Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
maciaszczykm committed Dec 4, 2023
2 parents 6266d12 + f3a385d commit 7368939
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 54 deletions.
29 changes: 0 additions & 29 deletions internal/resource/service_deployment_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ type ServiceDeploymentPolicyBinding struct {
}

type ServiceDeploymentSyncConfig struct {
DiffNormalizer *ServiceDeploymentDiffNormalizer `tfsdk:"diff_normalizer"`
NamespaceMetadata *ServiceDeploymentNamespaceMetadata `tfsdk:"namespace_metadata"`
}

Expand All @@ -248,38 +247,10 @@ func (this *ServiceDeploymentSyncConfig) Attributes() *gqlclient.SyncConfigAttri
}

return &gqlclient.SyncConfigAttributes{
DiffNormalizer: this.DiffNormalizer.Attributes(),
NamespaceMetadata: this.NamespaceMetadata.Attributes(),
}
}

type ServiceDeploymentDiffNormalizer struct {
Group types.String `tfsdk:"group"`
JsonPatches types.Set `tfsdk:"json_patches"`
Kind types.String `tfsdk:"kind"`
Name types.String `tfsdk:"name"`
Namespace types.String `tfsdk:"namespace"`
}

func (this *ServiceDeploymentDiffNormalizer) Attributes() *gqlclient.DiffNormalizerAttributes {
if this == nil {
return nil
}

jsonPatches := make([]types.String, len(this.JsonPatches.Elements()))
this.JsonPatches.ElementsAs(context.Background(), &jsonPatches, false)

return &gqlclient.DiffNormalizerAttributes{
Group: this.Group.ValueString(),
Kind: this.Kind.ValueString(),
Name: this.Name.ValueString(),
Namespace: this.Namespace.ValueString(),
JSONPatches: algorithms.Map(jsonPatches, func(v types.String) string {
return v.ValueString()
}),
}
}

type ServiceDeploymentNamespaceMetadata struct {
Annotations types.Map `tfsdk:"annotations"`
Labels types.Map `tfsdk:"labels"`
Expand Down
29 changes: 4 additions & 25 deletions internal/resource/service_deployment_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ func (r *ServiceDeploymentResource) schemaKustomize() schema.SingleNestedAttribu
}
}

func (r *ServiceDeploymentResource) schemaConfiguration() schema.ListNestedAttribute {
return schema.ListNestedAttribute{
func (r *ServiceDeploymentResource) schemaConfiguration() schema.SetNestedAttribute {
return schema.SetNestedAttribute{
Optional: true,
Description: "List of [name, value] secrets used to alter this ServiceDeployment configuration.",
MarkdownDescription: "List of [name, value] secrets used to alter this ServiceDeployment configuration.",
Expand Down Expand Up @@ -165,7 +165,7 @@ func (r *ServiceDeploymentResource) schemaBindings() schema.SingleNestedAttribut
Description: "Read and write policies of this ServiceDeployment.",
MarkdownDescription: "Read and write policies of this ServiceDeployment.",
Attributes: map[string]schema.Attribute{
"read": schema.ListNestedAttribute{
"read": schema.SetNestedAttribute{
Optional: true,
Description: "Read policies of this ServiceDeployment.",
MarkdownDescription: "Read policies of this ServiceDeployment.",
Expand All @@ -183,7 +183,7 @@ func (r *ServiceDeploymentResource) schemaBindings() schema.SingleNestedAttribut
},
},
},
"write": schema.ListNestedAttribute{
"write": schema.SetNestedAttribute{
Optional: true,
Description: "Write policies of this ServiceDeployment.",
MarkdownDescription: "Write policies of this ServiceDeployment.",
Expand Down Expand Up @@ -214,27 +214,6 @@ func (r *ServiceDeploymentResource) schemaSyncConfig() schema.SingleNestedAttrib
Description: "Settings for advanced tuning of the sync process.",
MarkdownDescription: "Settings for advanced tuning of the sync process.",
Attributes: map[string]schema.Attribute{
"diff_normalizer": schema.SingleNestedAttribute{
Optional: true,
Attributes: map[string]schema.Attribute{
"group": schema.StringAttribute{
Optional: true,
},
"json_patches": schema.SetAttribute{
ElementType: types.StringType,
Optional: true,
},
"kind": schema.StringAttribute{
Optional: true,
},
"name": schema.StringAttribute{
Optional: true,
},
"namespace": schema.StringAttribute{
Optional: true,
},
},
},
"namespace_metadata": schema.SingleNestedAttribute{
Optional: true,
Attributes: map[string]schema.Attribute{
Expand Down

0 comments on commit 7368939

Please sign in to comment.