@@ -138,7 +138,7 @@ func (p *createAPISubcommand) InjectResource(res *resource.Resource) error {
138
138
p .options .UpdateResource (p .resource , p .config )
139
139
140
140
if err := p .resource .Validate (); err != nil {
141
- return err
141
+ return fmt . Errorf ( "error validating resource: %w" , err )
142
142
}
143
143
144
144
// Check that the provided group can be added to the project
@@ -186,17 +186,17 @@ func (p *createAPISubcommand) Scaffold(fs machinery.Filesystem) error {
186
186
scaffolder .InjectFS (fs )
187
187
err := scaffolder .Scaffold ()
188
188
if err != nil {
189
- return err
189
+ return fmt . Errorf ( "error scaffolding deploy-image plugin: %w" , err )
190
190
}
191
191
192
192
// Track the resources following a declarative approach
193
193
cfg := PluginConfig {}
194
- if err : = p .config .DecodePluginConfig (pluginKey , & cfg ); errors .As (err , & config.UnsupportedFieldError {}) {
194
+ if err = p .config .DecodePluginConfig (pluginKey , & cfg ); errors .As (err , & config.UnsupportedFieldError {}) {
195
195
// Skip tracking as the config doesn't support per-plugin configuration
196
196
return nil
197
197
} else if err != nil && ! errors .As (err , & config.PluginKeyNotFoundError {}) {
198
198
// Fail unless the key wasn't found, which just means it is the first resource tracked
199
- return err
199
+ return fmt . Errorf ( "error decoding plugin configuration: %w" , err )
200
200
}
201
201
202
202
configDataOptions := options {
@@ -212,25 +212,30 @@ func (p *createAPISubcommand) Scaffold(fs machinery.Filesystem) error {
212
212
Kind : p .resource .GVK .Kind ,
213
213
Options : configDataOptions ,
214
214
})
215
- return p .config .EncodePluginConfig (pluginKey , cfg )
215
+
216
+ if err = p .config .EncodePluginConfig (pluginKey , cfg ); err != nil {
217
+ return fmt .Errorf ("error encoding plugin configuration: %w" , err )
218
+ }
219
+
220
+ return nil
216
221
}
217
222
218
223
func (p * createAPISubcommand ) PostScaffold () error {
219
224
err := util .RunCmd ("Update dependencies" , "go" , "mod" , "tidy" )
220
225
if err != nil {
221
- return err
226
+ return fmt . Errorf ( "error updating go dependencies: %w" , err )
222
227
}
223
228
if p .runMake && p .resource .HasAPI () {
224
229
err = util .RunCmd ("Running make" , "make" , "generate" )
225
230
if err != nil {
226
- return err
231
+ return fmt . Errorf ( "ailed running make generate: %w" , err )
227
232
}
228
233
}
229
234
230
235
if p .runManifests && p .resource .HasAPI () {
231
236
err = util .RunCmd ("Running make" , "make" , "manifests" )
232
237
if err != nil {
233
- return err
238
+ return fmt . Errorf ( "failed running make manifests: %w" , err )
234
239
}
235
240
}
236
241
0 commit comments