Skip to content

Commit 06297db

Browse files
Codelaxremyleone
andauthored
fix(k8s): remove warnings for missing pn (#2952)
* feat(k8s): remove warnings for missing pn * lint --------- Co-authored-by: Rémy Léone <[email protected]>
1 parent 767fd35 commit 06297db

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

internal/services/k8s/cluster.go

+6-18
Original file line numberDiff line numberDiff line change
@@ -570,41 +570,29 @@ func ResourceK8SClusterRead(ctx context.Context, d *schema.ResourceData, m inter
570570
_ = d.Set("open_id_connect_config", clusterOpenIDConnectConfigFlatten(cluster))
571571
_ = d.Set("auto_upgrade", clusterAutoUpgradeFlatten(cluster))
572572

573-
var diags diag.Diagnostics
574-
575573
// private_network
576-
pnID := types.FlattenStringPtr(cluster.PrivateNetworkID)
577-
clusterType := d.Get("type").(string)
578-
_ = d.Set("private_network_id", pnID)
579-
580-
if pnID == "" && !strings.HasPrefix(clusterType, "multicloud") {
581-
diags = append(diags, diag.Diagnostic{
582-
Severity: diag.Warning,
583-
Summary: "Public clusters are deprecated",
584-
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.",
585-
})
586-
}
574+
_ = d.Set("private_network_id", types.FlattenStringPtr(cluster.PrivateNetworkID))
587575

588576
////
589577
// Read kubeconfig
590578
////
591579
kubeconfig, err := flattenKubeconfig(ctx, k8sAPI, region, clusterID)
592580
if err != nil {
593581
if httperrors.Is403(err) {
594-
diags = append(diags, diag.Diagnostic{
582+
return diag.Diagnostics{diag.Diagnostic{
595583
Severity: diag.Warning,
596584
Summary: "Cannot read kubeconfig: unauthorized",
597585
Detail: "Got 403 while reading kubeconfig, please check your permissions",
598586
AttributePath: cty.GetAttrPath("kubeconfig"),
599-
})
587+
}}
600588
}
601-
} else {
602-
diags = append(diags, diag.FromErr(err)...)
589+
590+
return diag.FromErr(err)
603591
}
604592

605593
_ = d.Set("kubeconfig", []map[string]interface{}{kubeconfig})
606594

607-
return diags
595+
return nil
608596
}
609597

610598
//gocyclo:ignore

0 commit comments

Comments
 (0)