コード例 #1
0
ファイル: local.go プロジェクト: slack/helm
// AddChartToLocalRepo saves a chart in the given path and then reindexes the index file
func AddChartToLocalRepo(ch *chart.Chart, path string) error {
	_, err := chartutil.Save(ch, path)
	if err != nil {
		return err
	}
	return Reindex(ch, path+"/index.yaml")
}
コード例 #2
0
ファイル: package.go プロジェクト: gabrtv/helm
func runPackage(cmd *cobra.Command, args []string) error {
	path := "."

	if len(args) > 0 {
		path = args[0]
	} else {
		return fmt.Errorf("This command needs at least one argument, the path to the chart.")
	}

	path, err := filepath.Abs(path)
	if err != nil {
		return err
	}

	ch, err := chartutil.LoadDir(path)
	if err != nil {
		return err
	}

	if filepath.Base(path) != ch.Metadata.Name {
		return fmt.Errorf("directory name (%s) and Chart.yaml name (%s) must match", filepath.Base(path), ch.Metadata.Name)
	}

	// Save to the current working directory.
	cwd, err := os.Getwd()
	if err != nil {
		return err
	}
	name, err := chartutil.Save(ch, cwd)
	if err == nil && flagDebug {
		cmd.Printf("Saved %s to current directory\n", name)
	}

	// Save to $HELM_HOME/local directory. This is second, because we don't want
	// the case where we saved here, but didn't save to the default destination.
	if save {
		if err := repo.AddChartToLocalRepo(ch, localRepoDirectory()); err != nil {
			return err
		} else if flagDebug {
			cmd.Printf("Saved %s to %s\n", name, localRepoDirectory())
		}
	}

	return err
}
コード例 #3
0
ファイル: package.go プロジェクト: kubernetes/helm
func (p *packageCmd) run(cmd *cobra.Command, args []string) error {
	path, err := filepath.Abs(p.path)
	if err != nil {
		return err
	}

	ch, err := chartutil.LoadDir(path)
	if err != nil {
		return err
	}

	if filepath.Base(path) != ch.Metadata.Name {
		return fmt.Errorf("directory name (%s) and Chart.yaml name (%s) must match", filepath.Base(path), ch.Metadata.Name)
	}

	// Save to the current working directory.
	cwd, err := os.Getwd()
	if err != nil {
		return err
	}
	name, err := chartutil.Save(ch, cwd)
	if err == nil && flagDebug {
		fmt.Fprintf(p.out, "Saved %s to current directory\n", name)
	}

	// Save to $HELM_HOME/local directory. This is second, because we don't want
	// the case where we saved here, but didn't save to the default destination.
	if p.save {
		lr := p.home.LocalRepository()
		if err := repo.AddChartToLocalRepo(ch, lr); err != nil {
			return err
		} else if flagDebug {
			fmt.Fprintf(p.out, "Saved %s to %s\n", name, lr)
		}
	}

	if p.sign {
		err = p.clearsign(name)
	}

	return err
}