feat: add pod_address_ranges to ske resource/datasource (#888)
* feat: add pod_address_ranges to ske resource/datasource Signed-off-by: Mauritz Uphoff <mauritz.uphoff@stackit.cloud> * review changes Signed-off-by: Mauritz Uphoff <mauritz.uphoff@stackit.cloud> * review changes 2 Signed-off-by: Mauritz Uphoff <mauritz.uphoff@stackit.cloud> --------- Signed-off-by: Mauritz Uphoff <mauritz.uphoff@stackit.cloud>
This commit is contained in:
parent
2f06bc590d
commit
04a3436a0c
7 changed files with 174 additions and 15 deletions
|
|
@ -98,6 +98,11 @@ func (r *clusterDataSource) Schema(_ context.Context, _ datasource.SchemaRequest
|
|||
Computed: true,
|
||||
ElementType: types.StringType,
|
||||
},
|
||||
"pod_address_ranges": schema.ListAttribute{
|
||||
Description: "The network ranges (in CIDR notation) used by pods of the cluster.",
|
||||
Computed: true,
|
||||
ElementType: types.StringType,
|
||||
},
|
||||
"node_pools": schema.ListNestedAttribute{
|
||||
Description: "One or more `node_pool` block as defined below.",
|
||||
Computed: true,
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ type Model struct {
|
|||
Hibernations types.List `tfsdk:"hibernations"`
|
||||
Extensions types.Object `tfsdk:"extensions"`
|
||||
EgressAddressRanges types.List `tfsdk:"egress_address_ranges"`
|
||||
PodAddressRanges types.List `tfsdk:"pod_address_ranges"`
|
||||
Region types.String `tfsdk:"region"`
|
||||
}
|
||||
|
||||
|
|
@ -384,6 +385,11 @@ func (r *clusterResource) Schema(_ context.Context, _ resource.SchemaRequest, re
|
|||
Computed: true,
|
||||
ElementType: types.StringType,
|
||||
},
|
||||
"pod_address_ranges": schema.ListAttribute{
|
||||
Description: "The network ranges (in CIDR notation) used by pods of the cluster.",
|
||||
Computed: true,
|
||||
ElementType: types.StringType,
|
||||
},
|
||||
"node_pools": schema.ListNestedAttribute{
|
||||
Description: "One or more `node_pool` block as defined below.",
|
||||
Required: true,
|
||||
|
|
@ -1378,6 +1384,15 @@ func mapFields(ctx context.Context, cl *ske.Cluster, m *Model, region string) er
|
|||
}
|
||||
}
|
||||
|
||||
m.PodAddressRanges = types.ListNull(types.StringType)
|
||||
if cl.Status != nil {
|
||||
var diags diag.Diagnostics
|
||||
m.PodAddressRanges, diags = types.ListValueFrom(ctx, types.StringType, cl.Status.PodAddressRanges)
|
||||
if diags.HasError() {
|
||||
return fmt.Errorf("map podAddressRanges: %w", core.DiagsToError(diags))
|
||||
}
|
||||
}
|
||||
|
||||
err := mapNodePools(ctx, cl, m)
|
||||
if err != nil {
|
||||
return fmt.Errorf("map node_pools: %w", err)
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ func TestMapFields(t *testing.T) {
|
|||
Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}),
|
||||
Extensions: types.ObjectNull(extensionsTypes),
|
||||
EgressAddressRanges: types.ListNull(types.StringType),
|
||||
PodAddressRanges: types.ListNull(types.StringType),
|
||||
Region: types.StringValue(testRegion),
|
||||
},
|
||||
true,
|
||||
|
|
@ -151,6 +152,7 @@ func TestMapFields(t *testing.T) {
|
|||
Error: nil,
|
||||
Hibernated: nil,
|
||||
EgressAddressRanges: &[]string{"0.0.0.0/32", "1.1.1.1/32"},
|
||||
PodAddressRanges: &[]string{"0.0.0.0/32", "1.1.1.1/32"},
|
||||
},
|
||||
},
|
||||
testRegion,
|
||||
|
|
@ -168,6 +170,13 @@ func TestMapFields(t *testing.T) {
|
|||
types.StringValue("1.1.1.1/32"),
|
||||
},
|
||||
),
|
||||
PodAddressRanges: types.ListValueMust(
|
||||
types.StringType,
|
||||
[]attr.Value{
|
||||
types.StringValue("0.0.0.0/32"),
|
||||
types.StringValue("1.1.1.1/32"),
|
||||
},
|
||||
),
|
||||
NodePools: types.ListValueMust(
|
||||
types.ObjectType{AttrTypes: nodePoolTypes},
|
||||
[]attr.Value{
|
||||
|
|
@ -283,6 +292,7 @@ func TestMapFields(t *testing.T) {
|
|||
Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}),
|
||||
Extensions: types.ObjectNull(extensionsTypes),
|
||||
EgressAddressRanges: types.ListNull(types.StringType),
|
||||
PodAddressRanges: types.ListNull(types.StringType),
|
||||
Region: types.StringValue(testRegion),
|
||||
},
|
||||
true,
|
||||
|
|
@ -319,6 +329,7 @@ func TestMapFields(t *testing.T) {
|
|||
Maintenance: types.ObjectNull(maintenanceTypes),
|
||||
Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}),
|
||||
EgressAddressRanges: types.ListNull(types.StringType),
|
||||
PodAddressRanges: types.ListNull(types.StringType),
|
||||
Extensions: types.ObjectValueMust(extensionsTypes, map[string]attr.Value{
|
||||
"acl": types.ObjectValueMust(aclTypes, map[string]attr.Value{
|
||||
"enabled": types.BoolValue(true),
|
||||
|
|
@ -369,6 +380,7 @@ func TestMapFields(t *testing.T) {
|
|||
Maintenance: types.ObjectNull(maintenanceTypes),
|
||||
Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}),
|
||||
EgressAddressRanges: types.ListNull(types.StringType),
|
||||
PodAddressRanges: types.ListNull(types.StringType),
|
||||
Extensions: types.ObjectValueMust(extensionsTypes, map[string]attr.Value{
|
||||
"acl": types.ObjectValueMust(aclTypes, map[string]attr.Value{
|
||||
"enabled": types.BoolValue(false),
|
||||
|
|
@ -430,6 +442,7 @@ func TestMapFields(t *testing.T) {
|
|||
Maintenance: types.ObjectNull(maintenanceTypes),
|
||||
Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}),
|
||||
EgressAddressRanges: types.ListNull(types.StringType),
|
||||
PodAddressRanges: types.ListNull(types.StringType),
|
||||
Extensions: types.ObjectValueMust(extensionsTypes, map[string]attr.Value{
|
||||
"acl": types.ObjectValueMust(aclTypes, map[string]attr.Value{
|
||||
"enabled": types.BoolValue(true),
|
||||
|
|
@ -470,6 +483,7 @@ func TestMapFields(t *testing.T) {
|
|||
Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}),
|
||||
Extensions: types.ObjectNull(extensionsTypes),
|
||||
EgressAddressRanges: types.ListNull(types.StringType),
|
||||
PodAddressRanges: types.ListNull(types.StringType),
|
||||
Region: types.StringValue(testRegion),
|
||||
},
|
||||
true,
|
||||
|
|
@ -598,6 +612,7 @@ func TestMapFields(t *testing.T) {
|
|||
KubernetesVersionUsed: types.StringValue("1.2.3"),
|
||||
AllowPrivilegedContainers: types.BoolValue(true),
|
||||
EgressAddressRanges: types.ListNull(types.StringType),
|
||||
PodAddressRanges: types.ListNull(types.StringType),
|
||||
NodePools: types.ListValueMust(
|
||||
types.ObjectType{AttrTypes: nodePoolTypes},
|
||||
[]attr.Value{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue