示例#1
0
func arrangeArtifacts(artifacts []ArtifactEntry) []string {
	result := make([]string, 0, len(artifacts))
	for _, artifact := range artifacts {
		if artifact.Path == "" {
			continue
		}
		sanitized := utils.SanitizePath(artifact.Path)
		result = append(result, sanitized)
	}
	return result
}
示例#2
0
//processArtifacts iterates through each artifact entry
//It then substitutes the Nulecule parameters in and saves them in the workdir
func (b *Base) processArtifacts(c *Component, provider string, ask bool) {
	for _, artifactEntry := range c.Artifacts[provider] {
		//Process inherited artifacts as well
		if len(artifactEntry.Repo.Inherit) > 0 {
			for _, inheritedProvider := range artifactEntry.Repo.Inherit {
				b.processArtifacts(c, inheritedProvider, ask)
			}
		}
		//sanitize the prefix from the file path
		santitizedPath := utils.SanitizePath(artifactEntry.Path)
		//Form the absolute path of the artifact
		artifactPath := filepath.Join(b.Target(), santitizedPath)
		b.applyTemplate(artifactPath, c, ask)
	}
}
示例#3
0
//Issues a command to kubectl.
//Path is the path of the kubernets file to pass to kubectl
func (p *Kubernetes) kubectlCmd(path string) error {
	if p.Namespace == "" {
		p.Namespace = constants.DEFAULT_NAMESPACE
	}
	path = utils.SanitizePath(path)
	namespaceFlag := fmt.Sprintf("--namespace=%s", p.Namespace)
	kubeCmd := exec.Command(p.KubeCtl, "create", "-f", path, namespaceFlag)

	//In a dry run, we don't actually execute the commands, so we log and return here
	if p.DryRun() {
		logrus.Infof("DRY RUN: %s\n", kubeCmd.Args)
		return nil
	}

	if _, err := utils.CheckCommandOutput(kubeCmd, false); err != nil {
		return err
	}
	return nil
}