Skip to content

Commit 5a89e08

Browse files
committed
feature: preview building blocks v2 resources
1 parent 13f2d9c commit 5a89e08

File tree

8 files changed

+1025
-47
lines changed

8 files changed

+1025
-47
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- run: go mod download
3131
- run: go build -v .
3232
- name: Run linters
33-
uses: golangci/golangci-lint-action@v6
33+
uses: golangci/golangci-lint-action@v7
3434
with:
3535
version: latest
3636

client/buildingblock.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ type MeshBuildingBlockSpec struct {
4646
}
4747

4848
type MeshBuildingBlockIO struct {
49-
Key string `json:"key" tfsdk:"key"`
50-
Value interface{} `json:"value" tfsdk:"value"`
51-
ValueType string `json:"valueType" tfsdk:"value_type"`
49+
Key string `json:"key" tfsdk:"key"`
50+
Value any `json:"value" tfsdk:"value"`
51+
ValueType string `json:"valueType" tfsdk:"value_type"`
5252
}
5353

5454
type MeshBuildingBlockParent struct {

client/buildingblock_v2.go

Lines changed: 31 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,73 +6,61 @@ import (
66
"fmt"
77
"io"
88
"net/http"
9-
"net/url"
109
)
1110

1211
const (
13-
CONTENT_TYPE_BUILDING_BLOCK_V2 = "application/vnd.meshcloud.api.meshbuildingblock.v2.hal+json"
12+
CONTENT_TYPE_BUILDING_BLOCK_V2 = "application/vnd.meshcloud.api.meshbuildingblock.v2-preview.hal+json"
1413
)
1514

1615
type MeshBuildingBlockV2 struct {
17-
ApiVersion string `json:"apiVersion" tfsdk:"api_version"`
18-
Kind string `json:"kind" tfsdk:"kind"`
19-
Metadata MeshBuildingBlockMetadataV2 `json:"metadata" tfsdk:"metadata"`
20-
Spec MeshBuildingBlockSpecV2 `json:"spec" tfsdk:"spec"`
21-
Status MeshBuildingBlockStatusV2 `json:"status" tfsdk:"status"`
16+
ApiVersion string `json:"apiVersion" tfsdk:"api_version"`
17+
Kind string `json:"kind" tfsdk:"kind"`
18+
Metadata MeshBuildingBlockV2Metadata `json:"metadata" tfsdk:"metadata"`
19+
Spec MeshBuildingBlockV2Spec `json:"spec" tfsdk:"spec"`
20+
Status MeshBuildingBlockV2Status `json:"status" tfsdk:"status"`
2221
}
2322

24-
type MeshBuildingBlockMetadataV2 struct {
23+
type MeshBuildingBlockV2Metadata struct {
2524
Uuid string `json:"uuid" tfsdk:"uuid"`
26-
DefinitionUuid string `json:"definitionUuid" tfsdk:"definition_uuid"`
27-
DefinitionVersion int64 `json:"definitionVersion" tfsdk:"definition_version"`
28-
TenantIdentifier string `json:"tenantIdentifier" tfsdk:"tenant_identifier"`
29-
ForcePurge bool `json:"forcePurge" tfsdk:"force_purge"`
25+
OwnedByWorkspace string `json:"ownedByWorkspace" tfsdk:"owned_by_workspace"`
3026
CreatedOn string `json:"createdOn" tfsdk:"created_on"`
3127
MarkedForDeletionOn *string `json:"markedForDeletionOn" tfsdk:"marked_for_deletion_on"`
3228
MarkedForDeletionBy *string `json:"markedForDeletionBy" tfsdk:"marked_for_deletion_by"`
3329
}
3430

35-
type MeshBuildingBlockSpecV2 struct {
36-
DisplayName string `json:"displayName" tfsdk:"display_name"`
37-
Inputs []MeshBuildingBlockIOV2 `json:"inputs" tfsdk:"inputs"`
38-
ParentBuildingBlocks []MeshBuildingBlockParentV2 `json:"parentBuildingBlocks" tfsdk:"parent_building_blocks"`
39-
}
40-
41-
type MeshBuildingBlockIOV2 struct {
42-
Key string `json:"key" tfsdk:"key"`
43-
Value interface{} `json:"value" tfsdk:"value"`
44-
ValueType string `json:"valueType" tfsdk:"value_type"`
45-
}
31+
type MeshBuildingBlockV2Spec struct {
32+
BuildingBlockDefinitionVersionRef MeshBuildingBlockV2DefinitionVersionRef `json:"buildingBlockDefinitionVersionRef" tfsdk:"building_block_definition_version_ref"`
33+
TargetRef MeshBuildingBlockV2TargetRef `json:"targetRef" tfsdk:"target_ref"`
34+
DisplayName string `json:"displayName" tfsdk:"display_name"`
4635

47-
type MeshBuildingBlockParentV2 struct {
48-
BuildingBlockUuid string `json:"buildingBlockUuid" tfsdk:"buildingblock_uuid"`
49-
DefinitionUuid string `json:"definitionUuid" tfsdk:"definition_uuid"`
36+
Inputs []MeshBuildingBlockIO `json:"inputs" tfsdk:"inputs"`
37+
ParentBuildingBlocks []MeshBuildingBlockParent `json:"parentBuildingBlocks" tfsdk:"parent_building_blocks"`
5038
}
5139

52-
type MeshBuildingBlockStatusV2 struct {
53-
Status string `json:"status" tfsdk:"status"`
54-
Outputs []MeshBuildingBlockIOV2 `json:"outputs" tfsdk:"outputs"`
40+
type MeshBuildingBlockV2DefinitionVersionRef struct {
41+
Uuid string `json:"uuid" tfsdk:"uuid"`
5542
}
5643

57-
type MeshBuildingBlockCreateV2 struct {
58-
ApiVersion string `json:"apiVersion" tfsdk:"api_version"`
59-
Kind string `json:"kind" tfsdk:"kind"`
60-
Metadata MeshBuildingBlockMetadataV2 `json:"metadata" tfsdk:"metadata"`
61-
Spec MeshBuildingBlockSpecV2 `json:"spec" tfsdk:"spec"`
44+
type MeshBuildingBlockV2TargetRef struct {
45+
Kind string `json:"kind" tfsdk:"kind"`
46+
Uuid *string `json:"uuid" tfsdk:"uuid"`
47+
Identifier *string `json:"identifier" tfsdk:"identifier"`
6248
}
6349

64-
type MeshBuildingBlockCreateMetadataV2 struct {
65-
DefinitionUuid string `json:"definitionUuid" tfsdk:"definition_uuid"`
66-
DefinitionVersion int64 `json:"definitionVersion" tfsdk:"definition_version"`
67-
TenantIdentifier string `json:"tenantIdentifier" tfsdk:"tenant_identifier"`
50+
type MeshBuildingBlockV2Create struct {
51+
ApiVersion string `json:"apiVersion" tfsdk:"api_version"`
52+
Kind string `json:"kind" tfsdk:"kind"`
53+
Spec MeshBuildingBlockV2Spec `json:"spec" tfsdk:"spec"`
6854
}
6955

70-
func (c *MeshStackProviderClient) urlForBuildingBlockV2(uuid string) *url.URL {
71-
return c.endpoints.BuildingBlocks.JoinPath(uuid)
56+
type MeshBuildingBlockV2Status struct {
57+
Status string `json:"status" tfsdk:"status"`
58+
Outputs []MeshBuildingBlockIO `json:"outputs" tfsdk:"outputs"`
59+
ForcePurge bool `json:"forcePurge" tfsdk:"force_purge"`
7260
}
7361

7462
func (c *MeshStackProviderClient) ReadBuildingBlockV2(uuid string) (*MeshBuildingBlockV2, error) {
75-
targetUrl := c.urlForBuildingBlockV2(uuid)
63+
targetUrl := c.urlForBuildingBlock(uuid)
7664

7765
req, err := http.NewRequest("GET", targetUrl.String(), nil)
7866
if err != nil {
@@ -109,7 +97,7 @@ func (c *MeshStackProviderClient) ReadBuildingBlockV2(uuid string) (*MeshBuildin
10997
return &bb, nil
11098
}
11199

112-
func (c *MeshStackProviderClient) CreateBuildingBlockV2(bb *MeshBuildingBlockCreateV2) (*MeshBuildingBlockV2, error) {
100+
func (c *MeshStackProviderClient) CreateBuildingBlockV2(bb *MeshBuildingBlockV2Create) (*MeshBuildingBlockV2, error) {
113101
payload, err := json.Marshal(bb)
114102
if err != nil {
115103
return nil, err
@@ -148,6 +136,6 @@ func (c *MeshStackProviderClient) CreateBuildingBlockV2(bb *MeshBuildingBlockCre
148136
}
149137

150138
func (c *MeshStackProviderClient) DeleteBuildingBlockV2(uuid string) error {
151-
targetUrl := c.urlForBuildingBlockV2(uuid)
139+
targetUrl := c.urlForBuildingBlock(uuid)
152140
return c.deleteMeshObject(*targetUrl, 202)
153141
}
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "meshstack_building_block_v2 Data Source - terraform-provider-meshstack"
4+
subcategory: ""
5+
description: |-
6+
Single building block by UUID.
7+
~> Note: This resource is in preview. It's incomplete and will change in the near future.
8+
---
9+
10+
# meshstack_building_block_v2 (Data Source)
11+
12+
Single building block by UUID.
13+
14+
~> **Note:** This resource is in preview. It's incomplete and will change in the near future.
15+
16+
17+
18+
<!-- schema generated by tfplugindocs -->
19+
## Schema
20+
21+
### Required
22+
23+
- `metadata` (Attributes) Building block metadata. (see [below for nested schema](#nestedatt--metadata))
24+
25+
### Read-Only
26+
27+
- `api_version` (String) Building block datatype version
28+
- `kind` (String) meshObject type, always `meshBuildingBlock`.
29+
- `spec` (Attributes) Building block specification. (see [below for nested schema](#nestedatt--spec))
30+
- `status` (Attributes) Current building block status. (see [below for nested schema](#nestedatt--status))
31+
32+
<a id="nestedatt--metadata"></a>
33+
### Nested Schema for `metadata`
34+
35+
Required:
36+
37+
- `uuid` (String) UUID which uniquely identifies the building block.
38+
39+
Read-Only:
40+
41+
- `created_on` (String) Timestamp of building block creation.
42+
- `marked_for_deletion_by` (String) For deleted building blocks: user who requested deletion.
43+
- `marked_for_deletion_on` (String) For deleted building blocks: timestamp of deletion.
44+
- `owned_by_workspace` (String) The workspace containing this building block.
45+
46+
47+
<a id="nestedatt--spec"></a>
48+
### Nested Schema for `spec`
49+
50+
Read-Only:
51+
52+
- `building_block_definition_version_ref` (Attributes) References the building block definition this building block is based on. (see [below for nested schema](#nestedatt--spec--building_block_definition_version_ref))
53+
- `display_name` (String) Display name for the building block as shown in meshPanel.
54+
- `inputs` (Attributes Map) Contains all building block inputs. Each input has exactly one value attribute set according to its' type. (see [below for nested schema](#nestedatt--spec--inputs))
55+
- `parent_building_blocks` (Attributes List) List of parent building blocks. (see [below for nested schema](#nestedatt--spec--parent_building_blocks))
56+
- `target_ref` (Attributes) References the building block target. Depending on the building block definition this will be a workspace or a tenant (see [below for nested schema](#nestedatt--spec--target_ref))
57+
58+
<a id="nestedatt--spec--building_block_definition_version_ref"></a>
59+
### Nested Schema for `spec.building_block_definition_version_ref`
60+
61+
Read-Only:
62+
63+
- `uuid` (String) UUID of the building block definition.
64+
65+
66+
<a id="nestedatt--spec--inputs"></a>
67+
### Nested Schema for `spec.inputs`
68+
69+
Read-Only:
70+
71+
- `value_bool` (Boolean)
72+
- `value_file` (String)
73+
- `value_int` (Number)
74+
- `value_list` (String) JSON encoded list of objects.
75+
- `value_single_select` (String)
76+
- `value_string` (String)
77+
78+
79+
<a id="nestedatt--spec--parent_building_blocks"></a>
80+
### Nested Schema for `spec.parent_building_blocks`
81+
82+
Read-Only:
83+
84+
- `buildingblock_uuid` (String) UUID of the parent building block.
85+
- `definition_uuid` (String) UUID of the parent building block definition.
86+
87+
88+
<a id="nestedatt--spec--target_ref"></a>
89+
### Nested Schema for `spec.target_ref`
90+
91+
Read-Only:
92+
93+
- `identifier` (String) Identifier of the target workspace.
94+
- `kind` (String) Target kind for this building block, depends on building block definition type. One of `meshTenant`, `meshWorkspace`.
95+
- `uuid` (String) UUID of the target tenant.
96+
97+
98+
99+
<a id="nestedatt--status"></a>
100+
### Nested Schema for `status`
101+
102+
Read-Only:
103+
104+
- `force_purge` (Boolean) Indicates whether an operator has requested purging of this Building Block.
105+
- `outputs` (Attributes Map) Building block outputs. Each output has exactly one value attribute set. (see [below for nested schema](#nestedatt--status--outputs))
106+
- `status` (String) Execution status. One of `WAITING_FOR_DEPENDENT_INPUT`, `WAITING_FOR_OPERATOR_INPUT`, `PENDING`, `IN_PROGRESS`, `SUCCEEDED`, `FAILED`.
107+
108+
<a id="nestedatt--status--outputs"></a>
109+
### Nested Schema for `status.outputs`
110+
111+
Read-Only:
112+
113+
- `value_bool` (Boolean)
114+
- `value_file` (String)
115+
- `value_int` (Number)
116+
- `value_list` (String) JSON encoded list of objects.
117+
- `value_single_select` (String)
118+
- `value_string` (String)

docs/resources/building_block_v2.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "meshstack_building_block_v2 Resource - terraform-provider-meshstack"
4+
subcategory: ""
5+
description: |-
6+
Manage a workspace or tenant building block.
7+
~> Note: This resource is in preview. It's incomplete and will change in the near future.
8+
---
9+
10+
# meshstack_building_block_v2 (Resource)
11+
12+
Manage a workspace or tenant building block.
13+
14+
~> **Note:** This resource is in preview. It's incomplete and will change in the near future.
15+
16+
17+
18+
<!-- schema generated by tfplugindocs -->
19+
## Schema
20+
21+
### Required
22+
23+
- `spec` (Attributes) Building block specification. (see [below for nested schema](#nestedatt--spec))
24+
25+
### Read-Only
26+
27+
- `api_version` (String) Building block datatype version
28+
- `kind` (String) meshObject type, always `meshBuildingBlock`.
29+
- `metadata` (Attributes) Building block metadata. (see [below for nested schema](#nestedatt--metadata))
30+
- `status` (Attributes) Current building block status. (see [below for nested schema](#nestedatt--status))
31+
32+
<a id="nestedatt--spec"></a>
33+
### Nested Schema for `spec`
34+
35+
Required:
36+
37+
- `building_block_definition_version_ref` (Attributes) References the building block definition this building block is based on. (see [below for nested schema](#nestedatt--spec--building_block_definition_version_ref))
38+
- `display_name` (String) Display name for the building block as shown in meshPanel.
39+
- `target_ref` (Attributes) References the building block target. Depending on the building block definition this will be a workspace or a tenant (see [below for nested schema](#nestedatt--spec--target_ref))
40+
41+
Optional:
42+
43+
- `inputs` (Attributes Map) Building block user inputs. Each input has exactly one value. Use the value attribute that corresponds to the desired input type, e.g. `value_int` to set an integer input, and leave the remaining attributes empty. (see [below for nested schema](#nestedatt--spec--inputs))
44+
- `parent_building_blocks` (Attributes List) List of parent building blocks. (see [below for nested schema](#nestedatt--spec--parent_building_blocks))
45+
46+
Read-Only:
47+
48+
- `combined_inputs` (Attributes Map) Contains all building block inputs. Each input has exactly one value attribute set according to its' type. (see [below for nested schema](#nestedatt--spec--combined_inputs))
49+
50+
<a id="nestedatt--spec--building_block_definition_version_ref"></a>
51+
### Nested Schema for `spec.building_block_definition_version_ref`
52+
53+
Required:
54+
55+
- `uuid` (String) UUID of the building block definition.
56+
57+
58+
<a id="nestedatt--spec--target_ref"></a>
59+
### Nested Schema for `spec.target_ref`
60+
61+
Required:
62+
63+
- `kind` (String) Target kind for this building block, depends on building block definition type. One of `meshTenant`, `meshWorkspace`.
64+
65+
Optional:
66+
67+
- `identifier` (String) Identifier of the target workspace.
68+
- `uuid` (String) UUID of the target workspace or tenant.
69+
70+
71+
<a id="nestedatt--spec--inputs"></a>
72+
### Nested Schema for `spec.inputs`
73+
74+
Optional:
75+
76+
- `value_bool` (Boolean)
77+
- `value_file` (String)
78+
- `value_int` (Number)
79+
- `value_list` (String) JSON encoded list of objects.
80+
- `value_single_select` (String)
81+
- `value_string` (String)
82+
83+
84+
<a id="nestedatt--spec--parent_building_blocks"></a>
85+
### Nested Schema for `spec.parent_building_blocks`
86+
87+
Required:
88+
89+
- `buildingblock_uuid` (String) UUID of the parent building block.
90+
- `definition_uuid` (String) UUID of the parent building block definition.
91+
92+
93+
<a id="nestedatt--spec--combined_inputs"></a>
94+
### Nested Schema for `spec.combined_inputs`
95+
96+
Read-Only:
97+
98+
- `value_bool` (Boolean)
99+
- `value_file` (String)
100+
- `value_int` (Number)
101+
- `value_list` (String) JSON encoded list of objects.
102+
- `value_single_select` (String)
103+
- `value_string` (String)
104+
105+
106+
107+
<a id="nestedatt--metadata"></a>
108+
### Nested Schema for `metadata`
109+
110+
Read-Only:
111+
112+
- `created_on` (String) Timestamp of building block creation.
113+
- `marked_for_deletion_by` (String) For deleted building blocks: user who requested deletion.
114+
- `marked_for_deletion_on` (String) For deleted building blocks: timestamp of deletion.
115+
- `owned_by_workspace` (String) The workspace containing this building block.
116+
- `uuid` (String) UUID which uniquely identifies the building block.
117+
118+
119+
<a id="nestedatt--status"></a>
120+
### Nested Schema for `status`
121+
122+
Read-Only:
123+
124+
- `force_purge` (Boolean) Indicates whether an operator has requested purging of this Building Block.
125+
- `outputs` (Attributes Map) Building block outputs. Each output has exactly one value attribute set. (see [below for nested schema](#nestedatt--status--outputs))
126+
- `status` (String) Execution status. One of `WAITING_FOR_DEPENDENT_INPUT`, `WAITING_FOR_OPERATOR_INPUT`, `PENDING`, `IN_PROGRESS`, `SUCCEEDED`, `FAILED`.
127+
128+
<a id="nestedatt--status--outputs"></a>
129+
### Nested Schema for `status.outputs`
130+
131+
Read-Only:
132+
133+
- `value_bool` (Boolean)
134+
- `value_file` (String)
135+
- `value_int` (Number)
136+
- `value_list` (String) JSON encoded list of objects.
137+
- `value_single_select` (String)
138+
- `value_string` (String)

0 commit comments

Comments
 (0)