diff --git a/examples/cr-console.operator.config.yaml b/examples/cr-console.operator.config.yaml new file mode 100644 index 0000000000..1042899d0e --- /dev/null +++ b/examples/cr-console.operator.config.yaml @@ -0,0 +1,16 @@ +apiVersion: operator.openshift.io/v1 +kind: Console +metadata: + name: cluster +spec: + managementState: Managed + authentication: + # the logout redirect must be a valid URI that starts with http(s) + # valid examples: http://localhost:8080/logout.html, https://www.redhat.com/log/out/ + logoutRedirect: "https://www.redhat.com/i/should/logout" + customization: + brand: okd + # the documentation base must be a valid URI that starts with http(s) AND it must have a trailing slash + # the trailing slash is required because additional values will be appended + # valid examples: https://localhost:9999/docs/, http://192.168.1.5:3000/doc/location/ + documentationBaseURL: "https://www.redhat.com/someplace/for/docs/" diff --git a/hack/test-unit.sh b/hack/test-unit.sh index d2a7814b83..025bc56cbd 100755 --- a/hack/test-unit.sh +++ b/hack/test-unit.sh @@ -26,3 +26,20 @@ do os::log::info "Testing ${PACKAGE}" go test $PACKAGE done + +OCP_PACKAGES_TO_TEST=( + "github.com/openshift/console-operator/pkg/console/subresource/configmap" + "github.com/openshift/console-operator/pkg/console/subresource/deployment" + "github.com/openshift/console-operator/pkg/console/subresource/oauthclient" + "github.com/openshift/console-operator/pkg/console/subresource/route" + "github.com/openshift/console-operator/pkg/console/subresource/secret" + "github.com/openshift/console-operator/pkg/console/subresource/service" + "github.com/openshift/console-operator/pkg/console/subresource/util" + "github.com/openshift/console-operator/pkg/console/version" +) + +for PACKAGE in "${OCP_PACKAGES_TO_TEST[@]}" +do + os::log::info "Testing with tag ocp ${PACKAGE}" + go test -tags "ocp" $PACKAGE +done diff --git a/manifests/00-crd-operator-config.yaml b/manifests/00-crd-operator-config.yaml index 30d0613d7e..e18769724d 100644 --- a/manifests/00-crd-operator-config.yaml +++ b/manifests/00-crd-operator-config.yaml @@ -13,6 +13,32 @@ spec: subresources: status: {} versions: - - name: v1 - served: true - storage: true + - name: v1 + served: true + storage: true + validation: + openAPIV3Schema: + properties: + spec: + properties: + managementState: + pattern: ^(Managed|Unmanaged|Removed|Forced)$ + type: string + description: managementState indicates whether and how the operator + should manage the component + authentication: + properties: + logoutRedirect: + pattern: ^((https):\/\/?)[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|\/?))$ + type: string + description: Logout Redirect must be a valid URL + customization: + properties: + documentationBaseURL: + pattern: ^((https):\/\/?)[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|\/?))\/$ + type: string + description: Document base URL must be a valid URL that ends in a trailing slash + brand: + pattern: ^(ocp|origin|okd|dedicated|online|azure)$ + type: string + description: Brand must be be one of six values - azure|dedicated|ocp|okd|online|origin diff --git a/pkg/console/subresource/configmap/configmap_test.go b/pkg/console/subresource/configmap/configmap_test.go index 420e9756ac..b120501002 100644 --- a/pkg/console/subresource/configmap/configmap_test.go +++ b/pkg/console/subresource/configmap/configmap_test.go @@ -27,8 +27,8 @@ clusterInfo: consoleBaseAddress: https://` + host + ` consoleBasePath: "" customization: - branding: okd - documentationBaseURL: https://docs.okd.io/4.0/ + branding: ` + DEFAULT_BRAND + ` + documentationBaseURL: ` + DEFAULT_DOC_URL + ` servingInfo: bindAddress: https://0.0.0.0:8443 certFile: /var/serving-cert/tls.crt @@ -171,8 +171,8 @@ func TestNewYamlConfig(t *testing.T) { args: args{ host: host, logoutRedirect: "", - brand: "okd", - docURL: "https://docs.okd.io/4.0/", + brand: DEFAULT_BRAND, + docURL: DEFAULT_DOC_URL, }, want: exampleYaml, },