Skip to content

Commit a31ae27

Browse files
committed
🌱 (chore): wrap errors with %w and normalize formatting in kustomize/v2
Replaced uses of `%v` with `%w` in `fmt.Errorf` to support proper error wrapping. Standardized formatting style, e.g. quoting strings with `%q` where appropriate.
1 parent 6acdbd2 commit a31ae27

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

‎pkg/plugins/common/kustomize/v2/init.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ func (p *initSubcommand) InjectConfig(c config.Config) error {
7272
if p.name == "" {
7373
dir, err := os.Getwd()
7474
if err != nil {
75-
return fmt.Errorf("error getting current directory: %v", err)
75+
return fmt.Errorf("error getting current directory: %w", err)
7676
}
7777
p.name = strings.ToLower(filepath.Base(dir))
7878
}
7979
// Check if the project name is a valid k8s namespace (DNS 1123 label).
8080
if err := validation.IsDNS1123Label(p.name); err != nil {
81-
return fmt.Errorf("project name (%s) is invalid: %v", p.name, err)
81+
return fmt.Errorf("project name %q is invalid: %v", p.name, err)
8282
}
8383
return p.config.SetProjectName(p.name)
8484
}

‎pkg/plugins/common/kustomize/v2/scaffolds/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ func (s *apiScaffolder) Scaffold() error {
8181
&crd.Kustomization{},
8282
&crd.KustomizeConfig{},
8383
); err != nil {
84-
return fmt.Errorf("error scaffolding kustomize API manifests: %v", err)
84+
return fmt.Errorf("error scaffolding kustomize API manifests: %w", err)
8585
}
8686

8787
// If the gvk is non-empty
8888
if s.resource.Group != "" || s.resource.Version != "" || s.resource.Kind != "" {
8989
if err := scaffold.Execute(&samples.Kustomization{}); err != nil {
90-
return fmt.Errorf("error scaffolding manifests: %v", err)
90+
return fmt.Errorf("error scaffolding manifests: %w", err)
9191
}
9292
}
9393

‎pkg/plugins/common/kustomize/v2/scaffolds/webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (s *webhookScaffolder) Scaffold() error {
102102
}
103103

104104
if err := scaffold.Execute(buildScaffold...); err != nil {
105-
return fmt.Errorf("error scaffolding kustomize webhook manifests: %v", err)
105+
return fmt.Errorf("error scaffolding kustomize webhook manifests: %w", err)
106106
}
107107

108108
policyKustomizeFilePath := "config/network-policy/kustomization.yaml"

0 commit comments

Comments
 (0)