|
|
@ -13,8 +13,15 @@ import (
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var untarFile bool
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO(vaikas): Is there a well known directory for these??
|
|
|
|
|
|
|
|
var untarDir string
|
|
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
func init() {
|
|
|
|
RootCommand.AddCommand(fetchCmd)
|
|
|
|
RootCommand.AddCommand(fetchCmd)
|
|
|
|
|
|
|
|
fetchCmd.Flags().BoolVar(&untarFile, "untar", false, "If set to true, will untar the chart after downloading it.")
|
|
|
|
|
|
|
|
fetchCmd.Flags().StringVar(&untarDir, "untardir", ".", "If untar is specified, this flag specifies where to untar the chart.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var fetchCmd = &cobra.Command{
|
|
|
|
var fetchCmd = &cobra.Command{
|
|
|
@ -49,10 +56,8 @@ func fetch(cmd *cobra.Command, args []string) error {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
defer resp.Body.Close()
|
|
|
|
defer resp.Body.Close()
|
|
|
|
// TODO(vaikas): Implement untar / flag
|
|
|
|
if untarFile {
|
|
|
|
untar := false
|
|
|
|
return chart.Expand(untarDir, resp.Body)
|
|
|
|
if untar {
|
|
|
|
|
|
|
|
return untarChart(resp.Body)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
p := strings.Split(u.String(), "/")
|
|
|
|
p := strings.Split(u.String(), "/")
|
|
|
|
return saveChartFile(p[len(p)-1], resp.Body)
|
|
|
|
return saveChartFile(p[len(p)-1], resp.Body)
|
|
|
@ -84,18 +89,6 @@ func mapRepoArg(arg string, r map[string]string) (*url.URL, error) {
|
|
|
|
return nil, fmt.Errorf("Invalid chart url format: %s", arg)
|
|
|
|
return nil, fmt.Errorf("Invalid chart url format: %s", arg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func untarChart(r io.Reader) error {
|
|
|
|
|
|
|
|
c, err := chart.LoadDataFromReader(r)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if c == nil {
|
|
|
|
|
|
|
|
return fmt.Errorf("Failed to untar the chart")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return fmt.Errorf("Not implemented yee")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func saveChartFile(c string, r io.Reader) error {
|
|
|
|
func saveChartFile(c string, r io.Reader) error {
|
|
|
|
// Grab the chart name that we'll use for the name of the file to download to.
|
|
|
|
// Grab the chart name that we'll use for the name of the file to download to.
|
|
|
|
out, err := os.Create(c)
|
|
|
|
out, err := os.Create(c)
|
|
|
|