Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions client/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ type MeshPlatformSpec struct {
ContributingWorkspaces []string `json:"contributingWorkspaces" tfsdk:"contributing_workspaces"`
Availability PlatformAvailability `json:"availability" tfsdk:"availability"`
Config PlatformConfig `json:"config" tfsdk:"config"`
QuotaDefinitions []QuotaDefinition `json:"quotaDefinitions" tfsdk:"quota_definitions"`
}

type QuotaDefinition struct {
QuotaKey string `json:"quotaKey" tfsdk:"quota_key"`
MinValue int `json:"minValue" tfsdk:"min_value"`
MaxValue int `json:"maxValue" tfsdk:"max_value"`
Unit string `json:"unit" tfsdk:"unit"`
AutoApprovalThreshold int `json:"autoApprovalThreshold" tfsdk:"auto_approval_threshold"`
Description string `json:"description" tfsdk:"description"`
Label string `json:"label" tfsdk:"label"`
}

type LocationRef struct {
Expand Down
18 changes: 18 additions & 0 deletions docs/data-sources/platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ Read-Only:
<a id="nestedatt--spec"></a>
### Nested Schema for `spec`

Required:

- `quota_definitions` (List of Object) List of quota definitions for the platform. (see [below for nested schema](#nestedatt--spec--quota_definitions))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d: its listed as required. doesnt this break possibly all existing TF scripts or is it somehow default = empty? If this is possible I would suggest to have lets say a empty default to allow old TF scripts to continue to work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

V2 is in preview state. This is expected. Making it nullable is not an option. Discussed that already.


Read-Only:

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

<a id="nestedatt--spec--quota_definitions"></a>
### Nested Schema for `spec.quota_definitions`

Read-Only:

- `auto_approval_threshold` (Number)
- `description` (String)
- `label` (String)
- `max_value` (Number)
- `min_value` (Number)
- `quota_key` (String)
- `unit` (String)


<a id="nestedatt--spec--availability"></a>
### Nested Schema for `spec.availability`

Expand Down
17 changes: 17 additions & 0 deletions docs/resources/platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ resource "meshstack_platform" "example" {
restricted_to_workspaces = []
}

quota_definitions = []

config = {
azure = {
entra_tenant = "dev-mycompany.onmicrosoft.com"
Expand Down Expand Up @@ -189,6 +191,7 @@ Required:
- `display_name` (String) The human-readable display name of the meshPlatform.
- `endpoint` (String) The web console URL endpoint of the platform.
- `location_ref` (Attributes) Reference to the location where this platform is situated. (see [below for nested schema](#nestedatt--spec--location_ref))
- `quota_definitions` (List of Object) List of quota definitions for the platform. (see [below for nested schema](#nestedatt--spec--quota_definitions))

Optional:

Expand Down Expand Up @@ -849,6 +852,20 @@ Read-Only:

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


<a id="nestedatt--spec--quota_definitions"></a>
### Nested Schema for `spec.quota_definitions`

Required:

- `auto_approval_threshold` (Number)
- `description` (String)
- `label` (String)
- `max_value` (Number)
- `min_value` (Number)
- `quota_key` (String)
- `unit` (String)

## Import

Import is supported using the following syntax:
Expand Down
2 changes: 2 additions & 0 deletions examples/resources/meshstack_platform/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ resource "meshstack_platform" "example" {
restricted_to_workspaces = []
}

quota_definitions = []

config = {
azure = {
entra_tenant = "dev-mycompany.onmicrosoft.com"
Expand Down
17 changes: 17 additions & 0 deletions internal/provider/platform_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/meshcloud/terraform-provider-meshstack/client"

"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
Expand Down Expand Up @@ -164,6 +165,22 @@ func (d *platformDataSource) Schema(_ context.Context, _ datasource.SchemaReques
},
},
},
"quota_definitions": schema.ListAttribute{
MarkdownDescription: "List of quota definitions for the platform.",
Required: true,
Sensitive: false,
ElementType: types.ObjectType{
AttrTypes: map[string]attr.Type{
"quota_key": types.StringType,
"label": types.StringType,
"description": types.StringType,
"unit": types.StringType,
"min_value": types.Int64Type,
"max_value": types.Int64Type,
"auto_approval_threshold": types.Int64Type,
},
},
},
"config": schema.SingleNestedAttribute{
MarkdownDescription: "Platform-specific configuration options.",
Computed: true,
Expand Down
16 changes: 16 additions & 0 deletions internal/provider/platform_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,22 @@ func (r *platformResource) Schema(_ context.Context, _ resource.SchemaRequest, r
},
},
},
"quota_definitions": schema.ListAttribute{
MarkdownDescription: "List of quota definitions for the platform.",
Required: true,
Sensitive: false,
ElementType: types.ObjectType{
AttrTypes: map[string]attr.Type{
"quota_key": types.StringType,
"label": types.StringType,
"description": types.StringType,
"unit": types.StringType,
"min_value": types.Int64Type,
"max_value": types.Int64Type,
"auto_approval_threshold": types.Int64Type,
},
},
},
"config": schema.SingleNestedAttribute{
MarkdownDescription: "Platform-specific configuration settings.",
Required: true,
Expand Down