ref(helm): add default repository on init step

See #718
pull/720/head
Michelle Noorali 9 years ago
parent 57c9861116
commit 4b5eef90a1

@ -15,10 +15,12 @@ Kubernetes Cluster and sets up local configuration in $HELM_HOME (default: ~/.he
` `
var ( var (
tillerImg string tillerImg string
tillerNamespace string tillerNamespace string
clientOnly bool clientOnly bool
initSkipNamespace bool initSkipNamespace bool
defaultRepository = "kubernetes-charts"
defaultRepositoryURL = "http://storage.googleapis.com/kubernetes-charts"
) )
func init() { func init() {
@ -96,7 +98,7 @@ func ensureHome() error {
if _, err := os.Create(repoFile); err != nil { if _, err := os.Create(repoFile); err != nil {
return err return err
} }
if err := insertRepoLine("local", "http://localhost:8879/charts"); err != nil { if err := addRepository(defaultRepository, defaultRepositoryURL); err != nil {
return err return err
} }
} else if fi.IsDir() { } else if fi.IsDir() {

@ -55,15 +55,10 @@ func runRepoAdd(cmd *cobra.Command, args []string) error {
} }
name, url := args[0], args[1] name, url := args[0], args[1]
if err := repo.DownloadIndexFile(name, url, cacheDirectory(name, "-index.yaml")); err != nil { if err := addRepository(name, url); err != nil {
return errors.New("Oops! Looks like " + url + " is not a valid chart repository or cannot be reached\n")
}
if err := insertRepoLine(name, url); err != nil {
return err return err
} }
fmt.Println(name + " has been added to your repositories")
fmt.Println(args[0] + " has been added to your repositories")
return nil return nil
} }
@ -114,6 +109,14 @@ func index(dir, url string) error {
return chartRepo.Index() return chartRepo.Index()
} }
func addRepository(name, url string) error {
if err := repo.DownloadIndexFile(name, url, cacheDirectory(name, "-index.yaml")); err != nil {
return errors.New("Looks like " + url + " is not a valid chart repository or cannot be reached\n")
}
return insertRepoLine(name, url)
}
func removeRepoLine(name string) error { func removeRepoLine(name string) error {
r, err := repo.LoadRepositoriesFile(repositoriesFile()) r, err := repo.LoadRepositoriesFile(repositoriesFile())
if err != nil { if err != nil {

Loading…
Cancel
Save