mirror of
https://github.com/helm/helm.git
synced 2026-04-22 23:00:01 -04:00
Merge af31a67924 into 4d4642b83f
This commit is contained in:
commit
b26aa40d69
8 changed files with 25 additions and 18 deletions
|
|
@ -21,6 +21,7 @@ linters:
|
|||
enable:
|
||||
- depguard
|
||||
- dupl
|
||||
- errorlint
|
||||
- exhaustive
|
||||
- gomodguard
|
||||
- govet
|
||||
|
|
@ -64,6 +65,12 @@ linters:
|
|||
dupl:
|
||||
threshold: 400
|
||||
|
||||
errorlint:
|
||||
# Check for plain type assertions and type switches.
|
||||
asserts: false
|
||||
# Check for plain error comparisons.
|
||||
comparison: false
|
||||
|
||||
exhaustive:
|
||||
default-signifies-exhaustive: true
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ func existingResourceConflict(resources kube.ResourceList, releaseName, releaseN
|
|||
|
||||
// Allow adoption of the resource if it is managed by Helm and is annotated with correct release name and namespace.
|
||||
if err := checkOwnership(existing, releaseName, releaseNamespace); err != nil {
|
||||
return fmt.Errorf("%s exists and cannot be imported into the current release: %s", resourceString(info), err)
|
||||
return fmt.Errorf("%s exists and cannot be imported into the current release: %w", resourceString(info), err)
|
||||
}
|
||||
|
||||
infoCopy := *info
|
||||
|
|
@ -116,13 +116,13 @@ func checkOwnership(obj runtime.Object, releaseName, releaseNamespace string) er
|
|||
|
||||
var errs []error
|
||||
if err := requireValue(lbls, appManagedByLabel, appManagedByHelm); err != nil {
|
||||
errs = append(errs, fmt.Errorf("label validation error: %s", err))
|
||||
errs = append(errs, fmt.Errorf("label validation error: %w", err))
|
||||
}
|
||||
if err := requireValue(annos, helmReleaseNameAnnotation, releaseName); err != nil {
|
||||
errs = append(errs, fmt.Errorf("annotation validation error: %s", err))
|
||||
errs = append(errs, fmt.Errorf("annotation validation error: %w", err))
|
||||
}
|
||||
if err := requireValue(annos, helmReleaseNamespaceAnnotation, releaseNamespace); err != nil {
|
||||
errs = append(errs, fmt.Errorf("annotation validation error: %s", err))
|
||||
errs = append(errs, fmt.Errorf("annotation validation error: %w", err))
|
||||
}
|
||||
|
||||
if len(errs) > 0 {
|
||||
|
|
@ -154,7 +154,7 @@ func setMetadataVisitor(releaseName, releaseNamespace string, forceOwnership boo
|
|||
|
||||
if !forceOwnership {
|
||||
if err := checkOwnership(info.Object, releaseName, releaseNamespace); err != nil {
|
||||
return fmt.Errorf("%s cannot be owned: %s", resourceString(info), err)
|
||||
return fmt.Errorf("%s cannot be owned: %w", resourceString(info), err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -162,7 +162,7 @@ func setMetadataVisitor(releaseName, releaseNamespace string, forceOwnership boo
|
|||
appManagedByLabel: appManagedByHelm,
|
||||
}); err != nil {
|
||||
return fmt.Errorf(
|
||||
"%s labels could not be updated: %s",
|
||||
"%s labels could not be updated: %w",
|
||||
resourceString(info), err,
|
||||
)
|
||||
}
|
||||
|
|
@ -172,7 +172,7 @@ func setMetadataVisitor(releaseName, releaseNamespace string, forceOwnership boo
|
|||
helmReleaseNamespaceAnnotation: releaseNamespace,
|
||||
}); err != nil {
|
||||
return fmt.Errorf(
|
||||
"%s annotations could not be updated: %s",
|
||||
"%s annotations could not be updated: %w",
|
||||
resourceString(info), err,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ func newLintCmd(out io.Writer) *cobra.Command {
|
|||
if kubeVersion != "" {
|
||||
parsedKubeVersion, err := common.ParseKubeVersion(kubeVersion)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid kube version '%s': %s", kubeVersion, err)
|
||||
return fmt.Errorf("invalid kube version '%s': %w", kubeVersion, err)
|
||||
}
|
||||
client.KubeVersion = parsedKubeVersion
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ func (o *pluginUninstallOptions) run(out io.Writer) error {
|
|||
for _, name := range o.names {
|
||||
if found := findPlugin(plugins, name); found != nil {
|
||||
if err := uninstallPlugin(found); err != nil {
|
||||
errorPlugins = append(errorPlugins, fmt.Errorf("failed to uninstall plugin %s, got error (%v)", name, err))
|
||||
errorPlugins = append(errorPlugins, fmt.Errorf("failed to uninstall plugin %s, got error (%w)", name, err))
|
||||
} else {
|
||||
fmt.Fprintf(out, "Uninstalled plugin: %s\n", name)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ func (o *pluginUpdateOptions) run(out io.Writer) error {
|
|||
for _, name := range o.names {
|
||||
if found := findPlugin(plugins, name); found != nil {
|
||||
if err := updatePlugin(found); err != nil {
|
||||
errorPlugins = append(errorPlugins, fmt.Errorf("failed to update plugin %s, got error (%v)", name, err))
|
||||
errorPlugins = append(errorPlugins, fmt.Errorf("failed to update plugin %s, got error (%w)", name, err))
|
||||
} else {
|
||||
fmt.Fprintf(out, "Updated plugin: %s\n", name)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error {
|
|||
return err
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("unable to retrieve file info for '%s': %v", destPath, err)
|
||||
return fmt.Errorf("unable to retrieve file info for '%s': %w", destPath, err)
|
||||
}
|
||||
|
||||
// Prepare tmpPath
|
||||
|
|
@ -281,17 +281,17 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error {
|
|||
chartPath := filepath.Join(destPath, dep.Name)
|
||||
ch, err := loader.LoadDir(chartPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to load chart '%s': %v", chartPath, err)
|
||||
return fmt.Errorf("unable to load chart '%s': %w", chartPath, 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: %w", 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: %w", dep.Version, dep.Name, err)
|
||||
}
|
||||
|
||||
if !constraint.Check(v) {
|
||||
|
|
|
|||
|
|
@ -1234,7 +1234,7 @@ func patchResourceServerSide(target *resource.Info, dryRun bool, forceConflicts
|
|||
)
|
||||
if err != nil {
|
||||
if isIncompatibleServerError(err) {
|
||||
return fmt.Errorf("server-side apply not available on the server: %v", err)
|
||||
return fmt.Errorf("server-side apply not available on the server: %w", err)
|
||||
}
|
||||
|
||||
if apierrors.IsConflict(err) {
|
||||
|
|
@ -1251,7 +1251,7 @@ func patchResourceServerSide(target *resource.Info, dryRun bool, forceConflicts
|
|||
func (c *Client) GetPodList(namespace string, listOptions metav1.ListOptions) (*v1.PodList, error) {
|
||||
podList, err := c.kubeClient.CoreV1().Pods(namespace).List(context.Background(), listOptions)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get pod list with options: %+v with error: %v", listOptions, err)
|
||||
return nil, fmt.Errorf("failed to get pod list with options: %+v with error: %w", listOptions, err)
|
||||
}
|
||||
return podList, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -485,7 +485,7 @@ func (s *SQL) Create(key string, rel release.Releaser) error {
|
|||
transaction, err := s.db.Beginx()
|
||||
if err != nil {
|
||||
s.Logger().Debug("failed to start SQL transaction", slog.Any("error", err))
|
||||
return fmt.Errorf("error beginning transaction: %v", err)
|
||||
return fmt.Errorf("error beginning transaction: %w", err)
|
||||
}
|
||||
|
||||
insertQuery, args, err := s.statementBuilder.
|
||||
|
|
@ -623,7 +623,7 @@ func (s *SQL) Delete(key string) (release.Releaser, error) {
|
|||
transaction, err := s.db.Beginx()
|
||||
if err != nil {
|
||||
s.Logger().Debug("failed to start SQL transaction", slog.Any("error", err))
|
||||
return nil, fmt.Errorf("error beginning transaction: %v", err)
|
||||
return nil, fmt.Errorf("error beginning transaction: %w", err)
|
||||
}
|
||||
|
||||
selectQuery, args, err := s.statementBuilder.
|
||||
|
|
|
|||
Loading…
Reference in a new issue