Skip to content

Commit e10ac19

Browse files
committed
Fission patch for client-gen
Signed-off-by: Sanket Sudake <[email protected]>
1 parent 557ce1f commit e10ac19

File tree

3 files changed

+128
-95
lines changed

3 files changed

+128
-95
lines changed

cmd/client-gen/generators/fake/generator_fake_for_type.go

+43-43
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ func (c *Fake$.type|publicPlural$) List(ctx context.Context, opts $.ListOptions|
385385
`
386386

387387
var getTemplate = `
388-
// Get takes name of the $.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any.
388+
// Get takes name of the _$.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any.
389389
func (c *Fake$.type|publicPlural$) Get(ctx context.Context, name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) {
390390
obj, err := c.Fake.
391391
$if .namespaced$Invokes($.NewGetAction|raw$($.type|allLowercasePlural$Resource, c.ns, name), &$.resultType|raw${})
@@ -398,11 +398,11 @@ func (c *Fake$.type|publicPlural$) Get(ctx context.Context, name string, options
398398
`
399399

400400
var getSubresourceTemplate = `
401-
// Get takes name of the $.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any.
402-
func (c *Fake$.type|publicPlural$) Get(ctx context.Context, $.type|private$Name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) {
401+
// Get takes name of the _$.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any.
402+
func (c *Fake$.type|publicPlural$) Get(ctx context.Context, _$.type|private$Name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) {
403403
obj, err := c.Fake.
404-
$if .namespaced$Invokes($.NewGetSubresourceAction|raw$($.type|allLowercasePlural$Resource, c.ns, "$.subresourcePath$", $.type|private$Name), &$.resultType|raw${})
405-
$else$Invokes($.NewRootGetSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", $.type|private$Name), &$.resultType|raw${})$end$
404+
$if .namespaced$Invokes($.NewGetSubresourceAction|raw$($.type|allLowercasePlural$Resource, c.ns, "$.subresourcePath$", _$.type|private$Name), &$.resultType|raw${})
405+
$else$Invokes($.NewRootGetSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", _$.type|private$Name), &$.resultType|raw${})$end$
406406
if obj == nil {
407407
return nil, err
408408
}
@@ -411,7 +411,7 @@ func (c *Fake$.type|publicPlural$) Get(ctx context.Context, $.type|private$Name
411411
`
412412

413413
var deleteTemplate = `
414-
// Delete takes name of the $.type|private$ and deletes it. Returns an error if one occurs.
414+
// Delete takes name of the _$.type|private$ and deletes it. Returns an error if one occurs.
415415
func (c *Fake$.type|publicPlural$) Delete(ctx context.Context, name string, opts $.DeleteOptions|raw$) error {
416416
_, err := c.Fake.
417417
$if .namespaced$Invokes($.NewDeleteActionWithOptions|raw$($.type|allLowercasePlural$Resource, c.ns, name, opts), &$.type|raw${})
@@ -431,11 +431,11 @@ func (c *Fake$.type|publicPlural$) DeleteCollection(ctx context.Context, opts $.
431431
}
432432
`
433433
var createTemplate = `
434-
// Create takes the representation of a $.inputType|private$ and creates it. Returns the server's representation of the $.resultType|private$, and an error, if there is any.
435-
func (c *Fake$.type|publicPlural$) Create(ctx context.Context, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) {
434+
// Create takes the representation of a _$.inputType|private$ and creates it. Returns the server's representation of the $.resultType|private$, and an error, if there is any.
435+
func (c *Fake$.type|publicPlural$) Create(ctx context.Context, _$.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) {
436436
obj, err := c.Fake.
437-
$if .namespaced$Invokes($.NewCreateAction|raw$($.inputType|allLowercasePlural$Resource, c.ns, $.inputType|private$), &$.resultType|raw${})
438-
$else$Invokes($.NewRootCreateAction|raw$($.inputType|allLowercasePlural$Resource, $.inputType|private$), &$.resultType|raw${})$end$
437+
$if .namespaced$Invokes($.NewCreateAction|raw$($.inputType|allLowercasePlural$Resource, c.ns, _$.inputType|private$), &$.resultType|raw${})
438+
$else$Invokes($.NewRootCreateAction|raw$($.inputType|allLowercasePlural$Resource, _$.inputType|private$), &$.resultType|raw${})$end$
439439
if obj == nil {
440440
return nil, err
441441
}
@@ -444,11 +444,11 @@ func (c *Fake$.type|publicPlural$) Create(ctx context.Context, $.inputType|priva
444444
`
445445

446446
var createSubresourceTemplate = `
447-
// Create takes the representation of a $.inputType|private$ and creates it. Returns the server's representation of the $.resultType|private$, and an error, if there is any.
448-
func (c *Fake$.type|publicPlural$) Create(ctx context.Context, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) {
447+
// Create takes the representation of a _$.inputType|private$ and creates it. Returns the server's representation of the $.resultType|private$, and an error, if there is any.
448+
func (c *Fake$.type|publicPlural$) Create(ctx context.Context, _$.type|private$Name string, _$.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) {
449449
obj, err := c.Fake.
450-
$if .namespaced$Invokes($.NewCreateSubresourceAction|raw$($.type|allLowercasePlural$Resource, $.type|private$Name, "$.subresourcePath$", c.ns, $.inputType|private$), &$.resultType|raw${})
451-
$else$Invokes($.NewRootCreateSubresourceAction|raw$($.type|allLowercasePlural$Resource, $.type|private$Name, "$.subresourcePath$", $.inputType|private$), &$.resultType|raw${})$end$
450+
$if .namespaced$Invokes($.NewCreateSubresourceAction|raw$($.type|allLowercasePlural$Resource, _$.type|private$Name, "$.subresourcePath$", c.ns, _$.inputType|private$), &$.resultType|raw${})
451+
$else$Invokes($.NewRootCreateSubresourceAction|raw$($.type|allLowercasePlural$Resource, _$.type|private$Name, "$.subresourcePath$", _$.inputType|private$), &$.resultType|raw${})$end$
452452
if obj == nil {
453453
return nil, err
454454
}
@@ -457,11 +457,11 @@ func (c *Fake$.type|publicPlural$) Create(ctx context.Context, $.type|private$Na
457457
`
458458

459459
var updateTemplate = `
460-
// Update takes the representation of a $.inputType|private$ and updates it. Returns the server's representation of the $.resultType|private$, and an error, if there is any.
461-
func (c *Fake$.type|publicPlural$) Update(ctx context.Context, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) {
460+
// Update takes the representation of a _$.inputType|private$ and updates it. Returns the server's representation of the $.resultType|private$, and an error, if there is any.
461+
func (c *Fake$.type|publicPlural$) Update(ctx context.Context, _$.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) {
462462
obj, err := c.Fake.
463-
$if .namespaced$Invokes($.NewUpdateAction|raw$($.inputType|allLowercasePlural$Resource, c.ns, $.inputType|private$), &$.resultType|raw${})
464-
$else$Invokes($.NewRootUpdateAction|raw$($.inputType|allLowercasePlural$Resource, $.inputType|private$), &$.resultType|raw${})$end$
463+
$if .namespaced$Invokes($.NewUpdateAction|raw$($.inputType|allLowercasePlural$Resource, c.ns, _$.inputType|private$), &$.resultType|raw${})
464+
$else$Invokes($.NewRootUpdateAction|raw$($.inputType|allLowercasePlural$Resource, _$.inputType|private$), &$.resultType|raw${})$end$
465465
if obj == nil {
466466
return nil, err
467467
}
@@ -470,11 +470,11 @@ func (c *Fake$.type|publicPlural$) Update(ctx context.Context, $.inputType|priva
470470
`
471471

472472
var updateSubresourceTemplate = `
473-
// Update takes the representation of a $.inputType|private$ and updates it. Returns the server's representation of the $.resultType|private$, and an error, if there is any.
474-
func (c *Fake$.type|publicPlural$) Update(ctx context.Context, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) {
473+
// Update takes the representation of a _$.inputType|private$ and updates it. Returns the server's representation of the $.resultType|private$, and an error, if there is any.
474+
func (c *Fake$.type|publicPlural$) Update(ctx context.Context, _$.type|private$Name string, _$.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) {
475475
obj, err := c.Fake.
476-
$if .namespaced$Invokes($.NewUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", c.ns, $.inputType|private$), &$.inputType|raw${})
477-
$else$Invokes($.NewRootUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", $.inputType|private$), &$.resultType|raw${})$end$
476+
$if .namespaced$Invokes($.NewUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", c.ns, _$.inputType|private$), &$.inputType|raw${})
477+
$else$Invokes($.NewRootUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", _$.inputType|private$), &$.resultType|raw${})$end$
478478
if obj == nil {
479479
return nil, err
480480
}
@@ -485,10 +485,10 @@ func (c *Fake$.type|publicPlural$) Update(ctx context.Context, $.type|private$Na
485485
var updateStatusTemplate = `
486486
// UpdateStatus was generated because the type contains a Status member.
487487
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
488-
func (c *Fake$.type|publicPlural$) UpdateStatus(ctx context.Context, $.type|private$ *$.type|raw$, opts $.UpdateOptions|raw$) (*$.type|raw$, error) {
488+
func (c *Fake$.type|publicPlural$) UpdateStatus(ctx context.Context, _$.type|private$ *$.type|raw$, opts $.UpdateOptions|raw$) (*$.type|raw$, error) {
489489
obj, err := c.Fake.
490-
$if .namespaced$Invokes($.NewUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "status", c.ns, $.type|private$), &$.type|raw${})
491-
$else$Invokes($.NewRootUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "status", $.type|private$), &$.type|raw${})$end$
490+
$if .namespaced$Invokes($.NewUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "status", c.ns, _$.type|private$), &$.type|raw${})
491+
$else$Invokes($.NewRootUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "status", _$.type|private$), &$.type|raw${})$end$
492492
if obj == nil {
493493
return nil, err
494494
}
@@ -520,17 +520,17 @@ func (c *Fake$.type|publicPlural$) Patch(ctx context.Context, name string, pt $.
520520

521521
var applyTemplate = `
522522
// Apply takes the given apply declarative configuration, applies it and returns the applied $.resultType|private$.
523-
func (c *Fake$.type|publicPlural$) Apply(ctx context.Context, $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
524-
if $.inputType|private$ == nil {
525-
return nil, fmt.Errorf("$.inputType|private$ provided to Apply must not be nil")
523+
func (c *Fake$.type|publicPlural$) Apply(ctx context.Context, _$.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
524+
if _$.inputType|private$ == nil {
525+
return nil, fmt.Errorf("_$.inputType|private$ provided to Apply must not be nil")
526526
}
527-
data, err := $.jsonMarshal|raw$($.inputType|private$)
527+
data, err := $.jsonMarshal|raw$(_$.inputType|private$)
528528
if err != nil {
529529
return nil, err
530530
}
531-
name := $.inputType|private$.Name
531+
name := _$.inputType|private$.Name
532532
if name == nil {
533-
return nil, fmt.Errorf("$.inputType|private$.Name must be provided to Apply")
533+
return nil, fmt.Errorf("_$.inputType|private$.Name must be provided to Apply")
534534
}
535535
obj, err := c.Fake.
536536
$if .namespaced$Invokes($.NewPatchSubresourceAction|raw$($.type|allLowercasePlural$Resource, c.ns, *name, $.ApplyPatchType|raw$, data), &$.resultType|raw${})
@@ -545,17 +545,17 @@ func (c *Fake$.type|publicPlural$) Apply(ctx context.Context, $.inputType|privat
545545
var applyStatusTemplate = `
546546
// ApplyStatus was generated because the type contains a Status member.
547547
// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
548-
func (c *Fake$.type|publicPlural$) ApplyStatus(ctx context.Context, $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
549-
if $.inputType|private$ == nil {
550-
return nil, fmt.Errorf("$.inputType|private$ provided to Apply must not be nil")
548+
func (c *Fake$.type|publicPlural$) ApplyStatus(ctx context.Context, _$.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
549+
if _$.inputType|private$ == nil {
550+
return nil, fmt.Errorf("_$.inputType|private$ provided to Apply must not be nil")
551551
}
552-
data, err := $.jsonMarshal|raw$($.inputType|private$)
552+
data, err := $.jsonMarshal|raw$(_$.inputType|private$)
553553
if err != nil {
554554
return nil, err
555555
}
556-
name := $.inputType|private$.Name
556+
name := _$.inputType|private$.Name
557557
if name == nil {
558-
return nil, fmt.Errorf("$.inputType|private$.Name must be provided to Apply")
558+
return nil, fmt.Errorf("_$.inputType|private$.Name must be provided to Apply")
559559
}
560560
obj, err := c.Fake.
561561
$if .namespaced$Invokes($.NewPatchSubresourceAction|raw$($.type|allLowercasePlural$Resource, c.ns, *name, $.ApplyPatchType|raw$, data, "status"), &$.resultType|raw${})
@@ -570,17 +570,17 @@ func (c *Fake$.type|publicPlural$) ApplyStatus(ctx context.Context, $.inputType|
570570
var applySubresourceTemplate = `
571571
// Apply takes top resource name and the apply declarative configuration for $.subresourcePath$,
572572
// applies it and returns the applied $.resultType|private$, and an error, if there is any.
573-
func (c *Fake$.type|publicPlural$) Apply(ctx context.Context, $.type|private$Name string, $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
574-
if $.inputType|private$ == nil {
575-
return nil, fmt.Errorf("$.inputType|private$ provided to Apply must not be nil")
573+
func (c *Fake$.type|publicPlural$) Apply(ctx context.Context, _$.type|private$Name string, _$.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
574+
if _$.inputType|private$ == nil {
575+
return nil, fmt.Errorf("_$.inputType|private$ provided to Apply must not be nil")
576576
}
577-
data, err := $.jsonMarshal|raw$($.inputType|private$)
577+
data, err := $.jsonMarshal|raw$(_$.inputType|private$)
578578
if err != nil {
579579
return nil, err
580580
}
581581
obj, err := c.Fake.
582-
$if .namespaced$Invokes($.NewPatchSubresourceAction|raw$($.type|allLowercasePlural$Resource, c.ns, $.type|private$Name, $.ApplyPatchType|raw$, data, "status"), &$.resultType|raw${})
583-
$else$Invokes($.NewRootPatchSubresourceAction|raw$($.type|allLowercasePlural$Resource, $.type|private$Name, $.ApplyPatchType|raw$, data, "status"), &$.resultType|raw${})$end$
582+
$if .namespaced$Invokes($.NewPatchSubresourceAction|raw$($.type|allLowercasePlural$Resource, c.ns, _$.type|private$Name, $.ApplyPatchType|raw$, data, "status"), &$.resultType|raw${})
583+
$else$Invokes($.NewRootPatchSubresourceAction|raw$($.type|allLowercasePlural$Resource, _$.type|private$Name, $.ApplyPatchType|raw$, data, "status"), &$.resultType|raw${})$end$
584584
if obj == nil {
585585
return nil, err
586586
}

0 commit comments

Comments
 (0)