generated from hashicorp/terraform-provider-scaffolding-framework
/
monolith_manifest_sub_manifest.go
41 lines (35 loc) · 1.4 KB
/
monolith_manifest_sub_manifest.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package provider
import (
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/zentralopensource/goztl"
)
type monolithManifestSubManifest struct {
ID types.Int64 `tfsdk:"id"`
ManifestID types.Int64 `tfsdk:"manifest_id"`
SubManifestID types.Int64 `tfsdk:"sub_manifest_id"`
TagIDs types.Set `tfsdk:"tag_ids"`
}
func monolithManifestSubManifestForState(mmsm *goztl.MonolithManifestSubManifest) monolithManifestSubManifest {
tagIDs := make([]attr.Value, 0)
for _, tagID := range mmsm.TagIDs {
tagIDs = append(tagIDs, types.Int64Value(int64(tagID)))
}
return monolithManifestSubManifest{
ID: types.Int64Value(int64(mmsm.ID)),
ManifestID: types.Int64Value(int64(mmsm.ManifestID)),
SubManifestID: types.Int64Value(int64(mmsm.SubManifestID)),
TagIDs: types.SetValueMust(types.Int64Type, tagIDs),
}
}
func monolithManifestSubManifestRequestWithState(data monolithManifestSubManifest) *goztl.MonolithManifestSubManifestRequest {
tagIDs := make([]int, 0)
for _, tagID := range data.TagIDs.Elements() { // nil if null or unknown → no iterations
tagIDs = append(tagIDs, int(tagID.(types.Int64).ValueInt64()))
}
return &goztl.MonolithManifestSubManifestRequest{
ManifestID: int(data.ManifestID.ValueInt64()),
SubManifestID: int(data.SubManifestID.ValueInt64()),
TagIDs: tagIDs,
}
}