Only create WithAutomaticVersioning if versioning is used (#3210)
This option did not respect whether or not versioning was enabled when writing it out during generation. This does mean that there is a breaking change for auth tokens, but as it was a no-op anyways it's easy to fix and not something I want to /v2 about.
This commit is contained in:
1 parent
603c3c8c9c
commit
869310d7da
4 files changed
+20
-19
No files matched your search
@@ -756,6 +756,15 @@ var inputStructs = []*structInfo{
|
||||
createResponseTypes: []string{CreateResponseType, ReadResponseType, UpdateResponseType, DeleteResponseType, ListResponseType},
|
||||
recursiveListing: true,
|
||||
},
|
||||
{
|
||||
inProto: &hosts.StaticHostAttributes{},
|
||||
outFile: "hosts/static_host_attributes.gen.go",
|
||||
subtypeName: "StaticHost",
|
||||
parentTypeName: "Host",
|
||||
templates: []*template.Template{
|
||||
mapstructureConversionTemplate,
|
||||
},
|
||||
},
|
||||
{
|
||||
inProto: &hosts.Host{},
|
||||
outFile: "hosts/host.gen.go",
|
||||
@@ -772,15 +781,6 @@ var inputStructs = []*structInfo{
|
||||
versionEnabled: true,
|
||||
createResponseTypes: []string{CreateResponseType, ReadResponseType, UpdateResponseType, DeleteResponseType, ListResponseType},
|
||||
},
|
||||
{
|
||||
inProto: &hosts.StaticHostAttributes{},
|
||||
outFile: "hosts/static_host_attributes.gen.go",
|
||||
subtypeName: "StaticHost",
|
||||
parentTypeName: "Host",
|
||||
templates: []*template.Template{
|
||||
mapstructureConversionTemplate,
|
||||
},
|
||||
},
|
||||
{
|
||||
inProto: &hostsets.HostSet{},
|
||||
outFile: "hostsets/host_set.gen.go",
|
||||
@@ -964,6 +964,7 @@ var inputStructs = []*structInfo{
|
||||
pluralResourceName: "sessions",
|
||||
createResponseTypes: []string{CreateResponseType, ReadResponseType, UpdateResponseType, DeleteResponseType, ListResponseType},
|
||||
fieldFilter: []string{"private_key"},
|
||||
versionEnabled: true,
|
||||
recursiveListing: true,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -194,6 +194,7 @@ func fillTemplates() {
|
||||
Package: pkg,
|
||||
Fields: fields,
|
||||
RecursiveListing: inputMap[pkg].recursiveListing,
|
||||
VersionEnabled: inputMap[pkg].versionEnabled,
|
||||
}
|
||||
|
||||
if err := optionTemplate.Execute(outBuf, input); err != nil {
|
||||
@@ -683,6 +684,9 @@ var optionTemplate = template.Must(template.New("").Funcs(
|
||||
"removeDups": removeDups,
|
||||
},
|
||||
).Parse(`
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package {{ .Package }}
|
||||
|
||||
import (
|
||||
@@ -736,6 +740,7 @@ func getOpts(opt ...Option) (options, []api.Option) {
|
||||
return opts, apiOpts
|
||||
}
|
||||
|
||||
{{ if .VersionEnabled }}
|
||||
// If set, and if the version is zero during an update, the API will perform a
|
||||
// fetch to get the current version of the resource and populate it during the
|
||||
// update call. This is convenient but opens up the possibility for subtle
|
||||
@@ -745,6 +750,7 @@ func WithAutomaticVersioning(enable bool) Option {
|
||||
o.withAutomaticVersioning = enable
|
||||
}
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
// WithSkipCurlOutput tells the API to not use the current call for cURL output.
|
||||
// Useful for when we need to look up versions.
|
||||
|
||||
Reference in new issue
Block a user