|
|
@ -18,9 +18,12 @@ package main
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"io"
|
|
|
|
"path/filepath"
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
|
|
|
|
|
|
|
"k8s.io/helm/pkg/chartutil"
|
|
|
|
"k8s.io/helm/pkg/chartutil"
|
|
|
|
"k8s.io/helm/pkg/proto/hapi/chart"
|
|
|
|
"k8s.io/helm/pkg/proto/hapi/chart"
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -50,31 +53,40 @@ destination exists and there are files in that directory, conflicting files
|
|
|
|
will be overwritten, but other files will be left alone.
|
|
|
|
will be overwritten, but other files will be left alone.
|
|
|
|
`
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
type createCmd struct {
|
|
|
|
RootCommand.AddCommand(createCmd)
|
|
|
|
name string
|
|
|
|
|
|
|
|
out io.Writer
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var createCmd = &cobra.Command{
|
|
|
|
func newCreateCmd(out io.Writer) *cobra.Command {
|
|
|
|
|
|
|
|
cc := &createCmd{
|
|
|
|
|
|
|
|
out: out,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd := &cobra.Command{
|
|
|
|
Use: "create NAME",
|
|
|
|
Use: "create NAME",
|
|
|
|
Short: "create a new chart with the given name",
|
|
|
|
Short: "create a new chart with the given name",
|
|
|
|
Long: createDesc,
|
|
|
|
Long: createDesc,
|
|
|
|
RunE: runCreate,
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func runCreate(cmd *cobra.Command, args []string) error {
|
|
|
|
|
|
|
|
if len(args) == 0 {
|
|
|
|
if len(args) == 0 {
|
|
|
|
return errors.New("the name of the new chart is required")
|
|
|
|
return errors.New("the name of the new chart is required")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cname := args[0]
|
|
|
|
cc.name = args[0]
|
|
|
|
cmd.Printf("Creating %s\n", cname)
|
|
|
|
return cc.run()
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (c *createCmd) run() error {
|
|
|
|
|
|
|
|
fmt.Fprintf(c.out, "Creating %s\n", c.name)
|
|
|
|
|
|
|
|
|
|
|
|
chartname := filepath.Base(cname)
|
|
|
|
chartname := filepath.Base(c.name)
|
|
|
|
cfile := &chart.Metadata{
|
|
|
|
cfile := &chart.Metadata{
|
|
|
|
Name: chartname,
|
|
|
|
Name: chartname,
|
|
|
|
Description: "A Helm chart for Kubernetes",
|
|
|
|
Description: "A Helm chart for Kubernetes",
|
|
|
|
Version: "0.1.0",
|
|
|
|
Version: "0.1.0",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_, err := chartutil.Create(cfile, filepath.Dir(cname))
|
|
|
|
_, err := chartutil.Create(cfile, filepath.Dir(c.name))
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|