diff --git a/cmd/client-gen/generators/fake/generator_fake_for_type.go b/cmd/client-gen/generators/fake/generator_fake_for_type.go index 6c141003..d1216efd 100644 --- a/cmd/client-gen/generators/fake/generator_fake_for_type.go +++ b/cmd/client-gen/generators/fake/generator_fake_for_type.go @@ -379,7 +379,7 @@ func (c *fake$.type|publicPlural$) List(ctx $.contextContext|raw$, opts $.ListOp ` var getTemplate = ` -// Get takes name of the $.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any. +// Get takes name of the _$.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any. func (c *fake$.type|publicPlural$) Get(ctx $.contextContext|raw$, name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) { emptyResult := &$.resultType|raw${} obj, err := c.Fake. @@ -393,12 +393,12 @@ func (c *fake$.type|publicPlural$) Get(ctx $.contextContext|raw$, name string, o ` var getSubresourceTemplate = ` -// Get takes name of the $.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any. -func (c *fake$.type|publicPlural$) Get(ctx $.contextContext|raw$, $.type|private$Name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) { +// Get takes name of the _$.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any. +func (c *fake$.type|publicPlural$) Get(ctx $.contextContext|raw$, _$.type|private$Name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) { emptyResult := &$.resultType|raw${} obj, err := c.Fake. - $if .namespaced$Invokes($.NewGetSubresourceActionWithOptions|raw$(c.Resource(), c.Namespace(), "$.subresourcePath$", $.type|private$Name, options), emptyResult) - $else$Invokes($.NewRootGetSubresourceActionWithOptions|raw$(c.Resource(), "$.subresourcePath$", $.type|private$Name, options), emptyResult)$end$ + $if .namespaced$Invokes($.NewGetSubresourceActionWithOptions|raw$(c.Resource(), c.Namespace(), "$.subresourcePath$", _$.type|private$Name, options), emptyResult) + $else$Invokes($.NewRootGetSubresourceActionWithOptions|raw$(c.Resource(), "$.subresourcePath$", _$.type|private$Name, options), emptyResult)$end$ if obj == nil { return emptyResult, err } @@ -407,7 +407,7 @@ func (c *fake$.type|publicPlural$) Get(ctx $.contextContext|raw$, $.type|private ` var deleteTemplate = ` -// Delete takes name of the $.type|private$ and deletes it. Returns an error if one occurs. +// Delete takes name of the _$.type|private$ and deletes it. Returns an error if one occurs. func (c *fake$.type|publicPlural$) Delete(ctx $.contextContext|raw$, name string, opts $.DeleteOptions|raw$) error { _, err := c.Fake. $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 ` var createTemplate = ` -// 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. -func (c *fake$.type|publicPlural$) Create(ctx $.contextContext|raw$, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) { +// 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. +func (c *fake$.type|publicPlural$) Create(ctx $.contextContext|raw$, _$.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) { emptyResult := &$.resultType|raw${} obj, err := c.Fake. - $if .namespaced$Invokes($.NewCreateActionWithOptions|raw$(c.Resource(), c.Namespace(), $.inputType|private$, opts), emptyResult) - $else$Invokes($.NewRootCreateActionWithOptions|raw$(c.Resource(), $.inputType|private$, opts), emptyResult)$end$ + $if .namespaced$Invokes($.NewCreateActionWithOptions|raw$(c.Resource(), c.Namespace(), _$.inputType|private$, opts), emptyResult) + $else$Invokes($.NewRootCreateActionWithOptions|raw$(c.Resource(), _$.inputType|private$, opts), emptyResult)$end$ if obj == nil { return emptyResult, err } @@ -431,12 +431,12 @@ func (c *fake$.type|publicPlural$) Create(ctx $.contextContext|raw$, $.inputType ` var createSubresourceTemplate = ` -// 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. -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) { +// 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. +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) { emptyResult := &$.resultType|raw${} obj, err := c.Fake. - $if .namespaced$Invokes($.NewCreateSubresourceActionWithOptions|raw$(c.Resource(), $.type|private$Name, "$.subresourcePath$", c.Namespace(), $.inputType|private$, opts), emptyResult) - $else$Invokes($.NewRootCreateSubresourceActionWithOptions|raw$(c.Resource(), $.type|private$Name, "$.subresourcePath$", $.inputType|private$, opts), emptyResult)$end$ + $if .namespaced$Invokes($.NewCreateSubresourceActionWithOptions|raw$(c.Resource(), _$.type|private$Name, "$.subresourcePath$", c.Namespace(), _$.inputType|private$, opts), emptyResult) + $else$Invokes($.NewRootCreateSubresourceActionWithOptions|raw$(c.Resource(), _$.type|private$Name, "$.subresourcePath$", _$.inputType|private$, opts), emptyResult)$end$ if obj == nil { return emptyResult, err } @@ -445,12 +445,12 @@ func (c *fake$.type|publicPlural$) Create(ctx $.contextContext|raw$, $.type|priv ` var updateTemplate = ` -// 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. -func (c *fake$.type|publicPlural$) Update(ctx $.contextContext|raw$, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) { +// 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. +func (c *fake$.type|publicPlural$) Update(ctx $.contextContext|raw$, _$.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) { emptyResult := &$.resultType|raw${} obj, err := c.Fake. - $if .namespaced$Invokes($.NewUpdateActionWithOptions|raw$(c.Resource(), c.Namespace(), $.inputType|private$, opts), emptyResult) - $else$Invokes($.NewRootUpdateActionWithOptions|raw$(c.Resource(), $.inputType|private$, opts), emptyResult)$end$ + $if .namespaced$Invokes($.NewUpdateActionWithOptions|raw$(c.Resource(), c.Namespace(), _$.inputType|private$, opts), emptyResult) + $else$Invokes($.NewRootUpdateActionWithOptions|raw$(c.Resource(), _$.inputType|private$, opts), emptyResult)$end$ if obj == nil { return emptyResult, err } @@ -459,12 +459,12 @@ func (c *fake$.type|publicPlural$) Update(ctx $.contextContext|raw$, $.inputType ` var updateSubresourceTemplate = ` -// 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. -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) { +// 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. +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) { emptyResult := &$.resultType|raw${} obj, err := c.Fake. - $if .namespaced$Invokes($.NewUpdateSubresourceActionWithOptions|raw$(c.Resource(), "$.subresourcePath$", c.Namespace(), $.inputType|private$, opts), &$.inputType|raw${}) - $else$Invokes($.NewRootUpdateSubresourceActionWithOptions|raw$(c.Resource(), "$.subresourcePath$", $.inputType|private$, opts), emptyResult)$end$ + $if .namespaced$Invokes($.NewUpdateSubresourceActionWithOptions|raw$(c.Resource(), "$.subresourcePath$", c.Namespace(), _$.inputType|private$, opts), &$.inputType|raw${}) + $else$Invokes($.NewRootUpdateSubresourceActionWithOptions|raw$(c.Resource(), "$.subresourcePath$", _$.inputType|private$, opts), emptyResult)$end$ if obj == nil { return emptyResult, err } @@ -497,17 +497,17 @@ func (c *fake$.type|publicPlural$) Patch(ctx $.contextContext|raw$, name string, var applyTemplate = ` // Apply takes the given apply declarative configuration, applies it and returns the applied $.resultType|private$. -func (c *fake$.type|publicPlural$) Apply(ctx $.contextContext|raw$, $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) { - if $.inputType|private$ == nil { - return nil, $.fmtErrorf|raw$("$.inputType|private$ provided to Apply must not be nil") +func (c *fake$.type|publicPlural$) Apply(ctx $.contextContext|raw$, _$.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) { + if _$.inputType|private$ == nil { + return nil, $.fmtErrorf|raw$("_$.inputType|private$ provided to Apply must not be nil") } - data, err := $.jsonMarshal|raw$($.inputType|private$) + data, err := $.jsonMarshal|raw$(_$.inputType|private$) if err != nil { return nil, err } - name := $.inputType|private$.Name + name := _$.inputType|private$.Name if name == nil { - return nil, $.fmtErrorf|raw$("$.inputType|private$.Name must be provided to Apply") + return nil, $.fmtErrorf|raw$("_$.inputType|private$.Name must be provided to Apply") } emptyResult := &$.resultType|raw${} obj, err := c.Fake. @@ -523,18 +523,18 @@ func (c *fake$.type|publicPlural$) Apply(ctx $.contextContext|raw$, $.inputType| var applySubresourceTemplate = ` // Apply takes top resource name and the apply declarative configuration for $.subresourcePath$, // applies it and returns the applied $.resultType|private$, and an error, if there is any. -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) { - if $.inputType|private$ == nil { - return nil, $.fmtErrorf|raw$("$.inputType|private$ provided to Apply must not be nil") +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) { + if _$.inputType|private$ == nil { + return nil, $.fmtErrorf|raw$("_$.inputType|private$ provided to Apply must not be nil") } - data, err := $.jsonMarshal|raw$($.inputType|private$) + data, err := $.jsonMarshal|raw$(_$.inputType|private$) if err != nil { return nil, err } emptyResult := &$.resultType|raw${} obj, err := c.Fake. - $if .namespaced$Invokes($.NewPatchSubresourceActionWithOptions|raw$(c.Resource(), c.Namespace(), $.type|private$Name, $.ApplyPatchType|raw$, data, opts.ToPatchOptions(), "$.inputType|private$"), emptyResult) - $else$Invokes($.NewRootPatchSubresourceActionWithOptions|raw$(c.Resource(), $.type|private$Name, $.ApplyPatchType|raw$, data, opts.ToPatchOptions(), "$.inputType|private$"), emptyResult)$end$ + $if .namespaced$Invokes($.NewPatchSubresourceActionWithOptions|raw$(c.Resource(), c.Namespace(), _$.type|private$Name, $.ApplyPatchType|raw$, data, opts.ToPatchOptions(), "_$.inputType|private$"), emptyResult) + $else$Invokes($.NewRootPatchSubresourceActionWithOptions|raw$(c.Resource(), _$.type|private$Name, $.ApplyPatchType|raw$, data, opts.ToPatchOptions(), "_$.inputType|private$"), emptyResult)$end$ if obj == nil { return emptyResult, err } diff --git a/cmd/client-gen/generators/generator_for_type.go b/cmd/client-gen/generators/generator_for_type.go index 00b949a7..82d53e77 100644 --- a/cmd/client-gen/generators/generator_for_type.go +++ b/cmd/client-gen/generators/generator_for_type.go @@ -358,23 +358,23 @@ func generateInterface(defaultVerbTemplates map[string]string, tags util.Tags) s func buildSubresourceDefaultVerbTemplates(generateApply bool) map[string]string { m := map[string]string{ - "create": `Create(ctx $.context|raw$, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (*$.resultType|raw$, error)`, - "list": `List(ctx $.context|raw$, $.type|private$Name string, opts $.ListOptions|raw$) (*$.resultType|raw$List, error)`, - "update": `Update(ctx $.context|raw$, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (*$.resultType|raw$, error)`, - "get": `Get(ctx $.context|raw$, $.type|private$Name string, options $.GetOptions|raw$) (*$.resultType|raw$, error)`, + "create": `Create(ctx $.context|raw$, _$.type|private$Name string, _$.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (*$.resultType|raw$, error)`, + "list": `List(ctx $.context|raw$, _$.type|private$Name string, opts $.ListOptions|raw$) (*$.resultType|raw$List, error)`, + "update": `Update(ctx $.context|raw$, _$.type|private$Name string, _$.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (*$.resultType|raw$, error)`, + "get": `Get(ctx $.context|raw$, _$.type|private$Name string, options $.GetOptions|raw$) (*$.resultType|raw$, error)`, } if generateApply { - m["apply"] = `Apply(ctx $.context|raw$, $.type|private$Name string, $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (*$.resultType|raw$, error)` + m["apply"] = `Apply(ctx $.context|raw$, _$.type|private$Name string, _$.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (*$.resultType|raw$, error)` } return m } func buildDefaultVerbTemplates(generateApply bool) map[string]string { m := map[string]string{ - "create": `Create(ctx $.context|raw$, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (*$.resultType|raw$, error)`, - "update": `Update(ctx $.context|raw$, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (*$.resultType|raw$, error)`, + "create": `Create(ctx $.context|raw$, _$.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (*$.resultType|raw$, error)`, + "update": `Update(ctx $.context|raw$, _$.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (*$.resultType|raw$, error)`, "updateStatus": `// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -UpdateStatus(ctx $.context|raw$, $.inputType|private$ *$.type|raw$, opts $.UpdateOptions|raw$) (*$.type|raw$, error)`, +UpdateStatus(ctx $.context|raw$, _$.inputType|private$ *$.type|raw$, opts $.UpdateOptions|raw$) (*$.type|raw$, error)`, "delete": `Delete(ctx $.context|raw$, name string, opts $.DeleteOptions|raw$) error`, "deleteCollection": `DeleteCollection(ctx $.context|raw$, opts $.DeleteOptions|raw$, listOpts $.ListOptions|raw$) error`, "get": `Get(ctx $.context|raw$, name string, opts $.GetOptions|raw$) (*$.resultType|raw$, error)`, @@ -383,9 +383,9 @@ UpdateStatus(ctx $.context|raw$, $.inputType|private$ *$.type|raw$, opts $.Updat "patch": `Patch(ctx $.context|raw$, name string, pt $.PatchType|raw$, data []byte, opts $.PatchOptions|raw$, subresources ...string) (result *$.resultType|raw$, err error)`, } if generateApply { - m["apply"] = `Apply(ctx $.context|raw$, $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error)` + m["apply"] = `Apply(ctx $.context|raw$, _$.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error)` m["applyStatus"] = `// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). -ApplyStatus(ctx $.context|raw$, $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error)` +ApplyStatus(ctx $.context|raw$, _$.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error)` } return m } @@ -643,7 +643,7 @@ func (c *$.type|privatePlural$) list(ctx $.context|raw$, opts $.ListOptions|raw$ var listSubresourceTemplate = ` // $.verb$ takes $.type|raw$ name, label and field selectors, and returns the list of $.resultType|publicPlural$ that match those selectors. -func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.type|private$Name string, opts $.ListOptions|raw$) (result *$.resultType|raw$List, err error) { +func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, _$.type|private$Name string, opts $.ListOptions|raw$) (result *$.resultType|raw$List, err error) { var timeout $.timeDuration|raw$ if opts.TimeoutSeconds != nil{ timeout = $.timeDuration|raw$(*opts.TimeoutSeconds) * $.timeSecond|raw$ @@ -653,7 +653,7 @@ func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.type|private$Name $if .prefersProtobuf$UseProtobufAsDefault().$end$ $if .namespaced$Namespace(c.GetNamespace()).$end$ Resource("$.type|resource$"). - Name($.type|private$Name). + Name(_$.type|private$Name). SubResource("$.subresourcePath$"). VersionedParams(&opts, $.schemeParameterCodec|raw$). Timeout(timeout). @@ -664,7 +664,7 @@ func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.type|private$Name ` var getTemplate = ` -// $.verb$ takes name of the $.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any. +// $.verb$ takes name of the _$.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any. func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) { result = &$.resultType|raw${} err = c.GetClient().Get(). @@ -680,14 +680,14 @@ func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, name string, options ` var getSubresourceTemplate = ` -// $.verb$ takes name of the $.type|private$, and returns the corresponding $.resultType|raw$ object, and an error if there is any. -func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.type|private$Name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) { +// $.verb$ takes name of the _$.type|private$, and returns the corresponding $.resultType|raw$ object, and an error if there is any. +func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, _$.type|private$Name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) { result = &$.resultType|raw${} err = c.GetClient().Get(). $if .prefersProtobuf$UseProtobufAsDefault().$end$ $if .namespaced$Namespace(c.GetNamespace()).$end$ Resource("$.type|resource$"). - Name($.type|private$Name). + Name(_$.type|private$Name). SubResource("$.subresourcePath$"). VersionedParams(&options, $.schemeParameterCodec|raw$). Do(ctx). @@ -697,7 +697,7 @@ func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.type|private$Name ` var deleteTemplate = ` -// $.verb$ takes name of the $.type|private$ and deletes it. Returns an error if one occurs. +// $.verb$ takes name of the _$.type|private$ and deletes it. Returns an error if one occurs. func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, name string, opts $.DeleteOptions|raw$) error { return c.GetClient().Delete(). $if .prefersProtobuf$UseProtobufAsDefault().$end$ @@ -711,17 +711,17 @@ func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, name string, opts $. ` var createSubresourceTemplate = ` -// $.verb$ 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. -func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) { +// $.verb$ 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. +func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, _$.type|private$Name string, _$.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) { result = &$.resultType|raw${} err = c.GetClient().Post(). $if .prefersProtobuf$UseProtobufAsDefault().$end$ $if .namespaced$Namespace(c.GetNamespace()).$end$ Resource("$.type|resource$"). - Name($.type|private$Name). + Name(_$.type|private$Name). SubResource("$.subresourcePath$"). VersionedParams(&opts, $.schemeParameterCodec|raw$). - Body($.inputType|private$). + Body(_$.inputType|private$). Do(ctx). Into(result) return @@ -729,15 +729,15 @@ func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.type|private$Name ` var createTemplate = ` -// $.verb$ 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. -func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) { +// $.verb$ 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. +func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, _$.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) { result = &$.resultType|raw${} err = c.GetClient().Post(). $if .prefersProtobuf$UseProtobufAsDefault().$end$ $if .namespaced$Namespace(c.GetNamespace()).$end$ Resource("$.type|resource$"). VersionedParams(&opts, $.schemeParameterCodec|raw$). - Body($.inputType|private$). + Body(_$.inputType|private$). Do(ctx). Into(result) return @@ -745,17 +745,17 @@ func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.inputType|private$ ` var updateSubresourceTemplate = ` -// $.verb$ takes the top resource name and 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. -func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) { +// $.verb$ takes the top resource name and 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. +func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, _$.type|private$Name string, _$.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) { result = &$.resultType|raw${} err = c.GetClient().Put(). $if .prefersProtobuf$UseProtobufAsDefault().$end$ $if .namespaced$Namespace(c.GetNamespace()).$end$ Resource("$.type|resource$"). - Name($.type|private$Name). + Name(_$.type|private$Name). SubResource("$.subresourcePath$"). VersionedParams(&opts, $.schemeParameterCodec|raw$). - Body($.inputType|private$). + Body(_$.inputType|private$). Do(ctx). Into(result) return @@ -763,16 +763,16 @@ func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.type|private$Name ` var updateTemplate = ` -// $.verb$ 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. -func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) { +// $.verb$ 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. +func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, _$.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) { result = &$.resultType|raw${} err = c.GetClient().Put(). $if .prefersProtobuf$UseProtobufAsDefault().$end$ $if .namespaced$Namespace(c.GetNamespace()).$end$ Resource("$.type|resource$"). - Name($.inputType|private$.Name). + Name(_$.inputType|private$.Name). VersionedParams(&opts, $.schemeParameterCodec|raw$). - Body($.inputType|private$). + Body(_$.inputType|private$). Do(ctx). Into(result) return @@ -836,16 +836,16 @@ func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, name string, pt $.Pa var applyTemplate = ` // $.verb$ takes the given apply declarative configuration, applies it and returns the applied $.resultType|private$. -func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) { - if $.inputType|private$ == nil { - return nil, $.fmtErrorf|raw$("$.inputType|private$ provided to $.verb$ must not be nil") +func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, _$.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) { + if _$.inputType|private$ == nil { + return nil, $.fmtErrorf|raw$("_$.inputType|private$ provided to $.verb$ must not be nil") } patchOpts := opts.ToPatchOptions() - name := $.inputType|private$.Name + name := _$.inputType|private$.Name if name == nil { - return nil, $.fmtErrorf|raw$("$.inputType|private$.Name must be provided to $.verb$") + return nil, $.fmtErrorf|raw$("_$.inputType|private$.Name must be provided to $.verb$") } - request, err := $.applyNewRequest|raw$(c.GetClient(), $.inputType|private$) + request, err := $.applyNewRequest|raw$(c.GetClient(), _$.inputType|private$) if err != nil { return nil, err } @@ -865,12 +865,12 @@ func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.inputType|private$ var applySubresourceTemplate = ` // $.verb$ takes top resource name and the apply declarative configuration for $.subresourcePath$, // applies it and returns the applied $.resultType|private$, and an error, if there is any. -func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.type|private$Name string, $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) { - if $.inputType|private$ == nil { - return nil, $.fmtErrorf|raw$("$.inputType|private$ provided to $.verb$ must not be nil") +func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, _$.type|private$Name string, _$.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) { + if _$.inputType|private$ == nil { + return nil, $.fmtErrorf|raw$("_$.inputType|private$ provided to $.verb$ must not be nil") } patchOpts := opts.ToPatchOptions() - request, err := $.applyNewRequest|raw$(c.GetClient(), $.inputType|private$) + request, err := $.applyNewRequest|raw$(c.GetClient(), _$.inputType|private$) if err != nil { return nil, err } @@ -880,7 +880,7 @@ func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.type|private$Name $if .prefersProtobuf$UseProtobufAsDefault().$end$ $if .namespaced$Namespace(c.GetNamespace()).$end$ Resource("$.type|resource$"). - Name($.type|private$Name). + Name(_$.type|private$Name). SubResource("$.subresourcePath$"). VersionedParams(&patchOpts, $.schemeParameterCodec|raw$). Do(ctx). diff --git a/fission-script.sh b/fission-script.sh new file mode 100755 index 00000000..167ac5bb --- /dev/null +++ b/fission-script.sh @@ -0,0 +1,33 @@ +#!/bin/bash +function checkCommand() { + if ! command -v $1; then + echo "$1 command missing." + exit 1 + fi +} + +function strReplace() { + ORIG=$1 + REPL=$2 + for f in $(grep -rH $ORIG . | cut -d':' -f1 | grep '\.go$' | grep 'client-gen' | sort | uniq); do + echo $f + sed -i.bak "s/"$ORIG"/"$REPL"/g" $f + done +} + +function cleanBkpFile() { + find . -name '*.bak' -exec rm {} \; +} + +function checks() { + checkCommand command + checkCommand sed + checkCommand grep + checkCommand cut + checkCommand sort + checkCommand uniq +} + +strReplace '\$\.type\|private\$' '\_\$\.type\|private\$' +strReplace '\$\.inputType\|private\$' '\_\$\.inputType\|private\$' +cleanBkpFile