Skip to content
This repository has been archived by the owner on May 28, 2021. It is now read-only.

Commit

Permalink
Allow any version string to be used in spec
Browse files Browse the repository at this point in the history
Fixes #120 (once tagged and released as 0.1.1)
  • Loading branch information
Simon Lord committed Jun 8, 2018
1 parent 7f15250 commit 2c35780
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ USE_GLOBAL_NAMESPACE ?= false

ifdef WERCKER
# Insert swear words about mysql group replication and hostname length. Arghh..
VERSION := ${WERCKER_GIT_COMMIT}
VERSION ?= ${WERCKER_GIT_COMMIT}
TENANT := "oracle"
else
NEW_NAMESPACE ?= e2e-${USER}
Expand Down
6 changes: 6 additions & 0 deletions examples/cluster/cluster-with-custom-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: "mysql.oracle.com/v1"
kind: MySQLCluster
metadata:
name: mysql-cluster-5-7-22
spec:
version: 5.7.22-1.1.5
7 changes: 0 additions & 7 deletions pkg/apis/mysql/v1/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ const (
// ClusterCRDResourcePlural defines the custom resource name for mysqlclusters
const ClusterCRDResourcePlural = "mysqlclusters"

// TODO (owain) we need to remove this because it's not reasonable for us to maintain a list
// of all the potential MySQL versions that can be used and in reality, it shouldn't matter
// too much. The burden of this is not worth the benfit to a user
var validVersions = []string{
defaultVersion,
}

// MySQLClusterSpec defines the attributes a user can specify when creating a cluster
type MySQLClusterSpec struct {
// Version defines the MySQL Docker image version.
Expand Down
17 changes: 0 additions & 17 deletions pkg/apis/mysql/v1/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,8 @@ import (
"testing"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/validation/field"
)

func TestValidVersion(t *testing.T) {
for _, version := range validVersions {
errList := validateVersion(version, field.NewPath("spec", "version"))
if len(errList) > 0 {
t.Fail()
}
}
}

func TestInvalidVersion(t *testing.T) {
err := validateVersion("1.2.3", field.NewPath("spec", "version"))
if err == nil {
t.Fail()
}
}

func TestDefaultReplicas(t *testing.T) {
cluster := &MySQLCluster{}
cluster.EnsureDefaults()
Expand Down
12 changes: 0 additions & 12 deletions pkg/apis/mysql/v1/validate_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ func validateCluster(c *MySQLCluster) field.ErrorList {
func validateClusterSpec(s MySQLClusterSpec, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}

allErrs = append(allErrs, validateVersion(s.Version, fldPath.Child("version"))...)

return allErrs
}

Expand All @@ -39,16 +37,6 @@ func validateClusterStatus(s MySQLClusterStatus, fldPath *field.Path) field.Erro
return allErrs
}

func validateVersion(version string, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
for _, validVersion := range validVersions {
if version == validVersion {
return allErrs
}
}
return append(allErrs, field.Invalid(fldPath, version, "invalid version specified"))
}

func validatePhase(phase MySQLClusterPhase, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
for _, validPhase := range MySQLClusterValidPhases {
Expand Down
2 changes: 1 addition & 1 deletion wercker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ e2e-test:
name: e2e default tests
code: |
export KUBECONFIG="/tmp/kubeconfig"
echo -n "${KUBECONFIG_VAR}" | openssl enc -base64 -d -A > "${KUBECONFIG}"
echo -n "${KUBECONFIG_V0_1_VAR}" | openssl enc -base64 -d -A > "${KUBECONFIG}"
ginkgo -nodes=4 -v test/e2e -- \
--kubeconfig="${KUBECONFIG}" \
--operator-version="$(cat dist/version.txt)" \
Expand Down

0 comments on commit 2c35780

Please sign in to comment.