Skip to content

Commit 3bda272

Browse files
committed
fix: small issues
1 parent 5824068 commit 3bda272

14 files changed

+1197
-1051
lines changed

.github/.copilot-instructions.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,19 @@ This pattern ensures:
131131
- Implement proper authentication token refresh
132132
- Follow meshStack API conventions for CRUD operations
133133

134+
### Data Structure Guidelines
135+
**Pointer and `omitempty` Usage:**
136+
- Only use pointers (`*type`) and `omitempty` JSON tags for fields that are **actually nullable** in the backend API
137+
- Non-nullable fields should use value types (e.g., `string`, `int64`, `bool`) without `omitempty`
138+
- This ensures proper validation and prevents sending incorrect null values to the API
139+
- Example:
140+
```go
141+
type Resource struct {
142+
RequiredField string `json:"requiredField" tfsdk:"required_field"` // Non-nullable
143+
OptionalField *string `json:"optionalField,omitempty" tfsdk:"optional_field"` // Nullable in backend
144+
}
145+
```
146+
134147
## Key Dependencies
135148

136149
- **Terraform Plugin Framework**: Latest stable version for provider development

client/platform_config_aws.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
package client
22

33
type AwsPlatformConfig struct {
4-
Region *string `json:"region,omitempty" tfsdk:"region"`
4+
Region string `json:"region,omitempty" tfsdk:"region"`
55
Replication *AwsReplicationConfig `json:"replication,omitempty" tfsdk:"replication"`
66
Metering *AwsMeteringConfig `json:"metering,omitempty" tfsdk:"metering"`
77
}
88

99
type AwsReplicationConfig struct {
10-
AccessConfig *AwsAccessConfig `json:"accessConfig,omitempty" tfsdk:"access_config"`
11-
WaitForExternalAvm *bool `json:"waitForExternalAvm,omitempty" tfsdk:"wait_for_external_avm"`
12-
AutomationAccountRole *string `json:"automationAccountRole,omitempty" tfsdk:"automation_account_role"`
10+
AccessConfig AwsAccessConfig `json:"accessConfig" tfsdk:"access_config"`
11+
WaitForExternalAvm bool `json:"waitForExternalAvm" tfsdk:"wait_for_external_avm"`
12+
AutomationAccountRole string `json:"automationAccountRole" tfsdk:"automation_account_role"`
1313
AutomationAccountExternalId *string `json:"automationAccountExternalId,omitempty" tfsdk:"automation_account_external_id"`
14-
AccountAccessRole *string `json:"accountAccessRole,omitempty" tfsdk:"account_access_role"`
15-
AccountAliasPattern *string `json:"accountAliasPattern,omitempty" tfsdk:"account_alias_pattern"`
16-
EnforceAccountAlias *bool `json:"enforceAccountAlias,omitempty" tfsdk:"enforce_account_alias"`
17-
AccountEmailPattern *string `json:"accountEmailPattern,omitempty" tfsdk:"account_email_pattern"`
14+
AccountAccessRole string `json:"accountAccessRole" tfsdk:"account_access_role"`
15+
AccountAliasPattern string `json:"accountAliasPattern" tfsdk:"account_alias_pattern"`
16+
EnforceAccountAlias bool `json:"enforceAccountAlias" tfsdk:"enforce_account_alias"`
17+
AccountEmailPattern string `json:"accountEmailPattern" tfsdk:"account_email_pattern"`
1818
TenantTags *MeshTenantTags `json:"tenantTags,omitempty" tfsdk:"tenant_tags"`
1919
AwsSso *AwsSsoConfig `json:"awsSso,omitempty" tfsdk:"aws_sso"`
2020
EnrollmentConfiguration *AwsEnrollmentConfiguration `json:"enrollmentConfiguration,omitempty" tfsdk:"enrollment_configuration"`
21-
SelfDowngradeAccessRole *bool `json:"selfDowngradeAccessRole,omitempty" tfsdk:"self_downgrade_access_role"`
22-
SkipUserGroupPermissionCleanup *bool `json:"skipUserGroupPermissionCleanup,omitempty" tfsdk:"skip_user_group_permission_cleanup"`
23-
AllowHierarchicalOrganizationalUnitAssignment *bool `json:"allowHierarchicalOrganizationalUnitAssignment,omitempty" tfsdk:"allow_hierarchical_organizational_unit_assignment"`
21+
SelfDowngradeAccessRole bool `json:"selfDowngradeAccessRole" tfsdk:"self_downgrade_access_role"`
22+
SkipUserGroupPermissionCleanup bool `json:"skipUserGroupPermissionCleanup" tfsdk:"skip_user_group_permission_cleanup"`
23+
AllowHierarchicalOrganizationalUnitAssignment bool `json:"allowHierarchicalOrganizationalUnitAssignment" tfsdk:"allow_hierarchical_organizational_unit_assignment"`
2424
}
2525

