Skip to content

Commit

Permalink
Fix network policy ingress pod selector update
Browse files Browse the repository at this point in the history
  • Loading branch information
pdecat committed Apr 18, 2018
1 parent eb8a11d commit 8c54c42
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions kubernetes/resource_kubernetes_network_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ func TestAccKubernetesNetworkPolicy_basic(t *testing.T) {
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.#", "1"),
resource.TestCheckResourceAttr("kubernetes_network_policy.test", "spec.0.ingress.0.from.0.namespace_selector.0.match_labels.name", "default"),
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.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"),
),
},
},
Expand Down Expand Up @@ -335,9 +335,9 @@ resource "kubernetes_network_policy" "test" {
from = [
{
namespace_selector {
pod_selector {
match_labels = {
name = "default"
app = "myapp"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/structure_network_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func expandNetworkPolicyIngressFrom(l []interface{}) []v1.NetworkPolicyPeer {
obj[i].NamespaceSelector = expandLabelSelector(v)
}
if v, ok := in["pod_selector"].([]interface{}); ok && len(v) > 0 {
obj[i].NamespaceSelector = expandLabelSelector(v)
obj[i].PodSelector = expandLabelSelector(v)
}
}
return obj
Expand Down

0 comments on commit 8c54c42

Please sign in to comment.