Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 9 additions & 1 deletion pkg/istiovalues/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

package istiovalues

import v1 "github.com/istio-ecosystem/sail-operator/api/v1"
import (
v1 "github.com/istio-ecosystem/sail-operator/api/v1"

"istio.io/istio/pkg/ptr"
)

func ApplyOverrides(revisionName string, namespace string, values *v1.Values) {
// Set revision name to "" if revision name is "default". This is a temporary fix until we fix the injection
Expand All @@ -30,4 +34,8 @@ func ApplyOverrides(revisionName string, namespace string, values *v1.Values) {
values.Global = &v1.GlobalConfig{}
}
values.Global.IstioNamespace = &namespace

// Force defaultRevision to be empty to prevent creation of the default validator webhook.
// This field is deprecated and should be ignored by the operator.
values.DefaultRevision = ptr.Of("")
}
19 changes: 19 additions & 0 deletions pkg/istiovalues/overrides_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func TestApplyOverrides(t *testing.T) {
Global: &v1.GlobalConfig{
IstioNamespace: ptr.Of("ns1"),
},
DefaultRevision: ptr.Of(""),
},
},
{
Expand All @@ -53,6 +54,7 @@ func TestApplyOverrides(t *testing.T) {
Global: &v1.GlobalConfig{
IstioNamespace: ptr.Of("ns1"),
},
DefaultRevision: ptr.Of(""),
},
},
{
Expand All @@ -67,6 +69,7 @@ func TestApplyOverrides(t *testing.T) {
Global: &v1.GlobalConfig{
IstioNamespace: ptr.Of("ns1"),
},
DefaultRevision: ptr.Of(""),
},
},
{
Expand All @@ -83,6 +86,22 @@ func TestApplyOverrides(t *testing.T) {
Global: &v1.GlobalConfig{
IstioNamespace: ptr.Of("ns1"),
},
DefaultRevision: ptr.Of(""),
},
},
{
name: "defaultRevision-is-ignored-when-set-by-user",
revision: "my-revision",
namespace: "ns1",
values: v1.Values{
DefaultRevision: ptr.Of("my-revision"),
},
expectedValues: v1.Values{
Revision: ptr.Of("my-revision"),
Global: &v1.GlobalConfig{
IstioNamespace: ptr.Of("ns1"),
},
DefaultRevision: ptr.Of(""),
},
},
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/revision/values_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ spec:
Platform: ptr.Of("openshift"),
IstioNamespace: ptr.Of(namespace), // this value is always added/overridden based on IstioRevision.spec.namespace
},
Revision: ptr.Of(revisionName),
Revision: ptr.Of(revisionName),
DefaultRevision: ptr.Of(""),
}

if !reflect.DeepEqual(result, expected) {
Expand Down Expand Up @@ -123,7 +124,8 @@ spec:`)), 0o644))
Platform: ptr.Of("openshift"),
IstioNamespace: ptr.Of(namespace), // this value is always added/overridden based on IstioRevision.spec.namespace
},
Revision: ptr.Of(revisionName),
Revision: ptr.Of(revisionName),
DefaultRevision: ptr.Of(""),
}

if !reflect.DeepEqual(result, expected) {
Expand Down
17 changes: 17 additions & 0 deletions tests/integration/api/istiobase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ var _ = Describe("base chart support", Ordered, func() {
}

saKey := client.ObjectKey{Name: "istio-reader-service-account", Namespace: istioNamespace}
validatingWebhookKey := client.ObjectKey{Name: "istiod-default-validator", Namespace: istioNamespace}

BeforeAll(func() {
Step(fmt.Sprintf("Creating namespace %q", istioNamespace))
Expand Down Expand Up @@ -99,6 +100,10 @@ var _ = Describe("base chart support", Ordered, func() {
sa := &corev1.ServiceAccount{}
Step("Checking if istio-reader ServiceAccount was successfully created")
Eventually(k8sClient.Get).WithArguments(ctx, saKey, sa).Should(Succeed())

webhook := &admissionv1.ValidatingWebhookConfiguration{}
Step("Checking if default ValidatingWebhookConfiguration was successfully created")
Eventually(k8sClient.Get).WithArguments(ctx, validatingWebhookKey, webhook).Should(Succeed())
})

It("undeploys base chart when default IstioRevision is deleted", func() {
Expand All @@ -108,6 +113,10 @@ var _ = Describe("base chart support", Ordered, func() {
sa := &corev1.ServiceAccount{}
Step("Checking if istio-reader ServiceAccount was deleted")
Eventually(k8sClient.Get).WithArguments(ctx, saKey, sa).Should(ReturnNotFoundError())

webhook := &admissionv1.ValidatingWebhookConfiguration{}
Step("Checking if default ValidatingWebhookConfiguration was deleted")
Eventually(k8sClient.Get).WithArguments(ctx, validatingWebhookKey, webhook).Should(ReturnNotFoundError())
})
})

Expand Down Expand Up @@ -153,12 +162,20 @@ var _ = Describe("base chart support", Ordered, func() {
sa := &corev1.ServiceAccount{}
Step("Checking if istio-reader ServiceAccount was deleted")
Eventually(k8sClient.Get).WithArguments(ctx, saKey, sa).Should(ReturnNotFoundError())

webhook := &admissionv1.ValidatingWebhookConfiguration{}
Step("Checking if default ValidatingWebhookConfiguration was deleted")
Eventually(k8sClient.Get).WithArguments(ctx, validatingWebhookKey, webhook).Should(ReturnNotFoundError())
})

It("deploys base chart when default IstioRevisionTag is created", func() {
sa := &corev1.ServiceAccount{}
Step("Checking if istio-reader ServiceAccount was successfully created")
Eventually(k8sClient.Get).WithArguments(ctx, saKey, sa).Should(Succeed())

webhook := &admissionv1.ValidatingWebhookConfiguration{}
Step("Checking if default ValidatingWebhookConfiguration was successfully created")
Eventually(k8sClient.Get).WithArguments(ctx, validatingWebhookKey, webhook).Should(Succeed())
})
})

Expand Down