Skip to content

Commit 143a0d4

Browse files
committed
add version and provider id
1 parent 1431d4d commit 143a0d4

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

internal/model/cluster.go

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ type Cluster struct {
1414
InseredAt types.String `tfsdk:"inserted_at"`
1515
Name types.String `tfsdk:"name"`
1616
Handle types.String `tfsdk:"handle"`
17+
Version types.String `tfsdk:"version"`
18+
ProviderId types.String `tfsdk:"provider_id"`
1719
Cloud types.String `tfsdk:"cloud"`
1820
CloudSettings ClusterCloudSettings `tfsdk:"cloud_settings"`
1921
Protect types.Bool `tfsdk:"protect"`
@@ -120,24 +122,39 @@ func (c *Cluster) CreateAttributes() console.ClusterAttributes {
120122
return console.ClusterAttributes{
121123
Name: c.Name.ValueString(),
122124
Handle: c.Handle.ValueStringPointer(),
123-
Protect: c.Protect.ValueBoolPointer(),
125+
Version: c.Version.ValueStringPointer(),
126+
ProviderID: c.ProviderId.ValueStringPointer(),
124127
CloudSettings: c.CloudSettingsAttributes(),
125128
Tags: c.TagsAttribute(),
129+
Protect: c.Protect.ValueBoolPointer(),
126130
}
127131
}
128132

129133
func (c *Cluster) UpdateAttributes() console.ClusterUpdateAttributes {
130134
return console.ClusterUpdateAttributes{
131135
Handle: c.Handle.ValueStringPointer(),
136+
Version: c.Version.ValueStringPointer(),
132137
Protect: c.Protect.ValueBoolPointer(),
133138
}
134139
}
135140

141+
func (c *Cluster) TagsFrom(tags []*console.ClusterTags) {
142+
elements := map[string]attr.Value{}
143+
for _, v := range tags {
144+
elements[v.Name] = types.StringValue(v.Value)
145+
}
146+
147+
tagsValue, _ := types.MapValue(types.StringType, elements) // TODO: Skipped diagnostics.
148+
c.Tags = tagsValue
149+
}
150+
136151
func (c *Cluster) From(cl *console.ClusterFragment) {
137152
c.Id = types.StringValue(cl.ID)
138153
c.InseredAt = types.StringPointerValue(cl.InsertedAt)
139154
c.Name = types.StringValue(cl.Name)
140155
c.Handle = types.StringPointerValue(cl.Handle)
156+
c.Version = types.StringPointerValue(cl.Version)
157+
c.ProviderId = types.StringValue(cl.Provider.ID)
141158
c.Protect = types.BoolPointerValue(cl.Protect)
142159
c.TagsFrom(cl.Tags)
143160
}
@@ -147,16 +164,8 @@ func (c *Cluster) FromCreate(cc *console.CreateCluster) {
147164
c.InseredAt = types.StringPointerValue(cc.CreateCluster.InsertedAt)
148165
c.Name = types.StringValue(cc.CreateCluster.Name)
149166
c.Handle = types.StringPointerValue(cc.CreateCluster.Handle)
167+
c.Version = types.StringPointerValue(cc.CreateCluster.Version)
168+
c.ProviderId = types.StringValue(cc.CreateCluster.Provider.ID)
150169
c.Protect = types.BoolPointerValue(cc.CreateCluster.Protect)
151170
c.TagsFrom(cc.CreateCluster.Tags)
152171
}
153-
154-
func (c *Cluster) TagsFrom(tags []*console.ClusterTags) {
155-
elements := map[string]attr.Value{}
156-
for _, v := range tags {
157-
elements[v.Name] = types.StringValue(v.Value)
158-
}
159-
160-
tagsValue, _ := types.MapValue(types.StringType, elements) // TODO: Skipped diagnostics.
161-
c.Tags = tagsValue
162-
}

internal/resource/cluster/cluster.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ func (r *clusterResource) Schema(_ context.Context, _ resource.SchemaRequest, re
6161
Optional: true,
6262
Computed: true,
6363
},
64+
"version": schema.StringAttribute{
65+
MarkdownDescription: "",
66+
Optional: true,
67+
Computed: true,
68+
},
69+
"provider_id": schema.StringAttribute{
70+
MarkdownDescription: "",
71+
Required: true,
72+
},
6473
"cloud": schema.StringAttribute{
6574
MarkdownDescription: "The cloud provider used to create this cluster.",
6675
Required: true,

0 commit comments

Comments
 (0)