From 5b8985db5a50990f6a04adf9b239c88e21bf68cb Mon Sep 17 00:00:00 2001 From: Gaspard Micol Date: Fri, 3 May 2024 16:30:04 -0400 Subject: [PATCH] [ignore] Change name of template function from SetDefault to GetDefaultValues in generator and templates. --- gen/generator.go | 2 +- gen/templates/datasource.go.tmpl | 8 ++++---- gen/templates/datasource.md.tmpl | 4 ++-- gen/templates/resource.go.tmpl | 4 ++-- gen/templates/resource.md.tmpl | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gen/generator.go b/gen/generator.go index f7a1ba0ea..bd9db2930 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -91,7 +91,7 @@ var templateFuncs = template.FuncMap{ "createNonExistingValue": func(val string) string { return fmt.Sprintf("non_existing_%s", val) }, "getParentTestDependencies": GetParentTestDependencies, "getTargetTestDependencies": GetTargetTestDependencies, - "setDefault": GetDefaultValues, + "GetDefaultValues": GetDefaultValues, "fromInterfacesToString": FromInterfacesToString, "containsNoneAttributeValue": ContainsNoneAttributeValue, "definedInMap": DefinedInMap, diff --git a/gen/templates/datasource.go.tmpl b/gen/templates/datasource.go.tmpl index 0ad573d79..5e1c2d694 100644 --- a/gen/templates/datasource.go.tmpl +++ b/gen/templates/datasource.go.tmpl @@ -15,7 +15,7 @@ import ( {{- if or .HasBitmask }} "github.com/hashicorp/terraform-plugin-framework/types" {{- end}} - {{- if setDefault .PkgName "parent_dn" $.Definitions}} + {{- if GetDefaultValues .PkgName "parent_dn" $.Definitions}} "github.com/hashicorp/terraform-plugin-framework/types/basetypes" {{- end}} "github.com/hashicorp/terraform-plugin-log/tflog" @@ -52,7 +52,7 @@ func (d *{{.ResourceClassName}}DataSource) Schema(ctx context.Context, req datas }, {{- if .HasParent}} "parent_dn": schema.StringAttribute{ - {{- if setDefault .PkgName "parent_dn" $.Definitions}} + {{- if GetDefaultValues .PkgName "parent_dn" $.Definitions}} Optional: true, {{- else}} Required: true, @@ -145,9 +145,9 @@ func (d *{{.ResourceClassName}}DataSource) Read(ctx context.Context, req datasou getAndSet{{.ResourceClassName}}Attributes(ctx, &resp.Diagnostics, d.client, data) - {{ if setDefault .PkgName "parent_dn" $.Definitions}} + {{ if GetDefaultValues .PkgName "parent_dn" $.Definitions}} if data.ParentDn.IsNull() || data.ParentDn.IsUnknown(){ - data.ParentDn = basetypes.NewStringValue("{{setDefault .PkgName "parent_dn" $.Definitions}}") + data.ParentDn = basetypes.NewStringValue("{{GetDefaultValues .PkgName "parent_dn" $.Definitions}}") } {{- end}} diff --git a/gen/templates/datasource.md.tmpl b/gen/templates/datasource.md.tmpl index 690c9c946..c77544cd5 100644 --- a/gen/templates/datasource.md.tmpl +++ b/gen/templates/datasource.md.tmpl @@ -53,8 +53,8 @@ Data source for {{.ResourceNameAsDescription}} {{- range .DocumentationParentDns}} - {{ . }} {{- end}} - {{- if setDefault .PkgName "parent_dn" $.Definitions}} - - Default: `{{ setDefault .PkgName "parent_dn" $.Definitions}}` + {{- if GetDefaultValues .PkgName "parent_dn" $.Definitions}} + - Default: `{{ GetDefaultValues .PkgName "parent_dn" $.Definitions}}` {{ end}} {{- end}} {{- range .Properties}} diff --git a/gen/templates/resource.go.tmpl b/gen/templates/resource.go.tmpl index 50369b684..c7e06828e 100644 --- a/gen/templates/resource.go.tmpl +++ b/gen/templates/resource.go.tmpl @@ -121,10 +121,10 @@ func (r *{{.ResourceClassName}}Resource) Schema(ctx context.Context, req resourc }, {{- if .HasParent}} "parent_dn": schema.StringAttribute{ - {{- if setDefault .PkgName "parent_dn" $.Definitions}} + {{- if GetDefaultValues .PkgName "parent_dn" $.Definitions}} Optional: true, Computed: true, - Default: stringdefault.StaticString("{{setDefault .PkgName "parent_dn" $.Definitions}}"), + Default: stringdefault.StaticString("{{GetDefaultValues .PkgName "parent_dn" $.Definitions}}"), {{- else}} Required: true, {{- end}} diff --git a/gen/templates/resource.md.tmpl b/gen/templates/resource.md.tmpl index 89b8a5398..444e7fbf1 100644 --- a/gen/templates/resource.md.tmpl +++ b/gen/templates/resource.md.tmpl @@ -68,7 +68,7 @@ All examples for the {{.ResourceNameAsDescription}} resource can be found in the ## Schema ## ### Required ### -{{ if and .HasParent (not (setDefault .PkgName "parent_dn" $.Definitions))}} +{{ if and .HasParent (not (GetDefaultValues .PkgName "parent_dn" $.Definitions))}} * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: {{- range .DocumentationParentDns}} - {{ . }} @@ -89,12 +89,12 @@ All examples for the {{.ResourceNameAsDescription}} resource can be found in the {{- if .HasOptionalProperties}} ### Optional ### -{{- if and .HasParent (setDefault .PkgName "parent_dn" $.Definitions)}} +{{- if and .HasParent (GetDefaultValues .PkgName "parent_dn" $.Definitions)}} * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: {{- range .DocumentationParentDns}} - {{ . }} {{- end}} - - Default: `{{ setDefault .PkgName "parent_dn" $.Definitions}}` + - Default: `{{ GetDefaultValues .PkgName "parent_dn" $.Definitions}}` {{- end}} {{ range .Properties}} {{- if and (not .IsNaming) (not .IsRequired)}}