Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_kubernetes_cluster - prevent breaking change in casing for network_plugin_mode #22153

Merged
merged 2 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions internal/services/containers/kubernetes_cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -836,8 +836,7 @@ func resourceKubernetesCluster() *pluginsdk.Resource {
Optional: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
// TODO 4.0: change it to managedclusters.NetworkPluginModeOverlay
"Overlay",
string(managedclusters.NetworkPluginModeOverlay),
}, false),
},

Expand Down Expand Up @@ -1298,6 +1297,14 @@ func resourceKubernetesCluster() *pluginsdk.Resource {
Deprecated: "`docker_bridge_cidr` has been deprecated as the API no longer supports it and will be removed in version 4.0 of the provider.",
ValidateFunc: validate.CIDR,
}
resource.Schema["network_profile"].Elem.(*pluginsdk.Resource).Schema["network_plugin_mode"] = &pluginsdk.Schema{
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
"Overlay",
}, false),
}
}

return resource
Expand Down Expand Up @@ -3165,6 +3172,9 @@ func flattenKubernetesClusterNetworkProfile(profile *managedclusters.ContainerSe
// Issue: https://github.com/Azure/azure-rest-api-specs/issues/21810
if strings.EqualFold(string(*profile.NetworkPluginMode), string(managedclusters.NetworkPluginModeOverlay)) {
networkPluginMode = string(managedclusters.NetworkPluginModeOverlay)
if !features.FourPointOhBeta() {
networkPluginMode = "Overlay"
}
}
}
ebpfDataPlane := ""
Expand Down
4 changes: 2 additions & 2 deletions internal/services/containers/kubernetes_cluster_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func validateKubernetesCluster(d *pluginsdk.ResourceData, cluster *managedcluste
isServiceCidrSet := serviceCidr != "" || len(serviceCidrs) != 0

// Azure network plugin is not compatible with pod_cidr
if podCidr != "" && networkPlugin == "azure" && networkPluginMode != string(managedclusters.NetworkPluginModeOverlay) {
return fmt.Errorf("`pod_cidr` and `azure` cannot be set together unless specifying `network_plugin_mode` to `overlay`")
if podCidr != "" && strings.EqualFold(networkPlugin, "azure") && !strings.EqualFold(networkPluginMode, string(managedclusters.NetworkPluginModeOverlay)) {
return fmt.Errorf("`pod_cidr` and `azure` cannot be set together unless specifying `network_plugin_mode` to `Overlay`")
}

// if not All empty values or All set values.
Expand Down