added warning each time old repository is noticed

Signed-off-by: Matt Butcher <matt.butcher@microsoft.com>
pull/8901/head
Matt Butcher 5 years ago
parent 26c522edf3
commit a617b85cd6
No known key found for this signature in database
GPG Key ID: DCD5F5E5EF32C345

@ -36,6 +36,7 @@ import (
helm_env "k8s.io/helm/pkg/helm/environment"
"k8s.io/helm/pkg/helm/portforwarder"
"k8s.io/helm/pkg/kube"
"k8s.io/helm/pkg/repo"
"k8s.io/helm/pkg/tlsutil"
)
@ -175,6 +176,52 @@ Environment:
`
func checkForExpiredRepos(repofile string) {
expiredRepos := []struct {
name string
old string
new string
}{
{
name: "stable",
old: "kubernetes-charts.storage.googleapis.com",
new: "https://charts.helm.sh/stable",
},
{
name: "incubator",
old: "kubernetes-charts-incubator.storage.googleapis.com",
new: "https://charts.helm.sh/incubator",
},
}
// parse repo file.
// Ignore the error because it is okay for a repo file to be unparseable at this
// stage. Later checks will trap the error and respond accordingly.
repoFile, err := repo.LoadRepositoriesFile(repofile)
if err != nil {
return
}
for _, exp := range expiredRepos {
r, ok := repoFile.Get(exp.name)
if !ok {
return
}
if url := r.URL; strings.Contains(url, exp.old) {
fmt.Fprintf(
os.Stderr,
"WARNING: %q is deprecated for %q and will be deleted Nov. 13, 2020.\nWARNING: You should switch to %q\n",
exp.old,
exp.name,
exp.new,
)
}
}
}
func newRootCmd(args []string) *cobra.Command {
cmd := &cobra.Command{
Use: "helm",
@ -182,6 +229,7 @@ func newRootCmd(args []string) *cobra.Command {
Long: globalUsage,
SilenceUsage: true,
PersistentPreRun: func(*cobra.Command, []string) {
checkForExpiredRepos(settings.Home.RepositoryFile())
if settings.TLSCaCertFile == helm_env.DefaultTLSCaCert || settings.TLSCaCertFile == "" {
settings.TLSCaCertFile = settings.Home.TLSCaCert()
} else {

@ -48,7 +48,7 @@ helm init [flags]
--service-account string Name of service account
--skip-refresh Do not refresh (download) the local repository cache
--skip-repos Skip adding the stable and local repositories
--stable-repo-url string URL for stable repository (default "https://kubernetes-charts.storage.googleapis.com")
--stable-repo-url string URL for stable repository (default "https://charts.helm.sh/stable")
-i, --tiller-image string Override Tiller image
--tiller-tls Install Tiller with TLS enabled
--tiller-tls-cert string Path to TLS certificate file to install with Tiller
@ -57,6 +57,7 @@ helm init [flags]
--tiller-tls-verify Install Tiller with TLS enabled and to verify remote certificates
--tls-ca-cert string Path to CA root certificate
--upgrade Upgrade if Tiller is already installed
--use-deprecated-stable-repository Use the old (googleapis) repository URL even though that URL is being shutdown.
--wait Block until Tiller is running and ready to receive requests
```
@ -76,4 +77,4 @@ helm init [flags]
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 25-Jun-2020
###### Auto generated by spf13/cobra on 15-Oct-2020

Loading…
Cancel
Save