From 5c14eec3a39fb2f2cabdd616e9638f15a0946934 Mon Sep 17 00:00:00 2001 From: Scaat Feng Date: Thu, 26 Nov 2020 13:43:23 +0800 Subject: [PATCH 1/8] [FIX]receiver names are different Signed-off-by: Scaat Feng --- pkg/action/action.go | 56 ++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index 79bb4f638..8accf38a0 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -102,11 +102,11 @@ type Configuration struct { // TODO: This function is badly in need of a refactor. // TODO: As part of the refactor the duplicate code in cmd/helm/template.go should be removed // This code has to do with writing files to disk. -func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values, releaseName, outputDir string, subNotes, useReleaseName, includeCrds bool, pr postrender.PostRenderer, dryRun bool) ([]*release.Hook, *bytes.Buffer, string, error) { +func (cfg *Configuration) renderResources(ch *chart.Chart, values chartutil.Values, releaseName, outputDir string, subNotes, useReleaseName, includeCrds bool, pr postrender.PostRenderer, dryRun bool) ([]*release.Hook, *bytes.Buffer, string, error) { hs := []*release.Hook{} b := bytes.NewBuffer(nil) - caps, err := c.getCapabilities() + caps, err := cfg.getCapabilities() if err != nil { return hs, b, "", err } @@ -125,8 +125,8 @@ func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values // is mocked. It is not up to the template author to decide when the user wants to // connect to the cluster. So when the user says to dry run, respect the user's // wishes and do not connect to the cluster. - if !dryRun && c.RESTClientGetter != nil { - rest, err := c.RESTClientGetter.ToRESTConfig() + if !dryRun && cfg.RESTClientGetter != nil { + rest, err := cfg.RESTClientGetter.ToRESTConfig() if err != nil { return hs, b, "", err } @@ -236,11 +236,11 @@ type RESTClientGetter interface { type DebugLog func(format string, v ...interface{}) // capabilities builds a Capabilities from discovery information. -func (c *Configuration) getCapabilities() (*chartutil.Capabilities, error) { - if c.Capabilities != nil { - return c.Capabilities, nil +func (cfg *Configuration) getCapabilities() (*chartutil.Capabilities, error) { + if cfg.Capabilities != nil { + return cfg.Capabilities, nil } - dc, err := c.RESTClientGetter.ToDiscoveryClient() + dc, err := cfg.RESTClientGetter.ToDiscoveryClient() if err != nil { return nil, errors.Wrap(err, "could not get Kubernetes discovery client") } @@ -258,14 +258,14 @@ func (c *Configuration) getCapabilities() (*chartutil.Capabilities, error) { apiVersions, err := GetVersionSet(dc) if err != nil { if discovery.IsGroupDiscoveryFailedError(err) { - c.Log("WARNING: The Kubernetes server has an orphaned API service. Server reports: %s", err) - c.Log("WARNING: To fix this, kubectl delete apiservice ") + cfg.Log("WARNING: The Kubernetes server has an orphaned API service. Server reports: %s", err) + cfg.Log("WARNING: To fix this, kubectl delete apiservice ") } else { return nil, errors.Wrap(err, "could not get apiVersions from Kubernetes") } } - c.Capabilities = &chartutil.Capabilities{ + cfg.Capabilities = &chartutil.Capabilities{ APIVersions: apiVersions, KubeVersion: chartutil.KubeVersion{ Version: kubeVersion.GitVersion, @@ -273,12 +273,12 @@ func (c *Configuration) getCapabilities() (*chartutil.Capabilities, error) { Minor: kubeVersion.Minor, }, } - return c.Capabilities, nil + return cfg.Capabilities, nil } // KubernetesClientSet creates a new kubernetes ClientSet based on the configuration -func (c *Configuration) KubernetesClientSet() (kubernetes.Interface, error) { - conf, err := c.RESTClientGetter.ToRESTConfig() +func (cfg *Configuration) KubernetesClientSet() (kubernetes.Interface, error) { + conf, err := cfg.RESTClientGetter.ToRESTConfig() if err != nil { return nil, errors.Wrap(err, "unable to generate config for kubernetes client") } @@ -290,20 +290,20 @@ func (c *Configuration) KubernetesClientSet() (kubernetes.Interface, error) { // // If the configuration has a Timestamper on it, that will be used. // Otherwise, this will use time.Now(). -func (c *Configuration) Now() time.Time { +func (cfg *Configuration) Now() time.Time { return Timestamper() } -func (c *Configuration) releaseContent(name string, version int) (*release.Release, error) { +func (cfg *Configuration) releaseContent(name string, version int) (*release.Release, error) { if err := chartutil.ValidateReleaseName(name); err != nil { return nil, errors.Errorf("releaseContent: Release name is invalid: %s", name) } if version <= 0 { - return c.Releases.Last(name) + return cfg.Releases.Last(name) } - return c.Releases.Get(name, version) + return cfg.Releases.Get(name, version) } // GetVersionSet retrieves a set of available k8s API versions @@ -355,14 +355,14 @@ func GetVersionSet(client discovery.ServerResourcesInterface) (chartutil.Version } // recordRelease with an update operation in case reuse has been set. -func (c *Configuration) recordRelease(r *release.Release) { - if err := c.Releases.Update(r); err != nil { - c.Log("warning: Failed to update release %s: %s", r.Name, err) +func (cfg *Configuration) recordRelease(r *release.Release) { + if err := cfg.Releases.Update(r); err != nil { + cfg.Log("warning: Failed to update release %s: %s", r.Name, err) } } // Init initializes the action configuration -func (c *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log DebugLog) error { +func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log DebugLog) error { kc := kube.New(getter) kc.Log = log @@ -383,8 +383,8 @@ func (c *Configuration) Init(getter genericclioptions.RESTClientGetter, namespac store = storage.Init(d) case "memory": var d *driver.Memory - if c.Releases != nil { - if mem, ok := c.Releases.Driver.(*driver.Memory); ok { + if cfg.Releases != nil { + if mem, ok := cfg.Releases.Driver.(*driver.Memory); ok { // This function can be called more than once (e.g., helm list --all-namespaces). // If a memory driver was already initialized, re-use it but set the possibly new namespace. // We re-use it in case some releases where already created in the existing memory driver. @@ -411,10 +411,10 @@ func (c *Configuration) Init(getter genericclioptions.RESTClientGetter, namespac panic("Unknown driver in HELM_DRIVER: " + helmDriver) } - c.RESTClientGetter = getter - c.KubeClient = kc - c.Releases = store - c.Log = log + cfg.RESTClientGetter = getter + cfg.KubeClient = kc + cfg.Releases = store + cfg.Log = log return nil } From b6bd8d7363cf6ffeb7178526e7284603a6bb4495 Mon Sep 17 00:00:00 2001 From: Scaat Feng Date: Thu, 26 Nov 2020 13:45:13 +0800 Subject: [PATCH 2/8] [FIX]'rest' collides with imported package name Signed-off-by: Scaat Feng --- pkg/action/action.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index 8accf38a0..4b2af5759 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -126,11 +126,11 @@ func (cfg *Configuration) renderResources(ch *chart.Chart, values chartutil.Valu // connect to the cluster. So when the user says to dry run, respect the user's // wishes and do not connect to the cluster. if !dryRun && cfg.RESTClientGetter != nil { - rest, err := cfg.RESTClientGetter.ToRESTConfig() + restConfig, err := cfg.RESTClientGetter.ToRESTConfig() if err != nil { return hs, b, "", err } - files, err2 = engine.RenderWithClient(ch, values, rest) + files, err2 = engine.RenderWithClient(ch, values, restConfig) } else { files, err2 = engine.Render(ch, values) } From 0de89685d428b8af7f1188711f256e7c12703e64 Mon Sep 17 00:00:00 2001 From: Scaat Feng Date: Thu, 26 Nov 2020 13:47:14 +0800 Subject: [PATCH 3/8] [COMMENT]fix comment Signed-off-by: Scaat Feng --- pkg/action/install.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/action/install.go b/pkg/action/install.go index caeefca68..df3c14212 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -219,7 +219,7 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release. return nil, err } - //special case for helm template --is-upgrade + // special case for helm template --is-upgrade isUpgrade := i.IsUpgrade && i.DryRun options := chartutil.ReleaseOptions{ Name: i.ReleaseName, From 14f6bde04a062da4e5491fdfd9e42263e127534b Mon Sep 17 00:00:00 2001 From: Scaat Feng Date: Thu, 26 Nov 2020 14:01:20 +0800 Subject: [PATCH 4/8] [FIX]error string should not be capitalized Signed-off-by: Scaat Feng --- pkg/downloader/manager.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index 145244082..34f8dd2f0 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -273,21 +273,21 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error { chartPath := filepath.Join(tmpPath, dep.Name) ch, err := loader.LoadDir(chartPath) if err != nil { - return fmt.Errorf("Unable to load chart: %v", err) + return fmt.Errorf("unable to load chart: %v", err) } constraint, err := semver.NewConstraint(dep.Version) if err != nil { - return fmt.Errorf("Dependency %s has an invalid version/constraint format: %s", dep.Name, err) + return fmt.Errorf("dependency %s has an invalid version/constraint format: %s", dep.Name, err) } v, err := semver.NewVersion(ch.Metadata.Version) if err != nil { - return fmt.Errorf("Invalid version %s for dependency %s: %s", dep.Version, dep.Name, err) + return fmt.Errorf("invalid version %s for dependency %s: %s", dep.Version, dep.Name, err) } if !constraint.Check(v) { - saveError = fmt.Errorf("Dependency %s at version %s does not satisfy the constraint %s", dep.Name, ch.Metadata.Version, dep.Version) + saveError = fmt.Errorf("dependency %s at version %s does not satisfy the constraint %s", dep.Name, ch.Metadata.Version, dep.Version) break } continue From 1852694a65a1d64496af06492833b3182032bec6 Mon Sep 17 00:00:00 2001 From: Scaat Feng Date: Thu, 26 Nov 2020 14:03:41 +0800 Subject: [PATCH 5/8] [FIX]comment should start with whitespace Signed-off-by: Scaat Feng --- pkg/engine/lookup_func.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index 20be9189e..38dd7cb7b 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -63,7 +63,7 @@ func NewLookupFunction(config *rest.Config) lookupFunc { } return obj.UnstructuredContent(), nil } - //this will return a list + // this will return a list obj, err := client.List(context.Background(), metav1.ListOptions{}) if err != nil { if apierrors.IsNotFound(err) { @@ -112,7 +112,7 @@ func getAPIReourceForGVK(gvk schema.GroupVersionKind, config *rest.Config) (meta return res, err } for _, resource := range resList.APIResources { - //if a resource contains a "/" it's referencing a subresource. we don't support suberesource for now. + // if a resource contains a "/" it's referencing a subresource. we don't support suberesource for now. if resource.Kind == gvk.Kind && !strings.Contains(resource.Name, "/") { res = resource res.Group = gvk.Group From f1f2e6ff4c4d65d14b1caa809be4257919047049 Mon Sep 17 00:00:00 2001 From: Scaat Feng Date: Thu, 26 Nov 2020 14:06:00 +0800 Subject: [PATCH 6/8] [FIX]comment should start with whitespace Signed-off-by: Scaat Feng --- pkg/getter/httpgetter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/getter/httpgetter.go b/pkg/getter/httpgetter.go index c100b2cc0..a2dce8c47 100644 --- a/pkg/getter/httpgetter.go +++ b/pkg/getter/httpgetter.go @@ -33,7 +33,7 @@ type HTTPGetter struct { opts options } -//Get performs a Get from repo.Getter and returns the body. +// Get performs a Get from repo.Getter and returns the body. func (g *HTTPGetter) Get(href string, options ...Option) (*bytes.Buffer, error) { for _, opt := range options { opt(&g.opts) From 9020c95fb139944a99632ad5154a4fd5d89032d1 Mon Sep 17 00:00:00 2001 From: Scaat Feng Date: Thu, 26 Nov 2020 14:11:27 +0800 Subject: [PATCH 7/8] [FIX]comment should start with whitespace Signed-off-by: Scaat Feng --- pkg/lint/rules/template.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/lint/rules/template.go b/pkg/lint/rules/template.go index 0bb9f8671..387d21edc 100644 --- a/pkg/lint/rules/template.go +++ b/pkg/lint/rules/template.go @@ -110,7 +110,7 @@ func Templates(linter *support.Linter, values map[string]interface{}, namespace // NOTE: disabled for now, Refs https://github.com/helm/helm/issues/1463 // Check that all the templates have a matching value - //linter.RunLinterRule(support.WarningSev, fpath, validateNoMissingValues(templatesPath, valuesToRender, preExecutedTemplate)) + // linter.RunLinterRule(support.WarningSev, fpath, validateNoMissingValues(templatesPath, valuesToRender, preExecutedTemplate)) // NOTE: disabled for now, Refs https://github.com/helm/helm/issues/1037 // linter.RunLinterRule(support.WarningSev, fpath, validateQuotes(string(preExecutedTemplate))) From 89f2f84a0241422d3c430e2e67c3e4e21fbf4eb8 Mon Sep 17 00:00:00 2001 From: Scaat Feng Date: Thu, 26 Nov 2020 14:13:38 +0800 Subject: [PATCH 8/8] [FIX]error string should not be capitalized Signed-off-by: Scaat Feng --- pkg/plugin/plugin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/plugin/plugin.go b/pkg/plugin/plugin.go index 93b5527a1..4c1c98285 100644 --- a/pkg/plugin/plugin.go +++ b/pkg/plugin/plugin.go @@ -151,7 +151,7 @@ func (p *Plugin) PrepareCommand(extraArgs []string) (string, []string, error) { parts = strings.Split(os.ExpandEnv(p.Metadata.Command), " ") } if len(parts) == 0 || parts[0] == "" { - return "", nil, fmt.Errorf("No plugin command is applicable") + return "", nil, fmt.Errorf("no plugin command is applicable") } main := parts[0]