Skip to content

Commit

Permalink
Merge pull request #809 from Tanemahuta/issue/808
Browse files Browse the repository at this point in the history
Fix #808
  • Loading branch information
Laci21 authored Jan 24, 2022
2 parents 1a623b5 + fb96fba commit d1a174a
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 12 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha1/istiocontrolplane.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/v1alpha1/istiocontrolplane.pb.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h2 id="IstioControlPlaneSpec">IstioControlPlaneSpec</h2>
<td><code>string</code></td>
<td>
<p>Contains the intended version for the Istio control plane.
+kubebuilder:validation:Pattern=^1.</p>
+kubebuilder:validation:Pattern=^1\.</p>

</td>
<td>
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/istiocontrolplane.proto
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ option go_package = "github.com/banzaicloud/istio-operator/v2/api/v1alpha1";
// -->
message IstioControlPlaneSpec {
// Contains the intended version for the Istio control plane.
// +kubebuilder:validation:Pattern=^1.
// +kubebuilder:validation:Pattern=^1\.
string version = 1 [(google.api.field_behavior) = REQUIRED];
// Configure the mode for this control plane.
// Currently, two options are supported: "ACTIVE" and "PASSIVE".
Expand Down
4 changes: 2 additions & 2 deletions config/crd/bases/istio-operator-crds.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6379,7 +6379,7 @@ spec:
type: boolean
type: object
version:
pattern: ^1.
pattern: ^1\.
type: string
watchOneNamespace:
nullable: true
Expand Down Expand Up @@ -13704,7 +13704,7 @@ spec:
type: boolean
type: object
version:
pattern: ^1.
pattern: ^1\.
type: string
watchOneNamespace:
nullable: true
Expand Down
2 changes: 1 addition & 1 deletion controllers/istiocontrolplane_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (r *IstioControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.Re
}, nil
}

if !isIstioVersionSupported(icp.Spec.Version) {
if !IsIstioVersionSupported(icp.Spec.Version) {
err = errors.New("intended Istio version is unsupported by this version of the operator")
logger.Error(err, "", "version", icp.Spec.Version)

Expand Down
2 changes: 1 addition & 1 deletion controllers/meshgateway_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (r *IstioMeshGatewayReconciler) Reconcile(ctx context.Context, req ctrl.Req
return ctrl.Result{}, err
}

if !isIstioVersionSupported(icp.Spec.Version) {
if !IsIstioVersionSupported(icp.Spec.Version) {
return ctrl.Result{}, nil
}

Expand Down
4 changes: 2 additions & 2 deletions controllers/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ package controllers
import "regexp"

const (
supportedIstioMinorVersionRegex = "^1.11"
supportedIstioMinorVersionRegex = "^1\\.11(\\.[0-9]+)?(-.+)?$"
)

func isIstioVersionSupported(version string) bool {
func IsIstioVersionSupported(version string) bool {
re, _ := regexp.Compile(supportedIstioMinorVersionRegex)

return re.Match([]byte(version))
Expand Down
28 changes: 28 additions & 0 deletions controllers/version_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package controllers_test

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

"github.com/banzaicloud/istio-operator/v2/controllers"
)

var _ = Describe("IsIstioVersionSupported()", func() {
It("should deny unsupported versions", func() {
for _, version := range []string{"2.11", "2.11.1", "2.11.1-dev", "1.12", "1.12.1", "1.12.1-dev"} {
Expect(controllers.IsIstioVersionSupported(version)).To(BeFalse(), "invalid: "+version)
}
})
It("should accept all 1.11 versions", func() {
Expect(controllers.IsIstioVersionSupported("1.11")).To(BeTrue())
})
It("should accept all 1.11 versions with qualifier", func() {
Expect(controllers.IsIstioVersionSupported("1.11-dev")).To(BeTrue())
})
It("should accept micro versions", func() {
Expect(controllers.IsIstioVersionSupported("1.11.1")).To(BeTrue())
})
It("should accept micro versions with qualifier", func() {
Expect(controllers.IsIstioVersionSupported("1.11.1-dev")).To(BeTrue())
})
})
2 changes: 1 addition & 1 deletion deploy/charts/istio-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ icon: https://istio.io/latest/img/istio-whitelogo-bluebackground-framed.svg
# Based on support status of Istio releases: https://istio.io/latest/docs/releases/supported-releases/#support-status-of-istio-releases
kubeVersion: ">= 1.19.0-0 < 1.23.0-0"

version: 2.0.5
version: 2.0.6
appVersion: "v2.11.5"
Original file line number Diff line number Diff line change
Expand Up @@ -6379,7 +6379,7 @@ spec:
type: boolean
type: object
version:
pattern: ^1.
pattern: ^1\.
type: string
watchOneNamespace:
nullable: true
Expand Down Expand Up @@ -13704,7 +13704,7 @@ spec:
type: boolean
type: object
version:
pattern: ^1.
pattern: ^1\.
type: string
watchOneNamespace:
nullable: true
Expand Down

0 comments on commit d1a174a

Please sign in to comment.