Skip to content

Commit 63c9ff6

Browse files
committed
Fission patch for code generation
Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
1 parent 840eca3 commit 63c9ff6

3 files changed

Lines changed: 110 additions & 77 deletions

File tree

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

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ func (c *fake$.type|publicPlural$) List(ctx $.contextContext|raw$, opts $.ListOp
379379
`
380380

381381
var getTemplate = `
382-
// Get takes name of the $.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any.
382+
// Get takes name of the _$.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any.
383383
func (c *fake$.type|publicPlural$) Get(ctx $.contextContext|raw$, name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) {
384384
emptyResult := &$.resultType|raw${}
385385
obj, err := c.Fake.
@@ -393,12 +393,12 @@ func (c *fake$.type|publicPlural$) Get(ctx $.contextContext|raw$, name string, o
393393
`
394394

395395
var getSubresourceTemplate = `
396-
// Get takes name of the $.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any.
397-
func (c *fake$.type|publicPlural$) Get(ctx $.contextContext|raw$, $.type|private$Name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) {
396+
// Get takes name of the _$.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any.
397+
func (c *fake$.type|publicPlural$) Get(ctx $.contextContext|raw$, _$.type|private$Name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) {
398398
emptyResult := &$.resultType|raw${}
399399
obj, err := c.Fake.
400-
$if .namespaced$Invokes($.NewGetSubresourceActionWithOptions|raw$(c.Resource(), c.Namespace(), "$.subresourcePath$", $.type|private$Name, options), emptyResult)
401-
$else$Invokes($.NewRootGetSubresourceActionWithOptions|raw$(c.Resource(), "$.subresourcePath$", $.type|private$Name, options), emptyResult)$end$
400+
$if .namespaced$Invokes($.NewGetSubresourceActionWithOptions|raw$(c.Resource(), c.Namespace(), "$.subresourcePath$", _$.type|private$Name, options), emptyResult)
401+
$else$Invokes($.NewRootGetSubresourceActionWithOptions|raw$(c.Resource(), "$.subresourcePath$", _$.type|private$Name, options), emptyResult)$end$
402402
if obj == nil {
403403
return emptyResult, err
404404
}
@@ -407,7 +407,7 @@ func (c *fake$.type|publicPlural$) Get(ctx $.contextContext|raw$, $.type|private
407407
`
408408

409409
var deleteTemplate = `
410-
// Delete takes name of the $.type|private$ and deletes it. Returns an error if one occurs.
410+
// Delete takes name of the _$.type|private$ and deletes it. Returns an error if one occurs.
411411
func (c *fake$.type|publicPlural$) Delete(ctx $.contextContext|raw$, name string, opts $.DeleteOptions|raw$) error {
412412
_, err := c.Fake.
413413
$if .namespaced$Invokes($.NewDeleteActionWithOptions|raw$(c.Resource(), c.Namespace(), name, opts), &$.type|raw${})
@@ -417,12 +417,12 @@ func (c *fake$.type|publicPlural$) Delete(ctx $.contextContext|raw$, name string
417417
`
418418

419419
var createTemplate = `
420-
// 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.
421-
func (c *fake$.type|publicPlural$) Create(ctx $.contextContext|raw$, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) {
420+
// 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.
421+
func (c *fake$.type|publicPlural$) Create(ctx $.contextContext|raw$, _$.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) {
422422
emptyResult := &$.resultType|raw${}
423423
obj, err := c.Fake.
424-
$if .namespaced$Invokes($.NewCreateActionWithOptions|raw$(c.Resource(), c.Namespace(), $.inputType|private$, opts), emptyResult)
425-
$else$Invokes($.NewRootCreateActionWithOptions|raw$(c.Resource(), $.inputType|private$, opts), emptyResult)$end$
424+
$if .namespaced$Invokes($.NewCreateActionWithOptions|raw$(c.Resource(), c.Namespace(), _$.inputType|private$, opts), emptyResult)
425+
$else$Invokes($.NewRootCreateActionWithOptions|raw$(c.Resource(), _$.inputType|private$, opts), emptyResult)$end$
426426
if obj == nil {
427427
return emptyResult, err
428428
}
@@ -431,12 +431,12 @@ func (c *fake$.type|publicPlural$) Create(ctx $.contextContext|raw$, $.inputType
431431
`
432432

433433
var createSubresourceTemplate = `
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 $.contextContext|raw$, $.type|private$Name string, $.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 $.contextContext|raw$, _$.type|private$Name string, _$.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) {
436436
emptyResult := &$.resultType|raw${}
437437
obj, err := c.Fake.
438-
$if .namespaced$Invokes($.NewCreateSubresourceActionWithOptions|raw$(c.Resource(), $.type|private$Name, "$.subresourcePath$", c.Namespace(), $.inputType|private$, opts), emptyResult)
439-
$else$Invokes($.NewRootCreateSubresourceActionWithOptions|raw$(c.Resource(), $.type|private$Name, "$.subresourcePath$", $.inputType|private$, opts), emptyResult)$end$
438+
$if .namespaced$Invokes($.NewCreateSubresourceActionWithOptions|raw$(c.Resource(), _$.type|private$Name, "$.subresourcePath$", c.Namespace(), _$.inputType|private$, opts), emptyResult)
439+
$else$Invokes($.NewRootCreateSubresourceActionWithOptions|raw$(c.Resource(), _$.type|private$Name, "$.subresourcePath$", _$.inputType|private$, opts), emptyResult)$end$
440440
if obj == nil {
441441
return emptyResult, err
442442
}
@@ -445,12 +445,12 @@ func (c *fake$.type|publicPlural$) Create(ctx $.contextContext|raw$, $.type|priv
445445
`
446446

447447
var updateTemplate = `
448-
// 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.
449-
func (c *fake$.type|publicPlural$) Update(ctx $.contextContext|raw$, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) {
448+
// 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.
449+
func (c *fake$.type|publicPlural$) Update(ctx $.contextContext|raw$, _$.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) {
450450
emptyResult := &$.resultType|raw${}
451451
obj, err := c.Fake.
452-
$if .namespaced$Invokes($.NewUpdateActionWithOptions|raw$(c.Resource(), c.Namespace(), $.inputType|private$, opts), emptyResult)
453-
$else$Invokes($.NewRootUpdateActionWithOptions|raw$(c.Resource(), $.inputType|private$, opts), emptyResult)$end$
452+
$if .namespaced$Invokes($.NewUpdateActionWithOptions|raw$(c.Resource(), c.Namespace(), _$.inputType|private$, opts), emptyResult)
453+
$else$Invokes($.NewRootUpdateActionWithOptions|raw$(c.Resource(), _$.inputType|private$, opts), emptyResult)$end$
454454
if obj == nil {
455455
return emptyResult, err
456456
}
@@ -459,12 +459,12 @@ func (c *fake$.type|publicPlural$) Update(ctx $.contextContext|raw$, $.inputType
459459
`
460460

461461
var updateSubresourceTemplate = `
462-
// 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.
463-
func (c *fake$.type|publicPlural$) Update(ctx $.contextContext|raw$, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) {
462+
// 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.
463+
func (c *fake$.type|publicPlural$) Update(ctx $.contextContext|raw$, _$.type|private$Name string, _$.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) {
464464
emptyResult := &$.resultType|raw${}
465465
obj, err := c.Fake.
466-
$if .namespaced$Invokes($.NewUpdateSubresourceActionWithOptions|raw$(c.Resource(), "$.subresourcePath$", c.Namespace(), $.inputType|private$, opts), &$.inputType|raw${})
467-
$else$Invokes($.NewRootUpdateSubresourceActionWithOptions|raw$(c.Resource(), "$.subresourcePath$", $.inputType|private$, opts), emptyResult)$end$
466+
$if .namespaced$Invokes($.NewUpdateSubresourceActionWithOptions|raw$(c.Resource(), "$.subresourcePath$", c.Namespace(), _$.inputType|private$, opts), &$.inputType|raw${})
467+
$else$Invokes($.NewRootUpdateSubresourceActionWithOptions|raw$(c.Resource(), "$.subresourcePath$", _$.inputType|private$, opts), emptyResult)$end$
468468
if obj == nil {
469469
return emptyResult, err
470470
}
@@ -497,17 +497,17 @@ func (c *fake$.type|publicPlural$) Patch(ctx $.contextContext|raw$, name string,
497497

498498
var applyTemplate = `
499499
// Apply takes the given apply declarative configuration, applies it and returns the applied $.resultType|private$.
500-
func (c *fake$.type|publicPlural$) Apply(ctx $.contextContext|raw$, $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
501-
if $.inputType|private$ == nil {
502-
return nil, $.fmtErrorf|raw$("$.inputType|private$ provided to Apply must not be nil")
500+
func (c *fake$.type|publicPlural$) Apply(ctx $.contextContext|raw$, _$.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
501+
if _$.inputType|private$ == nil {
502+
return nil, $.fmtErrorf|raw$("_$.inputType|private$ provided to Apply must not be nil")
503503
}
504-
data, err := $.jsonMarshal|raw$($.inputType|private$)
504+
data, err := $.jsonMarshal|raw$(_$.inputType|private$)
505505
if err != nil {
506506
return nil, err
507507
}
508-
name := $.inputType|private$.Name
508+
name := _$.inputType|private$.Name
509509
if name == nil {
510-
return nil, $.fmtErrorf|raw$("$.inputType|private$.Name must be provided to Apply")
510+
return nil, $.fmtErrorf|raw$("_$.inputType|private$.Name must be provided to Apply")
511511
}
512512
emptyResult := &$.resultType|raw${}
513513
obj, err := c.Fake.
@@ -523,18 +523,18 @@ func (c *fake$.type|publicPlural$) Apply(ctx $.contextContext|raw$, $.inputType|
523523
var applySubresourceTemplate = `
524524
// Apply takes top resource name and the apply declarative configuration for $.subresourcePath$,
525525
// applies it and returns the applied $.resultType|private$, and an error, if there is any.
526-
func (c *fake$.type|publicPlural$) Apply(ctx $.contextContext|raw$, $.type|private$Name string, $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
527-
if $.inputType|private$ == nil {
528-
return nil, $.fmtErrorf|raw$("$.inputType|private$ provided to Apply must not be nil")
526+
func (c *fake$.type|publicPlural$) Apply(ctx $.contextContext|raw$, _$.type|private$Name string, _$.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
527+
if _$.inputType|private$ == nil {
528+
return nil, $.fmtErrorf|raw$("_$.inputType|private$ provided to Apply must not be nil")
529529
}
530-
data, err := $.jsonMarshal|raw$($.inputType|private$)
530+
data, err := $.jsonMarshal|raw$(_$.inputType|private$)
531531
if err != nil {
532532
return nil, err
533533
}
534534
emptyResult := &$.resultType|raw${}
535535
obj, err := c.Fake.
536-
$if .namespaced$Invokes($.NewPatchSubresourceActionWithOptions|raw$(c.Resource(), c.Namespace(), $.type|private$Name, $.ApplyPatchType|raw$, data, opts.ToPatchOptions(), "$.inputType|private$"), emptyResult)
537-
$else$Invokes($.NewRootPatchSubresourceActionWithOptions|raw$(c.Resource(), $.type|private$Name, $.ApplyPatchType|raw$, data, opts.ToPatchOptions(), "$.inputType|private$"), emptyResult)$end$
536+
$if .namespaced$Invokes($.NewPatchSubresourceActionWithOptions|raw$(c.Resource(), c.Namespace(), _$.type|private$Name, $.ApplyPatchType|raw$, data, opts.ToPatchOptions(), "_$.inputType|private$"), emptyResult)
537+
$else$Invokes($.NewRootPatchSubresourceActionWithOptions|raw$(c.Resource(), _$.type|private$Name, $.ApplyPatchType|raw$, data, opts.ToPatchOptions(), "_$.inputType|private$"), emptyResult)$end$
538538
if obj == nil {
539539
return emptyResult, err
540540
}

0 commit comments

Comments
 (0)