diff --git a/kubernetes/resource_kubernetes_network_policy.go b/kubernetes/resource_kubernetes_network_policy.go index 0520af8e6f..bf4845f5b8 100644 --- a/kubernetes/resource_kubernetes_network_policy.go +++ b/kubernetes/resource_kubernetes_network_policy.go @@ -17,12 +17,19 @@ var ( networkPolicySpecDoc = api.NetworkPolicy{}.SwaggerDoc()["spec"] networkPolicySpecIngressDoc = api.NetworkPolicySpec{}.SwaggerDoc()["ingress"] networkPolicyIngressRulePortsDoc = api.NetworkPolicyIngressRule{}.SwaggerDoc()["ports"] + networkPolicyIngressRuleFromDoc = api.NetworkPolicyIngressRule{}.SwaggerDoc()["from"] + networkPolicySpecEgressDoc = api.NetworkPolicySpec{}.SwaggerDoc()["egress"] + networkPolicyEgressRulePortsDoc = api.NetworkPolicyEgressRule{}.SwaggerDoc()["ports"] + networkPolicyEgressRuleToDoc = api.NetworkPolicyEgressRule{}.SwaggerDoc()["to"] networkPolicyPortPortDoc = api.NetworkPolicyPort{}.SwaggerDoc()["port"] networkPolicyPortProtocolDoc = api.NetworkPolicyPort{}.SwaggerDoc()["protocol"] - networkPolicyIngressRuleFromDoc = api.NetworkPolicyIngressRule{}.SwaggerDoc()["from"] + networkPolicyPeerIpBlockDoc = api.NetworkPolicyPeer{}.SwaggerDoc()["ipBlock"] + ipBlockCidrDoc = api.IPBlock{}.SwaggerDoc()["cidr"] + ipBlockExceptDoc = api.IPBlock{}.SwaggerDoc()["except"] networkPolicyPeerNamespaceSelectorDoc = api.NetworkPolicyPeer{}.SwaggerDoc()["namespaceSelector"] networkPolicyPeerPodSelectorDoc = api.NetworkPolicyPeer{}.SwaggerDoc()["podSelector"] networkPolicySpecPodSelectorDoc = api.NetworkPolicySpec{}.SwaggerDoc()["podSelector"] + networkPolicySpecPolicyTypesDoc = api.NetworkPolicySpec{}.SwaggerDoc()["policyTypes"] ) func resourceKubernetesNetworkPolicy() *schema.Resource { @@ -77,6 +84,104 @@ func resourceKubernetesNetworkPolicy() *schema.Resource { Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "ip_block": { + Type: schema.TypeList, + Description: networkPolicyPeerIpBlockDoc, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cidr": { + Type: schema.TypeString, + Description: ipBlockCidrDoc, + Optional: true, + }, + "except": { + Type: schema.TypeList, + Description: ipBlockExceptDoc, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, + "namespace_selector": { + Type: schema.TypeList, + Description: networkPolicyPeerNamespaceSelectorDoc, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: labelSelectorFields(), + }, + }, + "pod_selector": { + Type: schema.TypeList, + Description: networkPolicyPeerPodSelectorDoc, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: labelSelectorFields(), + }, + }, + }, + }, + }, + }, + }, + }, + "egress": { + Type: schema.TypeList, + Description: networkPolicySpecEgressDoc, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "ports": { + Type: schema.TypeList, + Description: networkPolicyEgressRulePortsDoc, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "port": { + Type: schema.TypeString, + Description: networkPolicyPortPortDoc, + Optional: true, + }, + "protocol": { + Type: schema.TypeString, + Description: networkPolicyPortProtocolDoc, + Optional: true, + Default: "TCP", + }, + }, + }, + }, + "to": { + Type: schema.TypeList, + Description: networkPolicyEgressRuleToDoc, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "ip_block": { + Type: schema.TypeList, + Description: networkPolicyPeerIpBlockDoc, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cidr": { + Type: schema.TypeString, + Description: ipBlockCidrDoc, + Optional: true, + }, + "except": { + Type: schema.TypeList, + Description: ipBlockExceptDoc, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, "namespace_selector": { Type: schema.TypeList, Description: networkPolicyPeerNamespaceSelectorDoc, @@ -110,6 +215,14 @@ func resourceKubernetesNetworkPolicy() *schema.Resource { Schema: labelSelectorFields(), }, }, + "policy_types": { + Type: schema.TypeList, + Description: networkPolicySpecPolicyTypesDoc, + Optional: true, + MaxItems: 2, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, }, }, }, diff --git a/kubernetes/resource_kubernetes_network_policy_test.go b/kubernetes/resource_kubernetes_network_policy_test.go index d791681ee4..57c3591792 100644 --- a/kubernetes/resource_kubernetes_network_policy_test.go +++ b/kubernetes/resource_kubernetes_network_policy_test.go @@ -127,10 +127,68 @@ func TestAccKubernetesNetworkPolicy_basic(t *testing.T) { resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.ports.0.protocol", "TCP"), resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.ports.1.port", "statsd"), resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.ports.1.protocol", "UDP"), - resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.#", "1"), - resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.0.namespace_selector.#", "0"), - resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.0.pod_selector.#", "1"), - resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.0.pod_selector.0.match_labels.app", "myapp"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.#", "2"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.0.ip_block.#", "1"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.0.ip_block.0.cidr", "10.0.0.0/8"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.0.ip_block.0.except.#", "2"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.0.ip_block.0.except.0", "10.0.0.0/24"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.0.ip_block.0.except.1", "10.0.1.0/24"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.0.pod_selector.#", "0"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.1.ip_block.#", "0"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.1.namespace_selector.#", "0"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.1.pod_selector.#", "1"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.1.pod_selector.0.match_labels.app", "myapp"), + ), + }, + { + Config: testAccKubernetesNetworkPolicyConfig_specModified3(name), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckKubernetesNetworkPolicyExists("kubernetes_network_policy.test", &conf), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "metadata.0.annotations.%", "0"), + testAccCheckMetaAnnotations(&conf.ObjectMeta, map[string]string{}), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "metadata.0.labels.%", "0"), + testAccCheckMetaLabels(&conf.ObjectMeta, map[string]string{}), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "metadata.0.name", name), + resource.TestCheckResourceAttrSet("kubernetes_network_policy.test", "metadata.0.generation"), + resource.TestCheckResourceAttrSet("kubernetes_network_policy.test", "metadata.0.resource_version"), + resource.TestCheckResourceAttrSet("kubernetes_network_policy.test", "metadata.0.self_link"), + resource.TestCheckResourceAttrSet("kubernetes_network_policy.test", "metadata.0.uid"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.#", "1"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.pod_selector.#", "1"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.pod_selector.0.match_expressions.#", "1"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.pod_selector.0.match_expressions.0.key", "name"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.pod_selector.0.match_expressions.0.operator", "In"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.pod_selector.0.match_expressions.0.values.#", "2"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.pod_selector.0.match_expressions.0.values.1742479128", "webfront"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.pod_selector.0.match_expressions.0.values.2902841359", "api"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.#", "1"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.ports.#", "2"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.ports.0.port", "http"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.ports.0.protocol", "TCP"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.ports.1.port", "statsd"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.ports.1.protocol", "UDP"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.#", "2"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.0.ip_block.#", "1"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.0.ip_block.0.cidr", "10.0.0.0/8"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.0.ip_block.0.except.#", "2"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.0.ip_block.0.except.0", "10.0.0.0/24"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.0.ip_block.0.except.1", "10.0.1.0/24"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.0.pod_selector.#", "0"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.1.ip_block.#", "0"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.1.namespace_selector.#", "0"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.1.pod_selector.#", "1"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.1.pod_selector.0.match_labels.app", "myapp"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.egress.#", "1"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.egress.0.ports.#", "1"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.egress.0.ports.0.port", "statsd"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.egress.0.ports.0.protocol", "UDP"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.egress.0.to.#", "1"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.egress.0.to.0.ip_block.#", "1"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.egress.0.to.0.ip_block.0.cidr", "10.0.0.0/8"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.egress.0.to.0.ip_block.0.except.#", "2"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.egress.0.to.0.ip_block.0.except.0", "10.0.0.0/24"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.egress.0.to.0.ip_block.0.except.1", "10.0.1.0/24"), + resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.egress.0.to.0.pod_selector.#", "0"), ), }, }, @@ -334,6 +392,15 @@ resource "kubernetes_network_policy" "test" { ] from = [ + { + ip_block { + cidr = "10.0.0.0/8" + except = [ + "10.0.0.0/24", + "10.0.1.0/24", + ] + } + }, { pod_selector { match_labels = { @@ -348,3 +415,81 @@ resource "kubernetes_network_policy" "test" { } `, name) } + +func testAccKubernetesNetworkPolicyConfig_specModified3(name string) string { + return fmt.Sprintf(` +resource "kubernetes_network_policy" "test" { + metadata { + name = "%s" + namespace = "default" + } + + spec { + pod_selector { + match_expressions { + key = "name" + operator = "In" + values = ["webfront", "api"] + } + } + + ingress = [ + { + ports = [ + { + port = "http" + protocol = "TCP" + }, + { + port = "statsd" + protocol = "UDP" + }, + ] + + from = [ + { + ip_block { + cidr = "10.0.0.0/8" + except = [ + "10.0.0.0/24", + "10.0.1.0/24", + ] + } + }, + { + pod_selector { + match_labels = { + app = "myapp" + } + } + }, + ] + }, + ] + + egress = [ + { + ports = [ + { + port = "statsd" + protocol = "UDP" + }, + ] + + to = [ + { + ip_block { + cidr = "10.0.0.0/8" + except = [ + "10.0.0.0/24", + "10.0.1.0/24", + ] + } + }, + ] + }, + ] + } +} + `, name) +} diff --git a/kubernetes/structure_network_policy.go b/kubernetes/structure_network_policy.go index d6180c0889..eb66aea942 100644 --- a/kubernetes/structure_network_policy.go +++ b/kubernetes/structure_network_policy.go @@ -13,11 +13,15 @@ import ( func flattenNetworkPolicySpec(in v1.NetworkPolicySpec) []interface{} { att := make(map[string]interface{}) att["ingress"] = flattenNetworkPolicyIngress(in.Ingress) + att["egress"] = flattenNetworkPolicyEgress(in.Egress) if len(in.PodSelector.MatchExpressions) > 0 || len(in.PodSelector.MatchLabels) > 0 { att["pod_selector"] = flattenLabelSelector(&in.PodSelector) } else { att["pod_selector"] = []interface{}{make(map[string]interface{})} } + if len(in.PolicyTypes) > 0 { + att["policy_types"] = in.PolicyTypes + } return []interface{}{att} } @@ -26,17 +30,32 @@ func flattenNetworkPolicyIngress(in []v1.NetworkPolicyIngressRule) []interface{} for i, ingress := range in { m := make(map[string]interface{}) if ingress.Ports != nil && len(ingress.Ports) > 0 { - m["ports"] = flattenNetworkPolicyIngressPorts(ingress.Ports) + m["ports"] = flattenNetworkPolicyPorts(ingress.Ports) } if ingress.From != nil && len(ingress.From) > 0 { - m["from"] = flattenNetworkPolicyIngressFrom(ingress.From) + m["from"] = flattenNetworkPolicyPeer(ingress.From) } att[i] = m } return att } -func flattenNetworkPolicyIngressPorts(in []v1.NetworkPolicyPort) []interface{} { +func flattenNetworkPolicyEgress(in []v1.NetworkPolicyEgressRule) []interface{} { + att := make([]interface{}, len(in), len(in)) + for i, egress := range in { + m := make(map[string]interface{}) + if egress.Ports != nil && len(egress.Ports) > 0 { + m["ports"] = flattenNetworkPolicyPorts(egress.Ports) + } + if egress.To != nil && len(egress.To) > 0 { + m["to"] = flattenNetworkPolicyPeer(egress.To) + } + att[i] = m + } + return att +} + +func flattenNetworkPolicyPorts(in []v1.NetworkPolicyPort) []interface{} { att := make([]interface{}, len(in), len(in)) for i, port := range in { m := make(map[string]interface{}) @@ -55,21 +74,35 @@ func flattenNetworkPolicyIngressPorts(in []v1.NetworkPolicyPort) []interface{} { return att } -func flattenNetworkPolicyIngressFrom(in []v1.NetworkPolicyPeer) []interface{} { +func flattenNetworkPolicyPeer(in []v1.NetworkPolicyPeer) []interface{} { att := make([]interface{}, len(in), len(in)) - for i, from := range in { + for i, peer := range in { m := make(map[string]interface{}) - if from.NamespaceSelector != nil { - m["namespace_selector"] = flattenLabelSelector(from.NamespaceSelector) + if peer.IPBlock != nil { + m["ip_block"] = flattenIPBlock(peer.IPBlock) + } + if peer.NamespaceSelector != nil { + m["namespace_selector"] = flattenLabelSelector(peer.NamespaceSelector) } - if from.PodSelector != nil { - m["pod_selector"] = flattenLabelSelector(from.PodSelector) + if peer.PodSelector != nil { + m["pod_selector"] = flattenLabelSelector(peer.PodSelector) } att[i] = m } return att } +func flattenIPBlock(in *v1.IPBlock) []interface{} { + att := make(map[string]interface{}) + if in.CIDR != "" { + att["cidr"] = in.CIDR + } + if len(in.Except) > 0 { + att["except"] = in.Except + } + return []interface{}{att} +} + // Expanders func expandNetworkPolicySpec(l []interface{}) v1.NetworkPolicySpec { @@ -92,17 +125,34 @@ func expandNetworkPolicyIngress(l []interface{}) []v1.NetworkPolicyIngressRule { in := ingress.(map[string]interface{}) obj[i] = v1.NetworkPolicyIngressRule{} if v, ok := in["ports"].([]interface{}); ok && len(v) > 0 { - obj[i].Ports = expandNetworkPolicyIngressPorts(v) + obj[i].Ports = expandNetworkPolicyPorts(v) } if v, ok := in["from"].([]interface{}); ok && len(v) > 0 { - obj[i].From = expandNetworkPolicyIngressFrom(v) + obj[i].From = expandNetworkPolicyPeer(v) } } } return obj } -func expandNetworkPolicyIngressPorts(l []interface{}) []v1.NetworkPolicyPort { +func expandNetworkPolicyEgress(l []interface{}) []v1.NetworkPolicyEgressRule { + obj := make([]v1.NetworkPolicyEgressRule, len(l), len(l)) + for i, ingress := range l { + if ingress != nil { + in := ingress.(map[string]interface{}) + obj[i] = v1.NetworkPolicyEgressRule{} + if v, ok := in["ports"].([]interface{}); ok && len(v) > 0 { + obj[i].Ports = expandNetworkPolicyPorts(v) + } + if v, ok := in["to"].([]interface{}); ok && len(v) > 0 { + obj[i].To = expandNetworkPolicyPeer(v) + } + } + } + return obj +} + +func expandNetworkPolicyPorts(l []interface{}) []v1.NetworkPolicyPort { obj := make([]v1.NetworkPolicyPort, len(l), len(l)) for i, port := range l { in := port.(map[string]interface{}) @@ -125,10 +175,13 @@ func expandNetworkPolicyIngressPorts(l []interface{}) []v1.NetworkPolicyPort { return obj } -func expandNetworkPolicyIngressFrom(l []interface{}) []v1.NetworkPolicyPeer { +func expandNetworkPolicyPeer(l []interface{}) []v1.NetworkPolicyPeer { obj := make([]v1.NetworkPolicyPeer, len(l), len(l)) - for i, from := range l { - in := from.(map[string]interface{}) + for i, peer := range l { + in := peer.(map[string]interface{}) + if v, ok := in["ip_block"].([]interface{}); ok && len(v) > 0 { + obj[i].IPBlock = expandIPBlock(v) + } if v, ok := in["namespace_selector"].([]interface{}); ok && len(v) > 0 { obj[i].NamespaceSelector = expandLabelSelector(v) } @@ -139,15 +192,54 @@ func expandNetworkPolicyIngressFrom(l []interface{}) []v1.NetworkPolicyPeer { return obj } +func expandIPBlock(l []interface{}) *v1.IPBlock { + obj := &v1.IPBlock{} + if len(l) == 0 || l[0] == nil { + return &v1.IPBlock{} + } + in := l[0].(map[string]interface{}) + if v, ok := in["cidr"].(string); ok && v != "" { + obj.CIDR = v + } + if v, ok := in["except"].([]interface{}); ok && len(v) > 0 { + obj.Except = expandStringSlice(v) + } + return obj +} + // Patchers func patchNetworkPolicySpec(keyPrefix, pathPrefix string, d *schema.ResourceData) PatchOperations { ops := make([]PatchOperation, 0, 0) if d.HasChange(keyPrefix + "ingress") { - ops = append(ops, &ReplaceOperation{ - Path: pathPrefix + "/ingress", - Value: expandNetworkPolicyIngress(d.Get(keyPrefix + "ingress").([]interface{})), - }) + oldV, _ := d.GetChange(keyPrefix + "ingress") + ingress := expandNetworkPolicyIngress(d.Get(keyPrefix + "ingress").([]interface{})) + if len(oldV.([]interface{})) == 0 { + ops = append(ops, &AddOperation{ + Path: pathPrefix + "/ingress", + Value: ingress, + }) + } else { + ops = append(ops, &ReplaceOperation{ + Path: pathPrefix + "/ingress", + Value: ingress, + }) + } + } + if d.HasChange(keyPrefix + "egress") { + oldV, _ := d.GetChange(keyPrefix + "egress") + egress := expandNetworkPolicyEgress(d.Get(keyPrefix + "egress").([]interface{})) + if len(oldV.([]interface{})) == 0 { + ops = append(ops, &AddOperation{ + Path: pathPrefix + "/egress", + Value: egress, + }) + } else { + ops = append(ops, &ReplaceOperation{ + Path: pathPrefix + "/egress", + Value: egress, + }) + } } if d.HasChange(keyPrefix + "pod_selector") { ops = append(ops, &ReplaceOperation{ @@ -155,5 +247,11 @@ func patchNetworkPolicySpec(keyPrefix, pathPrefix string, d *schema.ResourceData Value: expandLabelSelector(d.Get(keyPrefix + "pod_selector").([]interface{})), }) } + if d.HasChange(keyPrefix + "policy_types") { + ops = append(ops, &ReplaceOperation{ + Path: pathPrefix + "/policyTypes", + Value: expandStringSlice(d.Get(keyPrefix + "policy_types").([]interface{})), + }) + } return ops } diff --git a/kubernetes/structure_network_policy_test.go b/kubernetes/structure_network_policy_test.go index 6a47b8a2be..0aefec953d 100644 --- a/kubernetes/structure_network_policy_test.go +++ b/kubernetes/structure_network_policy_test.go @@ -67,7 +67,7 @@ func TestFlattenNetworkPolicyIngressPorts(t *testing.T) { } for _, tc := range cases { - output := flattenNetworkPolicyIngressPorts(tc.Input) + output := flattenNetworkPolicyPorts(tc.Input) if !reflect.DeepEqual(output, tc.ExpectedOutput) { t.Fatalf("Unexpected output from flattener.\nExpected: %#v\nGiven: %#v", tc.ExpectedOutput, output) @@ -126,7 +126,7 @@ func TestExpandNetworkPolicyIngressPorts(t *testing.T) { } for _, tc := range cases { - output := expandNetworkPolicyIngressPorts(tc.Input) + output := expandNetworkPolicyPorts(tc.Input) if !reflect.DeepEqual(output, tc.ExpectedOutput) { t.Fatalf("Unexpected output from flattener.\nExpected: %#v\nGiven: %#v", tc.ExpectedOutput, output)