Skip to content

Commit 6452e9f

Browse files
authored
Merge pull request #4732 from kersten/chore/deploy-image-v1alpha1
🌱 (chore): replace '%v' with '%w' in deploy-image v1alpha1 plugin errors
2 parents 8ebf7b3 + 59f6978 commit 6452e9f

File tree

1 file changed

+14
-14
lines changed
  • pkg/plugins/golang/deploy-image/v1alpha1/scaffolds

1 file changed

+14
-14
lines changed

pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/api.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ func (s *apiScaffolder) Scaffold() error {
108108
if err := scaffold.Execute(
109109
&api.Types{Port: s.port},
110110
); err != nil {
111-
return fmt.Errorf("error updating APIs: %v", err)
111+
return fmt.Errorf("error updating APIs: %w", err)
112112
}
113113

114114
if err := scaffold.Execute(
115115
&samples.CRDSample{Port: s.port},
116116
); err != nil {
117-
return fmt.Errorf("error updating config/samples: %v", err)
117+
return fmt.Errorf("error updating config/samples: %w", err)
118118
}
119119

120120
controller := &controllers.Controller{
@@ -124,22 +124,22 @@ func (s *apiScaffolder) Scaffold() error {
124124
if err := scaffold.Execute(
125125
controller,
126126
); err != nil {
127-
return fmt.Errorf("error scaffolding controller: %v", err)
127+
return fmt.Errorf("error scaffolding controller: %w", err)
128128
}
129129

130130
if err := s.updateControllerCode(*controller); err != nil {
131-
return fmt.Errorf("error updating controller: %v", err)
131+
return fmt.Errorf("error updating controller: %w", err)
132132
}
133133

134134
defaultMainPath := "cmd/main.go"
135135
if err := s.updateMainByAddingEventRecorder(defaultMainPath); err != nil {
136-
return fmt.Errorf("error updating main.go: %v", err)
136+
return fmt.Errorf("error updating main.go: %w", err)
137137
}
138138

139139
if err := scaffold.Execute(
140140
&controllers.ControllerTest{Port: s.port},
141141
); err != nil {
142-
return fmt.Errorf("error creating controller/**_controller_test.go: %v", err)
142+
return fmt.Errorf("error creating controller/**_controller_test.go: %w", err)
143143
}
144144

145145
return s.addEnvVarIntoManager()
@@ -169,11 +169,11 @@ func (s *apiScaffolder) addEnvVarIntoManager() error {
169169
// plugins to do the default scaffolds which an API is created
170170
func (s *apiScaffolder) scaffoldCreateAPI() error {
171171
if err := s.scaffoldCreateAPIFromGolang(); err != nil {
172-
return fmt.Errorf("error scaffolding golang files for the new API: %v", err)
172+
return fmt.Errorf("error scaffolding golang files for the new API: %w", err)
173173
}
174174

175175
if err := s.scaffoldCreateAPIFromKustomize(); err != nil {
176-
return fmt.Errorf("error scaffolding kustomize manifests for the new API: %v", err)
176+
return fmt.Errorf("error scaffolding kustomize manifests for the new API: %w", err)
177177
}
178178
return nil
179179
}
@@ -190,7 +190,7 @@ func (s *apiScaffolder) updateMainByAddingEventRecorder(defaultMainPath string)
190190
Scheme: mgr.GetScheme(),`, s.resource.Kind),
191191
fmt.Sprintf(recorderTemplate, strings.ToLower(s.resource.Kind)),
192192
); err != nil {
193-
return fmt.Errorf("error scaffolding event recorder in %s: %v", defaultMainPath, err)
193+
return fmt.Errorf("error scaffolding event recorder in %q: %w", defaultMainPath, err)
194194
}
195195

196196
return nil
@@ -205,7 +205,7 @@ func (s *apiScaffolder) updateControllerCode(controller controllers.Controller)
205205
strings.ToLower(s.resource.Kind), // value for the name of the container
206206
),
207207
); err != nil {
208-
return fmt.Errorf("error scaffolding container in the controller path (%s): %v",
208+
return fmt.Errorf("error scaffolding container in the controller path %q: %w",
209209
controller.Path, err)
210210
}
211211

@@ -231,7 +231,7 @@ func (s *apiScaffolder) updateControllerCode(controller controllers.Controller)
231231
},
232232
},
233233
},`, fmt.Sprintf(commandTemplate, res)); err != nil {
234-
return fmt.Errorf("error scaffolding command in the controller path (%s): %v",
234+
return fmt.Errorf("error scaffolding command in the controller path %q: %w",
235235
controller.Path, err)
236236
}
237237
}
@@ -254,7 +254,7 @@ func (s *apiScaffolder) updateControllerCode(controller controllers.Controller)
254254
strings.ToLower(s.resource.Kind),
255255
strings.ToLower(s.resource.Kind)),
256256
); err != nil {
257-
return fmt.Errorf("error scaffolding container port in the controller path (%s): %v",
257+
return fmt.Errorf("error scaffolding container port in the controller path %q: %w",
258258
controller.Path,
259259
err)
260260
}
@@ -266,7 +266,7 @@ func (s *apiScaffolder) updateControllerCode(controller controllers.Controller)
266266
`RunAsNonRoot: ptr.To(true),`,
267267
fmt.Sprintf(runAsUserTemplate, s.runAsUser),
268268
); err != nil {
269-
return fmt.Errorf("error scaffolding user-id in the controller path (%s): %v",
269+
return fmt.Errorf("error scaffolding user-id in the controller path %q: %w",
270270
controller.Path, err)
271271
}
272272
}
@@ -284,7 +284,7 @@ func (s *apiScaffolder) scaffoldCreateAPIFromKustomize() error {
284284
kustomizeScaffolder.InjectFS(s.fs)
285285

286286
if err := kustomizeScaffolder.Scaffold(); err != nil {
287-
return fmt.Errorf("error scaffolding kustomize files for the APIs: %v", err)
287+
return fmt.Errorf("error scaffolding kustomize files for the APIs: %w", err)
288288
}
289289

290290
return nil

0 commit comments

Comments
 (0)