Skip to content

Commit 3b3f3f7

Browse files
committed
feat: add quota definitions to meshPlatforms
1 parent 5ae6892 commit 3b3f3f7

File tree

6 files changed

+81
-0
lines changed

6 files changed

+81
-0
lines changed

client/platform.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ type MeshPlatformSpec struct {
3636
ContributingWorkspaces []string `json:"contributingWorkspaces" tfsdk:"contributing_workspaces"`
3737
Availability PlatformAvailability `json:"availability" tfsdk:"availability"`
3838
Config PlatformConfig `json:"config" tfsdk:"config"`
39+
QuotaDefinitions []QuotaDefinition `json:"quotaDefinitions" tfsdk:"quota_definitions"`
40+
}
41+
42+
type QuotaDefinition struct {
43+
QuotaKey string `json:"quotaKey" tfsdk:"quota_key"`
44+
MinValue int `json:"minValue" tfsdk:"min_value"`
45+
MaxValue int `json:"maxValue" tfsdk:"max_value"`
46+
Unit string `json:"unit" tfsdk:"unit"`
47+
AutoApprovalThreshold int `json:"autoApprovalThreshold" tfsdk:"auto_approval_threshold"`
48+
Description string `json:"description" tfsdk:"description"`
49+
Label string `json:"label" tfsdk:"label"`
3950
}
4051

4152
type LocationRef struct {

docs/data-sources/platform.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ Read-Only:
5151
<a id="nestedatt--spec"></a>
5252
### Nested Schema for `spec`
5353

54+
Required:
55+
56+
- `quota_definitions` (List of Object) List of quota definitions for the platform. (see [below for nested schema](#nestedatt--spec--quota_definitions))
57+
5458
Read-Only:
5559

5660
- `availability` (Attributes) Availability configuration for the meshPlatform. (see [below for nested schema](#nestedatt--spec--availability))
@@ -63,6 +67,20 @@ Read-Only:
6367
- `location_ref` (Attributes) Reference to the location where this platform is situated. (see [below for nested schema](#nestedatt--spec--location_ref))
6468
- `support_url` (String) URL for platform support documentation.
6569

70+
<a id="nestedatt--spec--quota_definitions"></a>
71+
### Nested Schema for `spec.quota_definitions`
72+
73+
Read-Only:
74+
75+
- `auto_approval_threshold` (Number)
76+
- `description` (String)
77+
- `label` (String)
78+
- `max_value` (Number)
79+
- `min_value` (Number)
80+
- `quota_key` (String)
81+
- `unit` (String)
82+
83+
6684
<a id="nestedatt--spec--availability"></a>
6785
### Nested Schema for `spec.availability`
6886

docs/resources/platform.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ resource "meshstack_platform" "example" {
4141
restricted_to_workspaces = []
4242
}
4343
44+
quota_definitions = []
45+
4446
config = {
4547
azure = {
4648
entra_tenant = "dev-mycompany.onmicrosoft.com"
@@ -189,6 +191,7 @@ Required:
189191
- `display_name` (String) The human-readable display name of the meshPlatform.
190192
- `endpoint` (String) The web console URL endpoint of the platform.
191193
- `location_ref` (Attributes) Reference to the location where this platform is situated. (see [below for nested schema](#nestedatt--spec--location_ref))
194+
- `quota_definitions` (List of Object) List of quota definitions for the platform. (see [below for nested schema](#nestedatt--spec--quota_definitions))
192195

193196
Optional:
194197

@@ -849,6 +852,20 @@ Read-Only:
849852

850853
- `kind` (String) meshObject type, always `meshLocation`.
851854

855+
856+
<a id="nestedatt--spec--quota_definitions"></a>
857+
### Nested Schema for `spec.quota_definitions`
858+
859+
Required:
860+
861+
- `auto_approval_threshold` (Number)
862+
- `description` (String)
863+
- `label` (String)
864+
- `max_value` (Number)
865+
- `min_value` (Number)
866+
- `quota_key` (String)
867+
- `unit` (String)
868+
852869
## Import
853870

854871
Import is supported using the following syntax:

examples/resources/meshstack_platform/resource.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ resource "meshstack_platform" "example" {
2020
restricted_to_workspaces = []
2121
}
2222

23+
quota_definitions = []
24+
2325
config = {
2426
azure = {
2527
entra_tenant = "dev-mycompany.onmicrosoft.com"

internal/provider/platform_data_source.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/meshcloud/terraform-provider-meshstack/client"
88

99
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
10+
"github.com/hashicorp/terraform-plugin-framework/attr"
1011
"github.com/hashicorp/terraform-plugin-framework/datasource"
1112
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
1213
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -164,6 +165,22 @@ func (d *platformDataSource) Schema(_ context.Context, _ datasource.SchemaReques
164165
},
165166
},
166167
},
168+
"quota_definitions": schema.ListAttribute{
169+
MarkdownDescription: "List of quota definitions for the platform.",
170+
Required: true,
171+
Sensitive: false,
172+
ElementType: types.ObjectType{
173+
AttrTypes: map[string]attr.Type{
174+
"quota_key": types.StringType,
175+
"label": types.StringType,
176+
"description": types.StringType,
177+
"unit": types.StringType,
178+
"min_value": types.Int64Type,
179+
"max_value": types.Int64Type,
180+
"auto_approval_threshold": types.Int64Type,
181+
},
182+
},
183+
},
167184
"config": schema.SingleNestedAttribute{
168185
MarkdownDescription: "Platform-specific configuration options.",
169186
Computed: true,

internal/provider/platform_resource.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,22 @@ func (r *platformResource) Schema(_ context.Context, _ resource.SchemaRequest, r
212212
},
213213
},
214214
},
215+
"quota_definitions": schema.ListAttribute{
216+
MarkdownDescription: "List of quota definitions for the platform.",
217+
Required: true,
218+
Sensitive: false,
219+
ElementType: types.ObjectType{
220+
AttrTypes: map[string]attr.Type{
221+
"quota_key": types.StringType,
222+
"label": types.StringType,
223+
"description": types.StringType,
224+
"unit": types.StringType,
225+
"min_value": types.Int64Type,
226+
"max_value": types.Int64Type,
227+
"auto_approval_threshold": types.Int64Type,
228+
},
229+
},
230+
},
215231
"config": schema.SingleNestedAttribute{
216232
MarkdownDescription: "Platform-specific configuration settings.",
217233
Required: true,

0 commit comments

Comments
 (0)