@@ -326,7 +326,7 @@ func (a *api) WriteContent() error {
326
326
if * extension .Verb == "apply" {
327
327
_ , gvString := codegenutil .ParsePathGroupVersion (pkg )
328
328
* a .importList = append (* a .importList , util .ImportFormat (fmt .Sprintf ("%sapplyconfig" , strings .ToLower (name )), fmt .Sprintf ("%s/%s" , a .ApplyConfigurationPackage , gvString )))
329
- a .InputType = fmt .Sprintf ("%sapplyconfig.%sApplyConfiguration" , strings .ToLower (name ), name )
329
+ a .InputType = fmt .Sprintf ("* %sapplyconfig.%sApplyConfiguration" , strings .ToLower (name ), name )
330
330
}
331
331
} else {
332
332
a .InputType = fmt .Sprintf ("*%sapi%s.%s" , a .PkgName , a .Version , name )
@@ -346,23 +346,23 @@ func (a *api) WriteContent() error {
346
346
347
347
if * extension .Verb == "create" {
348
348
a .Method = * extension .Method
349
- adjTemplate := adjustTemplate (createTemplate )
349
+ adjTemplate := adjustTemplate (createTemplate , "create" )
350
350
if err := templateExecute (adjTemplate , * a ); err != nil {
351
351
return err
352
352
}
353
353
}
354
354
355
355
if * extension .Verb == "update" {
356
356
a .Method = * extension .Method
357
- adjTemplate := adjustTemplate (updateTemplate )
357
+ adjTemplate := adjustTemplate (updateTemplate , "update" )
358
358
if err := templateExecute (adjTemplate , * a ); err != nil {
359
359
return err
360
360
}
361
361
}
362
362
363
363
if * extension .Verb == "apply" {
364
364
a .Method = * extension .Method
365
- adjTemplate := adjustTemplate (applyTemplate )
365
+ adjTemplate := adjustTemplate (applyTemplate , "apply" )
366
366
if err := templateExecute (adjTemplate , * a ); err != nil {
367
367
return err
368
368
}
@@ -414,7 +414,14 @@ func (p *packages) appendGenericImports(importList []string) []string {
414
414
util .ImportFormat (fmt .Sprintf ("%s%s" , p .Name , p .Version ), fmt .Sprintf ("%s/typed/%s/%s" , p .ClientPath , p .Name , p .Version )))
415
415
}
416
416
417
- func adjustTemplate (template string ) string {
417
+ func adjustTemplate (template , verb string ) string {
418
418
index := strings .Index (template , "ctx context.Context," ) + len ("ctx context.Context," )
419
- return string (template [:index ]) + " name string," + string (template [index :])
419
+ newTemplate := string (template [:index ]) + " name string," + string (template [index :])
420
+ return adjReturnValueInTemplate (newTemplate , verb )
421
+ }
422
+
423
+ func adjReturnValueInTemplate (template , verb string ) string {
424
+ s := fmt .Sprintf ("w.delegate.{{value .Method \" %s\" }}(ctx," , upperFirst (verb ))
425
+ index := strings .Index (template , s ) + len (s )
426
+ return string (template [:index ]) + " name, " + string (template [index :])
420
427
}
0 commit comments