-
Notifications
You must be signed in to change notification settings - Fork 976
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
Make attribute ingress_class_name
of resource kubernetes_ingress_v1
computed
#1947
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:enhancement | ||
`resource/kubernetes_ingress_v1`: make the attribute `spec.ingress_class_name` computed | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,21 +185,6 @@ func TestAccKubernetesIngress_WaitForLoadBalancerGoogleCloud(t *testing.T) { | |
}) | ||
} | ||
|
||
func testAccCheckKubernetesIngressForceNew(old, new *api.Ingress, wantNew bool) resource.TestCheckFunc { | ||
return func(s *terraform.State) error { | ||
if wantNew { | ||
if old.ObjectMeta.UID == new.ObjectMeta.UID { | ||
return fmt.Errorf("Expecting new resource for Ingress %s", old.ObjectMeta.UID) | ||
} | ||
} else { | ||
if old.ObjectMeta.UID != new.ObjectMeta.UID { | ||
return fmt.Errorf("Expecting Ingress UIDs to be the same: expected %s got %s", old.ObjectMeta.UID, new.ObjectMeta.UID) | ||
} | ||
} | ||
return nil | ||
} | ||
} | ||
|
||
func testAccCheckKubernetesIngressDestroy(s *terraform.State) error { | ||
conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() | ||
|
||
|
@@ -452,47 +437,3 @@ resource "kubernetes_ingress" "test" { | |
wait_for_load_balancer = true | ||
}`, name, name, name, name, name, name, name) | ||
} | ||
|
||
func testAccKubernetesIngressConfig_stateUpgradev0(provider, name string) string { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not related to the original issue, just noticed that it is not in use, and since I touched this file, I cleaned it up a bit. |
||
return fmt.Sprintf(`resource "kubernetes_service" "test" { | ||
provider = "%s" | ||
metadata { | ||
name = "%s" | ||
} | ||
spec { | ||
port { | ||
port = 80 | ||
target_port = 80 | ||
protocol = "TCP" | ||
} | ||
type = "NodePort" | ||
} | ||
} | ||
|
||
resource "kubernetes_ingress" "test" { | ||
provider = "%s" | ||
wait_for_load_balancer = false | ||
metadata { | ||
name = "%s" | ||
annotations = { | ||
"kubernetes.io/ingress.class" = "alb" | ||
"alb.ingress.kubernetes.io/scheme" = "internet-facing" | ||
"alb.ingress.kubernetes.io/target-type" = "ip" | ||
} | ||
} | ||
spec { | ||
rule { | ||
http { | ||
path { | ||
path = "/*" | ||
backend { | ||
service_name = kubernetes_service.test.metadata.0.name | ||
service_port = 80 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`, provider, name, provider, name) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -310,19 +310,33 @@ func TestAccKubernetesIngressV1_multipleRulesDifferentHosts(t *testing.T) { | |
}) | ||
} | ||
|
||
func testAccCheckKubernetesIngressV1ForceNew(old, new *networking.Ingress, wantNew bool) resource.TestCheckFunc { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not related to the original issue, just noticed that it is not in use, and since I touched this file, I cleaned it up a bit. |
||
return func(s *terraform.State) error { | ||
if wantNew { | ||
if old.ObjectMeta.UID == new.ObjectMeta.UID { | ||
return fmt.Errorf("Expecting new resource for Ingress %s", old.ObjectMeta.UID) | ||
} | ||
} else { | ||
if old.ObjectMeta.UID != new.ObjectMeta.UID { | ||
return fmt.Errorf("Expecting Ingress UIDs to be the same: expected %s got %s", old.ObjectMeta.UID, new.ObjectMeta.UID) | ||
} | ||
} | ||
return nil | ||
} | ||
func TestAccKubernetesIngressV1_defaultIngressClass(t *testing.T) { | ||
var conf networking.Ingress | ||
name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) | ||
ingressClass := "default-ingress-class" | ||
resourceName := "kubernetes_ingress_v1.test" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { | ||
testAccPreCheck(t) | ||
skipIfClusterVersionLessThan(t, "1.22.0") | ||
}, | ||
IDRefreshName: resourceName, | ||
IDRefreshIgnore: []string{"metadata.0.resource_version"}, | ||
ProviderFactories: testAccProviderFactories, | ||
CheckDestroy: testAccCheckKubernetesIngressV1Destroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccKubernetesIngressV1Config_defaultIngressClass(ingressClass, name), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
testAccCheckKubernetesIngressV1Exists(resourceName, &conf), | ||
resource.TestCheckResourceAttr(resourceName, "metadata.0.name", name), | ||
resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), | ||
resource.TestCheckResourceAttr(resourceName, "spec.0.ingress_class_name", "default-ingress-class"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCheckKubernetesIngressV1Destroy(s *terraform.State) error { | ||
|
@@ -724,3 +738,45 @@ func testAccKubernetesIngressV1Config_multipleRulesDifferentHosts(name string) s | |
} | ||
}`, name) | ||
} | ||
|
||
func testAccKubernetesIngressV1Config_defaultIngressClass(ingressClass, name string) string { | ||
return fmt.Sprintf(`resource "kubernetes_ingress_class_v1" "test" { | ||
metadata { | ||
name = "%s" | ||
labels = { | ||
"app.kubernetes.io/component" = "controller" | ||
} | ||
annotations = { | ||
"ingressclass.kubernetes.io/is-default-class" = "true" | ||
} | ||
} | ||
spec { | ||
controller = "k8s.io/ingress-nginx" | ||
} | ||
} | ||
|
||
resource "kubernetes_ingress_v1" "test" { | ||
metadata { | ||
name = "%s" | ||
} | ||
spec { | ||
rule { | ||
host = "server.domain.com" | ||
http { | ||
path { | ||
backend { | ||
service { | ||
name = "app1" | ||
port { | ||
number = 8080 | ||
} | ||
} | ||
} | ||
path = "/app1/*" | ||
} | ||
} | ||
} | ||
} | ||
depends_on = ["kubernetes_ingress_class_v1.test"] | ||
}`, ingressClass, name) | ||
} |
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.
Not related to the original issue, just noticed that it is not in use, and since I touched this file, I cleaned it up a bit.