2626
type AwsAccessConfig struct {
@@ -31,8 +31,8 @@ type AwsAccessConfig struct {
3131
}
3232

3333
type AwsServiceUserConfig struct {
34-
AccessKey string `json:"accessKey" tfsdk:"access_key"`
35-
SecretKey *string `json:"secretKey,omitempty" tfsdk:"secret_key"`
34+
AccessKey string `json:"accessKey" tfsdk:"access_key"`
35+
SecretKey string `json:"secretKey" tfsdk:"secret_key"`
3636
}
3737

3838
type AwsWorkloadIdentityConfig struct {
@@ -43,9 +43,9 @@ type AwsSsoConfig struct {
4343
ScimEndpoint string `json:"scimEndpoint" tfsdk:"scim_endpoint"`
4444
Arn string `json:"arn" tfsdk:"arn"`
4545
GroupNamePattern string `json:"groupNamePattern" tfsdk:"group_name_pattern"`
46-
SsoAccessToken *string `json:"ssoAccessToken,omitempty" tfsdk:"sso_access_token"`
46+
SsoAccessToken string `json:"ssoAccessToken" tfsdk:"sso_access_token"`
4747
AwsRoleMappings []AwsSsoRoleMapping `json:"awsRoleMappings" tfsdk:"aws_role_mappings"`
48-
SignInUrl *string `json:"signInUrl,omitempty" tfsdk:"sign_in_url"`
48+
SignInUrl string `json:"signInUrl" tfsdk:"sign_in_url"`
4949
}
5050

5151
type AwsSsoRoleMapping struct {

client/platform_config_kubernetes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ type KubernetesPlatformConfig struct {
99

1010
type KubernetesReplicationConfig struct {
1111
ClientConfig KubernetesClientConfig `json:"clientConfig" tfsdk:"client_config"`
12-
NamespaceNamePattern string `json:"namespaceNamePattern,omitempty" tfsdk:"namespace_name_pattern"`
12+
NamespaceNamePattern string `json:"namespaceNamePattern" tfsdk:"namespace_name_pattern"`
1313
}
1414

1515
type KubernetesClientConfig struct {

client/platform_config_openshift.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,20 @@ type OpenShiftPlatformConfig struct {
88
}
99

1010
type OpenShiftReplicationConfig struct {
11-
ClientConfig *OpenShiftClientConfig `json:"clientConfig,omitempty" tfsdk:"client_config"`
11+
ClientConfig KubernetesClientConfig `json:"clientConfig" tfsdk:"client_config"`
1212
WebConsoleUrl *string `json:"webConsoleUrl,omitempty" tfsdk:"web_console_url"`
13-
ProjectNamePattern *string `json:"projectNamePattern,omitempty" tfsdk:"project_name_pattern"`
14-
EnableTemplateInstantiation *bool `json:"enableTemplateInstantiation,omitempty" tfsdk:"enable_template_instantiation"`
15-
OpenShiftRoleMappings []OpenShiftPlatformRoleMapping `json:"openshiftRoleMappings,omitempty" tfsdk:"openshift_role_mappings"`
16-
IdentityProviderName *string `json:"identityProviderName,omitempty" tfsdk:"identity_provider_name"`
13+
ProjectNamePattern string `json:"projectNamePattern" tfsdk:"project_name_pattern"`
14+
EnableTemplateInstantiation bool `json:"enableTemplateInstantiation" tfsdk:"enable_template_instantiation"`
15+
OpenShiftRoleMappings []OpenShiftPlatformRoleMapping `json:"openshiftRoleMappings" tfsdk:"openshift_role_mappings"`
16+
IdentityProviderName string `json:"identityProviderName" tfsdk:"identity_provider_name"`
1717
TenantTags *MeshTenantTags `json:"tenantTags,omitempty" tfsdk:"tenant_tags"`
1818
}
1919

20-
type OpenShiftClientConfig struct {
21-
AccessToken *string `json:"accessToken,omitempty" tfsdk:"access_token"`
22-
}
23-
2420
type OpenShiftMeteringConfig struct {
25-
ClientConfig *OpenShiftClientConfig `json:"clientConfig,omitempty" tfsdk:"client_config"`
26-
Processing *MeshPlatformMeteringProcessingConfig `json:"processing,omitempty" tfsdk:"processing"`
21+
ClientConfig KubernetesClientConfig `json:"clientConfig" tfsdk:"client_config"`
22+
Processing MeshPlatformMeteringProcessingConfig `json:"processing" tfsdk:"processing"`
2723
}
2824

29-
3025
type OpenShiftPlatformRoleMapping struct {
3126
MeshProjectRoleRef MeshProjectRoleRefV2 `json:"projectRoleRef" tfsdk:"project_role_ref"`
3227
OpenShiftRole string `json:"openshiftRole" tfsdk:"openshift_role"`

internal/modifiers/platformtypemodifier/validate_single_platform.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ func (v singlePlatformValidator) PlanModifyObject(ctx context.Context, req planm
4444
if len(configuredPlatforms) > 1 {
4545
resp.Diagnostics.AddError(
4646
"Multiple Platform Configurations",
47-
fmt.Sprintf("Only one platform configuration can be specified within "+
48-
"platform_properties, but found: %v. Please specify only one platform "+
47+
fmt.Sprintf("Only one platform configuration can be specified,"+
48+
"but found: %v. Please specify only one platform "+
4949
"configuration.", configuredPlatforms),
5050
)
5151
}
5252

5353
if len(configuredPlatforms) == 0 {
5454
resp.Diagnostics.AddError(
5555
"No Platform Configuration",
56-
"At least one platform configuration must be specified within platform_properties. "+
56+
"At least one platform configuration must be specified. "+
5757
"Please specify one of: aws, aks, azure, azurerg, gcp, kubernetes, openshift.",
5858
)
5959
}

internal/provider/landingzone_resource.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func awsPlatformConfigSchema() schema.Attribute {
225225
Required: true,
226226
NestedObject: schema.NestedAttributeObject{
227227
Attributes: map[string]schema.Attribute{
228-
"project_role_ref": meshProjectRoleAttribute(),
228+
"project_role_ref": meshProjectRoleAttribute(false),
229229
"platform_role": schema.StringAttribute{
230230
MarkdownDescription: "The AWS platform role",
231231
Required: true,
@@ -254,7 +254,7 @@ func aksPlatformConfigSchema() schema.Attribute {
254254
Required: true,
255255
NestedObject: schema.NestedAttributeObject{
256256
Attributes: map[string]schema.Attribute{
257-
"project_role_ref": meshProjectRoleAttribute(),
257+
"project_role_ref": meshProjectRoleAttribute(false),
258258
"platform_roles": schema.ListAttribute{
259259
MarkdownDescription: "List of AKS platform roles to assign to the meshProject role.",
260260
ElementType: types.StringType,
@@ -284,7 +284,7 @@ func azurePlatformConfigSchema() schema.Attribute {
284284
Required: true,
285285
NestedObject: schema.NestedAttributeObject{
286286
Attributes: map[string]schema.Attribute{
287-
"project_role_ref": meshProjectRoleAttribute(),
287+
"project_role_ref": meshProjectRoleAttribute(false),
288288
"azure_group_suffix": schema.StringAttribute{
289289
MarkdownDescription: "The given role name will be injected into the" +
290290
" group name via the group naming pattern configured on the" +
@@ -336,7 +336,7 @@ func gcpPlatformConfigSchema() schema.Attribute {
336336
Required: true,
337337
NestedObject: schema.NestedAttributeObject{
338338
Attributes: map[string]schema.Attribute{
339-
"project_role_ref": meshProjectRoleAttribute(),
339+
"project_role_ref": meshProjectRoleAttribute(false),
340340
"platform_roles": schema.ListAttribute{
341341
MarkdownDescription: "Can be empty. List of GCP IAM roles to assign to the meshProject role.",
342342
ElementType: types.StringType,
@@ -367,7 +367,7 @@ func azureRgPlatformConfigSchema() schema.Attribute {
367367
Required: true,
368368
NestedObject: schema.NestedAttributeObject{
369369
Attributes: map[string]schema.Attribute{
370-
"project_role_ref": meshProjectRoleAttribute(),
370+
"project_role_ref": meshProjectRoleAttribute(false),
371371
"azure_group_suffix": schema.StringAttribute{
372372
MarkdownDescription: "The given role name will be injected into the" +
373373
" group name via the group naming pattern configured on the" +
@@ -410,7 +410,7 @@ func kubernetesPlatformConfigSchema() schema.Attribute {
410410
Required: true,
411411
NestedObject: schema.NestedAttributeObject{
412412
Attributes: map[string]schema.Attribute{
413-
"project_role_ref": meshProjectRoleAttribute(),
413+
"project_role_ref": meshProjectRoleAttribute(false),
414414
"platform_roles": schema.ListAttribute{
415415
MarkdownDescription: "Roles need to be mapped from the meshRole to" +
416416
" the Cluster Role. You can use both built in roles like 'editor' or custom roles that you setup in the Kubernetes Cluster" +

internal/provider/platform_data_source.go

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func (d *platformDataSource) Schema(_ context.Context, _ datasource.SchemaReques
167167
},
168168
"quota_definitions": schema.ListAttribute{
169169
MarkdownDescription: "List of quota definitions for the platform.",
170-
Required: true,
170+
Computed: true,
171171
Sensitive: false,
172172
ElementType: types.ObjectType{
173173
AttrTypes: map[string]attr.Type{
@@ -679,15 +679,15 @@ func awsReplicationConfigDataSourceSchema() schema.Attribute {
679679
Computed: true,
680680
NestedObject: schema.NestedAttributeObject{
681681
Attributes: map[string]schema.Attribute{
682-
"project_role_ref": meshProjectRoleAttribute(),
682+
"project_role_ref": meshProjectRoleAttribute(true),
683683
"aws_role": schema.StringAttribute{
684684
MarkdownDescription: "The AWS role name",
685685
Computed: true,
686686
},
687687
"permission_set_arns": schema.ListAttribute{
688688
MarkdownDescription: "List of permission set ARNs associated with this role mapping",
689689
ElementType: types.StringType,
690-
Optional: true,
690+
Computed: true,
691691
},
692692
},
693693
},
@@ -843,8 +843,7 @@ func azureReplicationConfigDataSourceSchema() schema.Attribute {
843843
Computed: true,
844844
Attributes: map[string]schema.Attribute{
845845
"redirect_url": schema.StringAttribute{
846-
MarkdownDescription: "This is the URL that Azure's consent experience redirects users to after they accept their invitation.",
847-
Computed: true,
846+
Computed: true,
848847
},
849848
"send_azure_invitation_mail": schema.BoolAttribute{
850849
MarkdownDescription: "When true, meshStack instructs Azure to send out Invitation mails to invited users. These mails allow users to redeem their invitation to the AAD tenant only using email and Azure Portal.",
@@ -873,7 +872,7 @@ func azureReplicationConfigDataSourceSchema() schema.Attribute {
873872
Computed: true,
874873
NestedObject: schema.NestedAttributeObject{
875874
Attributes: map[string]schema.Attribute{
876-
"project_role_ref": meshProjectRoleAttribute(),
875+
"project_role_ref": meshProjectRoleAttribute(true),
877876
"azure_role": schema.SingleNestedAttribute{
878877
MarkdownDescription: "The Azure role definition.",
879878
Computed: true,
@@ -937,8 +936,6 @@ func azureReplicationConfigDataSourceSchema() schema.Attribute {
937936
}
938937
}
939938

940-
// TODO continue here.
941-
942939
func azureRgReplicationConfigDataSourceSchema() schema.Attribute {
943940
return schema.SingleNestedAttribute{
944941
MarkdownDescription: "Azure Resource Group-specific replication configuration for the platform.",
@@ -1111,7 +1108,7 @@ func gcpReplicationConfigDataSourceSchema() schema.Attribute {
11111108
Computed: true,
11121109
NestedObject: schema.NestedAttributeObject{
11131110
Attributes: map[string]schema.Attribute{
1114-
"project_role_ref": meshProjectRoleAttribute(),
1111+
"project_role_ref": meshProjectRoleAttribute(true),
11151112
"gcp_role": schema.StringAttribute{
11161113
MarkdownDescription: "The GCP IAM role",
11171114
Computed: true,
@@ -1208,13 +1205,10 @@ func kubernetesMeteringConfigDataSourceSchema() schema.Attribute {
12081205
Computed: true,
12091206
Attributes: map[string]schema.Attribute{
12101207
"client_config": kubernetesClientConfigDataSourceSchema("Client configuration for Kubernetes metering"),
1211-
"processing": meteringProcessingConfigDataSourceSchema(),
12121208
},
12131209
}
12141210
}
12151211

1216-
// TODO continue here.
1217-
12181212
func openShiftReplicationConfigDataSourceSchema() schema.Attribute {
12191213
return schema.SingleNestedAttribute{
12201214
MarkdownDescription: "Replication configuration for OpenShift (optional, but required for replication)",
@@ -1238,7 +1232,7 @@ func openShiftReplicationConfigDataSourceSchema() schema.Attribute {
12381232
Computed: true,
12391233
NestedObject: schema.NestedAttributeObject{
12401234
Attributes: map[string]schema.Attribute{
1241-
"project_role_ref": meshProjectRoleAttribute(),
1235+
"project_role_ref": meshProjectRoleAttribute(true),
12421236
"openshift_role": schema.StringAttribute{
12431237
MarkdownDescription: "The OpenShift role name",
12441238
Computed: true,

0 commit comments

Comments
 (0)