-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
kubernetes_cluster_resource
support network_profile.ip_versions
#16088
kubernetes_cluster_resource
support network_profile.ip_versions
#16088
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR @heiazuo, this is off to a good start. Aside from the comments left in-line I also have two additional suggestions:
- We should create an additional test that tests dual-stack networking with the value
["IPv4", "IPv6"]
- In the create method could we add a check that throws an error if a user tries to specify
["IPv6"]
, the validation for the property allows it, but it isn't valid for the API.
Once the above is addressed we can take another look through this.
b71dce8
to
b58db9c
Compare
Thanks @stephybun, thanks for your suggestion, I made the changes as suggested |
kubernetes_cluster_resource
support network_profile.ip_familieskubernetes_cluster_resource
support network_profile.ip_versions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for renaming the property and adding the test for dual-stack networking @heiazuo, I still have a question and suggestion regarding the check on the value.
func expandIPVersions(input []interface{}) *[]containerservice.IPFamily { | ||
if len(input) == 0 { | ||
return nil | ||
} | ||
ipf := make([]containerservice.IPFamily, 0) | ||
for _, data := range input { | ||
ipf = append(ipf, containerservice.IPFamily(data.(string))) | ||
} | ||
|
||
return &ipf | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like so
func expandIPVersions(input []interface{}) *[]containerservice.IPFamily { | |
if len(input) == 0 { | |
return nil | |
} | |
ipf := make([]containerservice.IPFamily, 0) | |
for _, data := range input { | |
ipf = append(ipf, containerservice.IPFamily(data.(string))) | |
} | |
return &ipf | |
} | |
func expandIPVersions(input []interface{}) (*[]containerservice.IPFamily, error) { | |
if len(input) == 0 { | |
return nil, nil | |
} | |
ipf := make([]containerservice.IPFamily, 0) | |
for _, data := range input { | |
ipf = append(ipf, containerservice.IPFamily(data.(string))) | |
} | |
if len(ipf) == 1 && ipf[0] == containerservice.IPFamilyIPv6 { | |
return nil, fmt.Errorf("`ip_versions` must be `IPv4` or `IPv4` and `IPv6`. `IPv6` alone is not supported") | |
} | |
return &ipf, nil | |
} |
ipVersions := config["ip_versions"].([]interface{}) | ||
|
||
networkProfile := containerservice.NetworkProfile{ | ||
NetworkPlugin: containerservice.NetworkPlugin(networkPlugin), | ||
NetworkMode: containerservice.NetworkMode(networkMode), | ||
NetworkPolicy: containerservice.NetworkPolicy(networkPolicy), | ||
LoadBalancerSku: containerservice.LoadBalancerSku(loadBalancerSku), | ||
OutboundType: containerservice.OutboundType(outboundType), | ||
IPFamilies: expandIPVersions(ipVersions), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ipVersions := config["ip_versions"].([]interface{}) | |
networkProfile := containerservice.NetworkProfile{ | |
NetworkPlugin: containerservice.NetworkPlugin(networkPlugin), | |
NetworkMode: containerservice.NetworkMode(networkMode), | |
NetworkPolicy: containerservice.NetworkPolicy(networkPolicy), | |
LoadBalancerSku: containerservice.LoadBalancerSku(loadBalancerSku), | |
OutboundType: containerservice.OutboundType(outboundType), | |
IPFamilies: expandIPVersions(ipVersions), | |
ipVersions, err := expandIPVersions(config["ip_versions"].([]interface{})) | |
if err != nil { | |
return nil, err | |
} | |
networkProfile := containerservice.NetworkProfile{ | |
NetworkPlugin: containerservice.NetworkPlugin(networkPlugin), | |
NetworkMode: containerservice.NetworkMode(networkMode), | |
NetworkPolicy: containerservice.NetworkPolicy(networkPolicy), | |
LoadBalancerSku: containerservice.LoadBalancerSku(loadBalancerSku), | |
OutboundType: containerservice.OutboundType(outboundType), | |
IPFamilies: ipVersions, | |
} |
2:add ip_versions`IPv6` alone check logic at expandIPVersions function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @heiazuo, LGTM 🥟
This functionality has been released in v3.1.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
create a public pull request for
kubernetes_cluster_resource
support network_profile.ip_familiesLink to #15708