diff --git a/gen/templates/resource.go.tmpl b/gen/templates/resource.go.tmpl index cb206fd96..e6311cba9 100644 --- a/gen/templates/resource.go.tmpl +++ b/gen/templates/resource.go.tmpl @@ -2,67 +2,6 @@ // In order to regenerate this file execute `go generate` from the repository root. // More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). -{{- define "child_attributes" }} - "{{- .ResourceName}}": schema.SetNestedAttribute{ - MarkdownDescription: `{{.Comment}}`, - Optional: true, - Computed: true, - PlanModifiers: []planmodifier.Set{ - setplanmodifier.UseStateForUnknown(), - }, - {{- if not .IdentifiedBy}} - Validators: []validator.Set{ - setvalidator.SizeAtMost(1), - }, - {{- end}} - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - {{- range .Properties}} - {{- if eq .ValueType "bitmask"}} - "{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}": schema.SetAttribute{ - MarkdownDescription: `{{.Comment}}`, - Optional: true, - Computed: true, - PlanModifiers: []planmodifier.Set{ - setplanmodifier.UseStateForUnknown(), - }, - {{- if .ValidValues}} - Validators: []validator.Set{ - setvalidator.SizeAtMost({{ len .ValidValues }}), - setvalidator.ValueStringsAre( - stringvalidator.OneOf({{- validatorString .ValidValues}}), - ), - }, - {{- end}} - ElementType: types.StringType, - }, - {{- else}} - "{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}": schema.StringAttribute{ - {{- if or .IsNaming .IsRequired}} - Required: true, - {{- else }} - Optional: true, - Computed: true, - {{- end}} - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, - {{- if .ValidValues}} - Validators: []validator.String{ - stringvalidator.OneOf({{- validatorString .ValidValues}}), - }, - {{- end}} - MarkdownDescription: `{{.Comment}}`, - }, - {{- end}} - {{- end}} - {{- range .Children}} - {{- template "child_attributes" . }} - }, - }, - }, - {{- end}} - {{- end}} package provider @@ -249,13 +188,12 @@ func (r *{{.ResourceClassName}}Resource) Schema(ctx context.Context, req resourc {{- end}} {{- range .Children}} {{- template "child_attributes" . }} - - }, - }, }, + }, + }, {{- end}} - }, + }, } tflog.Debug(ctx, "End schema of resource: aci_{{.ResourceName}}") } @@ -773,3 +711,67 @@ func get{{.ResourceClassName}}CreateJsonPayload(ctx context.Context, diags *diag } return jsonPayload } + +{{- define "child_attributes" }} + "{{ .ResourceName }}": schema.SetNestedAttribute{ + MarkdownDescription: `{{ .Comment }}`, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + {{- if not .IdentifiedBy }} + Validators: []validator.Set{ + setvalidator.SizeAtMost(1), + }, + {{- end }} + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + {{- range .Properties }} + {{- if eq .ValueType "bitmask" }} + "{{ overwriteProperty .PkgName .SnakeCaseName $.Definitions }}": schema.SetAttribute{ + MarkdownDescription: `{{ .Comment }}`, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + {{- if .ValidValues }} + Validators: []validator.Set{ + setvalidator.SizeAtMost({{ len .ValidValues }}), + setvalidator.ValueStringsAre( + stringvalidator.OneOf({{ validatorString .ValidValues }}), + ), + }, + {{- end }} + ElementType: types.StringType, + }, + {{- else }} + "{{ overwriteProperty .PkgName .SnakeCaseName $.Definitions }}": schema.StringAttribute{ + {{- if or .IsNaming .IsRequired }} + Required: true, + {{- else }} + Optional: true, + Computed: true, + {{- end }} + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + {{- if .ValidValues }} + Validators: []validator.String{ + stringvalidator.OneOf({{ validatorString .ValidValues }}), + }, + {{- end }} + MarkdownDescription: `{{ .Comment }}`, + }, + {{- end }} + {{- end }} + }, + {{- range .Children }} + "{{ .ResourceName }}": { + {{- template "child_attributes" . }} + }, + {{- end }} + }, + }, +{{- end }} \ No newline at end of file diff --git a/internal/provider/resource_aci_external_management_network_instance_profile.go b/internal/provider/resource_aci_external_management_network_instance_profile.go index 86a762cb4..83a9abb73 100644 --- a/internal/provider/resource_aci_external_management_network_instance_profile.go +++ b/internal/provider/resource_aci_external_management_network_instance_profile.go @@ -439,6 +439,21 @@ func getAndSetMgmtInstPAttributes(ctx context.Context, diags *diag.Diagnostics, data.Prio = basetypes.NewStringValue(attributeValue.(string)) } } + if data.Annotation.IsUnknown() { + data.Annotation = types.StringNull() + } + if data.Descr.IsUnknown() { + data.Descr = types.StringNull() + } + if data.Name.IsUnknown() { + data.Name = types.StringNull() + } + if data.NameAlias.IsUnknown() { + data.NameAlias = types.StringNull() + } + if data.Prio.IsUnknown() { + data.Prio = types.StringNull() + } MgmtRsOoBConsMgmtInstPList := make([]MgmtRsOoBConsMgmtInstPResourceModel, 0) TagAnnotationMgmtInstPList := make([]TagAnnotationMgmtInstPResourceModel, 0) TagTagMgmtInstPList := make([]TagTagMgmtInstPResourceModel, 0) @@ -650,7 +665,6 @@ func getMgmtInstPTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostic return childPayloads } - func getMgmtInstPCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *MgmtInstPResourceModel, mgmtRsOoBConsPlan, mgmtRsOoBConsState []MgmtRsOoBConsMgmtInstPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationMgmtInstPResourceModel, tagTagPlan, tagTagState []TagTagMgmtInstPResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{}