Skip to content

Commit e6ccf31

Browse files
authored
feat(k8s): add warning message for clusters with no PN (#2149)
1 parent 0374856 commit e6ccf31

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

scaleway/resource_k8s_cluster.go

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -545,29 +545,38 @@ func resourceScalewayK8SClusterRead(ctx context.Context, d *schema.ResourceData,
545545
_ = d.Set("open_id_connect_config", clusterOpenIDConnectConfigFlatten(cluster))
546546
_ = d.Set("auto_upgrade", clusterAutoUpgradeFlatten(cluster))
547547

548+
var diags diag.Diagnostics
549+
548550
// private_network
549-
_ = d.Set("private_network_id", flattenStringPtr(cluster.PrivateNetworkID))
551+
pnID := flattenStringPtr(cluster.PrivateNetworkID)
552+
_ = d.Set("private_network_id", pnID)
553+
if pnID == "" {
554+
diags = append(diags, diag.Diagnostic{
555+
Severity: diag.Warning,
556+
Summary: "Public clusters are deprecated",
557+
Detail: "Important: Harden your cluster's security by enabling a free private network ASAP. Full public clusters are deprecated and will reach End of Support in Q1 2024.",
558+
})
559+
}
550560

551561
////
552562
// Read kubeconfig
553563
////
554564
kubeconfig, err := flattenKubeconfig(ctx, k8sAPI, region, clusterID)
555565
if err != nil {
556566
if is403Error(err) {
557-
return diag.Diagnostics{
558-
diag.Diagnostic{
559-
Severity: diag.Warning,
560-
Summary: "Cannot read kubeconfig: unauthorized",
561-
Detail: "Got 403 while reading kubeconfig, please check your permissions",
562-
AttributePath: cty.GetAttrPath("kubeconfig"),
563-
},
564-
}
567+
diags = append(diags, diag.Diagnostic{
568+
Severity: diag.Warning,
569+
Summary: "Cannot read kubeconfig: unauthorized",
570+
Detail: "Got 403 while reading kubeconfig, please check your permissions",
571+
AttributePath: cty.GetAttrPath("kubeconfig"),
572+
})
565573
}
566-
return diag.FromErr(err)
574+
} else {
575+
diags = append(diags, diag.FromErr(err)...)
567576
}
568577
_ = d.Set("kubeconfig", []map[string]interface{}{kubeconfig})
569578

570-
return nil
579+
return diags
571580
}
572581

573582
//gocyclo:ignore

0 commit comments

Comments
 (0)