diff --git a/.travis.yml b/.travis.yml index 84db1a7369..face095681 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,9 +24,9 @@ notifications: install: - make generate-verify - - make docker - make manifests - make olm-verify + - make docker - make apidocs before_script: diff --git a/Makefile b/Makefile index e082b3a974..d3adb49363 100644 --- a/Makefile +++ b/Makefile @@ -12,15 +12,15 @@ #See the License for the specific language governing permissions and #limitations under the License. -.PHONY: build build-controller build-importer build-cloner build-apiserver build-uploadproxy build-uploadserver build-operator build-functest-file-image-init build-functest-registry-image-init build-functest \ - docker docker-controller docker-cloner docker-importer docker-apiserver docker-uploadproxy docker-uploadserver docker-operator docker-functest-image-init docker-functest-image-http docker-functest-registry-populate docker-functest-registry docker-functest-registry-init \ - cluster-up cluster-down cluster-sync cluster-sync-controller cluster-sync-cloner cluster-sync-importer cluster-sync-apiserver cluster-sync-uploadproxy cluster-sync-uploadserver \ +.PHONY: build build-controller build-importer build-cloner build-apiserver build-uploadproxy build-uploadserver build-operator build-functest-file-image-init build-functest-registry-image-init build-functest \ + manifests \ olm-verify olm-push \ + docker docker-controller docker-cloner docker-importer docker-apiserver docker-uploadproxy docker-uploadserver docker-operator docker-functest-image-init docker-functest-image-http docker-functest-registry-populate docker-functest-registry docker-functest-registry-init docker-olm-catalog \ + cluster-up cluster-down cluster-sync cluster-sync-controller cluster-sync-cloner cluster-sync-importer cluster-sync-apiserver cluster-sync-uploadproxy cluster-sync-uploadserver \ test test-functional test-unit test-lint \ publish \ vet \ format \ - manifests \ goveralls \ release-description @@ -49,7 +49,7 @@ apidocs: ${DO} "./hack/update-codegen.sh && ./hack/gen-swagger-doc/gen-swagger-docs.sh v1alpha1 html" build: - ${DO} "./hack/build/build-go.sh clean && ./hack/build/build-go.sh build ${WHAT} && ./hack/build/build-cdi-func-test-file-host.sh && ./hack/build/build-cdi-func-test-registry-host.sh && DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} VERBOSITY=${VERBOSITY} PULL_POLICY=${PULL_POLICY} QUAY_NAMESPACE=${QUAY_NAMESPACE} QUAY_REPOSITORY=${QUAY_REPOSITORY} CSV_VERSION=${CSV_VERSION} ./hack/build/build-manifests.sh ${WHAT} && ./hack/build/build-copy-artifacts.sh ${WHAT}" + ${DO} "DOCKER_REPO=${DOCKER_REPO} DOCKER_TAG=${DOCKER_TAG} VERBOSITY=${VERBOSITY} PULL_POLICY=${PULL_POLICY} QUAY_NAMESPACE=${QUAY_NAMESPACE} QUAY_REPOSITORY=${QUAY_REPOSITORY} CSV_VERSION=${CSV_VERSION} ./hack/build/build-go.sh clean && ./hack/build/build-go.sh build ${WHAT} && ./hack/build/build-cdi-func-test-file-host.sh && ./hack/build/build-cdi-func-test-registry-host.sh && ./hack/build/build-cdi-olm-catalog.sh && ./hack/build/build-copy-artifacts.sh ${WHAT}" build-controller: WHAT = cmd/cdi-controller build-controller: build @@ -65,6 +65,8 @@ build-cloner: WHAT = cmd/cdi-cloner build-cloner: build build-operator: WHAT = cmd/cdi-operator build-operator: build +#build-cdi-olm-catalog: WHAT = tools/cdi-olm-catalog +#build-cdi-olm-catalog: build-functest-file-image-init: WHAT = tools/cdi-func-test-file-host-init build-functest-file-image-init: build-functest-registry-image-init: WHAT= tools/cdi-func-test-registry-init @@ -106,7 +108,10 @@ docker-uploadserver: WHAT = cmd/cdi-uploadserver docker-uploadserver: docker docker-operator: WHAT = cmd/cdi-operator docker-operator: docker -docker-functest-images: docker-functest-image-http docker-functest-image-init docker-functest-registry-init docker-functest-registry-populate docker-functest-registry +docker-olm-catalog: WHAT = tools/cdi-olm-catalog +docker-olm-catalog: + ${DO} "./hack/build/build-cdi-olm-catalog.sh && ./hack/build/build-docker.sh build ${WHAT}" +docker-functest-images: docker-functest-image-http docker-functest-image-init docker-functest-registry-init docker-functest-registry-populate docker-functest-registry docker-functest-block-device docker-olm-catalog docker-functest-image-init: WHAT = tools/cdi-func-test-file-host-init docker-functest-image-init: docker docker-functest-image-http: WHAT = tools/cdi-func-test-file-host-http diff --git a/cluster-sync/ephemeral_provider.sh b/cluster-sync/ephemeral_provider.sh index dc79811c4c..4503498020 100644 --- a/cluster-sync/ephemeral_provider.sh +++ b/cluster-sync/ephemeral_provider.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash set -e +source cluster-sync/install.sh + function seed_images(){ container="" container_alias="" @@ -30,4 +32,4 @@ function verify() { function configure_local_storage() { echo "Local storage already configured ..." -} \ No newline at end of file +} diff --git a/cluster-sync/external/install.sh b/cluster-sync/external/install.sh new file mode 100644 index 0000000000..2d80c0634e --- /dev/null +++ b/cluster-sync/external/install.sh @@ -0,0 +1 @@ +CDI_INISTALL=${CDI_INSTALL_OPERATOR} diff --git a/cluster-sync/external/provider.sh b/cluster-sync/external/provider.sh index 4d93d8bf8e..3c679a0430 100644 --- a/cluster-sync/external/provider.sh +++ b/cluster-sync/external/provider.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +source cluster-sync/install.sh + function _kubectl(){ kubectl "$@" } @@ -19,4 +21,6 @@ function up() { function configure_local_storage() { echo "Local storage not needed for external provider..." -} \ No newline at end of file +} + + diff --git a/cluster-sync/install.sh b/cluster-sync/install.sh new file mode 100644 index 0000000000..eecac92055 --- /dev/null +++ b/cluster-sync/install.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +set -e +source ./cluster-sync/${KUBEVIRT_PROVIDER}/install.sh + +function install_cdi_olm { + #Install CDI via OLM + _kubectl create ns $NAMESPACE + _kubectl apply -f _out/manifests/release/olm/operatorgroup.yaml + _kubectl apply -f _out/manifests/release/olm/k8s/cdi-catalogsource-registry.yaml + _kubectl apply -f _out/manifests/release/olm/k8s/cdi-subscription.yaml +} + +function install_cdi_operator { + _kubectl apply -f "./_out/manifests/release/cdi-operator.yaml" +} + + +function install_cdi { + case "${CDI_INSTALL}" in + "${CDI_INSTALL_OPERATOR}") + install_cdi_operator + ;; + "${CDI_INSTALL_OLM}") + install_cdi_olm + ;; + esac +} + + +function wait_cdi_crd_installed { + timeout=$1 + crd_defined=0 + while [ $crd_defined -eq 0 ] && [ $timeout > 0 ]; do + crd_defined=$(_kubectl get customresourcedefinition| grep cdis.cdi.kubevirt.io | wc -l) + sleep 1 + timeout=timeout-1 + done + + #In case CDI crd is not defined after 120s - throw error + if [ $timeout \< 1 ]; then + echo "ERROR - CDI CRD is not defined after timeout" + exit 1 + fi + +} + diff --git a/cluster-sync/k8s-1.13.3/install.sh b/cluster-sync/k8s-1.13.3/install.sh new file mode 100644 index 0000000000..1d169f6da0 --- /dev/null +++ b/cluster-sync/k8s-1.13.3/install.sh @@ -0,0 +1 @@ +CDI_INSTALL=${CDI_INSTALL_OPERATOR} diff --git a/cluster-sync/k8s-1.13.3/provider.sh b/cluster-sync/k8s-1.13.3/provider.sh index dd1f3f7604..83c38bc486 100644 --- a/cluster-sync/k8s-1.13.3/provider.sh +++ b/cluster-sync/k8s-1.13.3/provider.sh @@ -9,3 +9,5 @@ re='^-?[0-9]+$' if ! [[ $num_nodes =~ $re ]] || [[ $num_nodes -lt 1 ]] ; then num_nodes=1 fi + + diff --git a/cluster-sync/okd-4.1.2/install.sh b/cluster-sync/okd-4.1.2/install.sh new file mode 100644 index 0000000000..e46d84788d --- /dev/null +++ b/cluster-sync/okd-4.1.2/install.sh @@ -0,0 +1 @@ +CDI_INSTALL=${CDI_INSTALL_OLM} diff --git a/cluster-sync/okd-4.1.2/provider.sh b/cluster-sync/okd-4.1.2/provider.sh index bfd8dbc389..fee0638cd9 100644 --- a/cluster-sync/okd-4.1.2/provider.sh +++ b/cluster-sync/okd-4.1.2/provider.sh @@ -47,3 +47,4 @@ function configure_local_storage() { set -e fi } + diff --git a/cluster-sync/os-3.11.0-crio/install.sh b/cluster-sync/os-3.11.0-crio/install.sh new file mode 100644 index 0000000000..1d169f6da0 --- /dev/null +++ b/cluster-sync/os-3.11.0-crio/install.sh @@ -0,0 +1 @@ +CDI_INSTALL=${CDI_INSTALL_OPERATOR} diff --git a/cluster-sync/os-3.11.0-crio/provider.sh b/cluster-sync/os-3.11.0-crio/provider.sh index dd1f3f7604..4f3f0427a8 100644 --- a/cluster-sync/os-3.11.0-crio/provider.sh +++ b/cluster-sync/os-3.11.0-crio/provider.sh @@ -9,3 +9,6 @@ re='^-?[0-9]+$' if ! [[ $num_nodes =~ $re ]] || [[ $num_nodes -lt 1 ]] ; then num_nodes=1 fi + + + diff --git a/cluster-sync/sync.sh b/cluster-sync/sync.sh index 33174d817a..2b4b356b9c 100755 --- a/cluster-sync/sync.sh +++ b/cluster-sync/sync.sh @@ -28,21 +28,27 @@ if [ "${KUBEVIRT_PROVIDER}" != "external" ]; then registry=${IMAGE_REGISTRY:-localhost:$(_port registry)} DOCKER_PREFIX=${registry} MANIFEST_REGISTRY="registry:5000" + QUAY_NAMESPACE="none" fi # Need to set the DOCKER_PREFIX appropriately in the call to `make docker push`, otherwise make will just pass in the default `kubevirt` +QUAY_NAMESPACE=$QUAY_NAMESPACE DOCKER_PREFIX=$MANIFEST_REGISTRY PULL_POLICY=$(getTestPullPolicy) make manifests DOCKER_PREFIX=$DOCKER_PREFIX make docker push -DOCKER_PREFIX=$MANIFEST_REGISTRY PULL_POLICY=$(getTestPullPolicy) make manifests seed_images configure_local_storage # Install CDI -_kubectl apply -f "./_out/manifests/release/cdi-operator.yaml" +install_cdi + +#wait cdi crd is installed with timeout +wait_cdi_crd_installed $CDI_INSTALL_TIMEOUT + _kubectl apply -f "./_out/manifests/release/cdi-cr.yaml" _kubectl wait cdis.cdi.kubevirt.io/cdi --for=condition=running --timeout=120s + # Start functional test HTTP server. # We skip the functional test additions for external provider for now, as they're specific if [ "${KUBEVIRT_PROVIDER}" != "external" ]; then diff --git a/cluster-up/hack/common.sh b/cluster-up/hack/common.sh index 5fffb80b99..c5a72b748d 100644 --- a/cluster-up/hack/common.sh +++ b/cluster-up/hack/common.sh @@ -15,6 +15,11 @@ if [ -z "$KUBEVIRTCI_CONFIG_PATH" ]; then )" fi +CDI_INSTALL_OPERATOR="install-operator" +CDI_INSTALL_OLM="install-olm" +CDI_INSTALL=${CDI_INSTALL:-${CDI_INSTALL_OPERATOR}} +CDI_INSTALL_TIMEOUT=${CDI_INSTALL_TIMEOUT:-120} + KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER:-k8s-1.13.3} KUBEVIRT_NUM_NODES=${KUBEVIRT_NUM_NODES:-1} KUBEVIRT_MEMORY_SIZE=${KUBEVIRT_MEMORY_SIZE:-5120M} diff --git a/doc/cdi-operator-olm.md b/doc/cdi-operator-olm.md index 7b00438d7a..782e42e582 100644 --- a/doc/cdi-operator-olm.md +++ b/doc/cdi-operator-olm.md @@ -1,4 +1,4 @@ -# OLM (Operator Lifecycle Management) CDI (Containerized Data Importer) intergartion +# OLM (Operator Lifecycle Management) CDI (Containerized Data Importer) integration ## Table of Contents * [OLM Overview](#overview) @@ -17,6 +17,7 @@ https://github.com/kubevirt/kubevirt/blob/master/docs/devel/olm-integration.md | ------------- |:-------------|:--------------| | _OperatorSource_ | Is used to define the external datastore we are using to store operator bundles |https://github.com/operator-framework/operator-marketplace/blob/master/README.md| | _CatalogSourceConfig_ | Is used to enable an operator present in the _OperatorSource_ to your cluster. Behind the scenes, it will configure an OLM CatalogSource so that the operator can then be managed by OLM. | https://github.com/operator-framework/operator-marketplace/blob/master/README.md| +| _operator-registry_ | Operator Registry runs in a Kubernetes or OpenShift cluster to provide operator catalog data to Operator Lifecycle Manager. | https://github.com/operator-framework/operator-registry| | _Subscription_ | Monitors CatalogSource for updates | https://github.com/operator-framework/operator-lifecycle-manager/tree/274df58592c2ffd1d8ea56156c73c7746f57efc0#discovery-catalogs-and-automated-upgrades | | _OperatorGroup_ | An OperatorGroup is an OLM resource that provides rudimentary multitenant configuration to OLM installed operators. | https://github.com/operator-framework/operator-lifecycle-manager/blob/master/Documentation/design/operatorgroups.md| @@ -114,7 +115,7 @@ cluster/kubectl.sh apply -f _out/manifests/release/cdi-cr.yaml Now CDI deployment should finish its deployment successfully #### k8s cluster -- Install CDI operatorsource manifest that specifies the location of CDI OLM bundle in quay +- Install CDI operatorsource manifest that specifies the location of CDI OLM bundle in quay. **Vocabulary**: _OperatorSource_ is used to define the external datastore we are using to store operator bundles ```bash kubectl apply -f _out/manifests/release/olm/k8s/cdi-operatorsource.yaml @@ -127,7 +128,7 @@ kubectl create ns cdi ```bash kubectl apply -f _out/manifests/release/olm/operatorgroup.yaml ``` -- Install CatalogSourceConfig resource +- Install CatalogSourceConfig resource. **Vocabulary**: _CatalogSourceConfig_ is used to enable an operator present in the _OperatorSource_ to your cluster. Behind the scenes, it will configure an OLM CatalogSource so that the operator can then be managed by OLM. ```bash kubectl create --save-config -f _out/manifests/release/olm/k8s/cdi-catalogsource.yaml @@ -152,6 +153,129 @@ cluster/kubectl.sh apply -f _out/manifests/release/cdi-cr.yaml ``` Now the operator should finish its deployment successfully + +### CDI Installation via OLM with operator-registry +It is possible to deploy operator via OLM without marketplace operator. Marketplace operator is required in order to fetch OLM bundle from the specified quay repo. Operator framework provides a way to create _CatalogSource_ with manifests without hosting them in quay. This functionlaity is introduced in operator-registry https://github.com/operator-framework/operator-registry + +In order to deploy operator-registry a _CatalogSource_ manifest has to reference a container image that is based on _quay.io/openshift/origin-operator-registry_ and has operator OLM manifests under /registry directory. + +#####Example of Dockerfile +``` +> cat Dockerfile +FROM quay.io/openshift/origin-operator-registry + +COPY olm-catalog /registry + +# Initialize the database +RUN initializer --manifests /registry --output bundles.db + +# There are multiple binaries in the origin-operator-registry +# We want the registry-server +ENTRYPOINT ["registry-server"] +CMD ["--database", "bundles.db"] + +``` +#####Example of CatalogSource +``` +apiVersion: operators.coreos.com/v1alpha1 +kind: CatalogSource +metadata: + name: cdi-operatorhub + namespace: cdi +spec: + sourceType: grpc + image: docker.io/kubevirt/cdi-olm-catalog:latest + displayName: KubeVirt CDI + publisher: Red Hat + +``` + +Once such _CatalogSource_ is deployed, it provides operartor's OLM manifests via grpc interface and can be consumed by OLM subscription mechanism. + +#### OKD4.x cluster +- Generate CDI OLM manifests +- Create operator-registry container image +``` +CSV_VERSION= DOCKER_REPO= DOCKER_TAG= make docker-olm-catalog +``` +- Push operator-registry container image to dockerhub +``` +docker push DOCKER_REPO/cdi-olm-catalog:DOCKER_TAG +``` +- Create CDI namespace +```bash +kubectl create ns cdi +``` +- Configure namespace to be allowed to create operators there +```bash +kubectl apply -f _out/manifests/release/olm/operatorgroup.yaml +``` +- Install catalogsourceconfig that refers to the created operator-registry container image +```bash +kubectl apply -f _out/manifests/release/olm/os/cdi-catalogsource-registry.yaml +``` +- Install subscription that will point from which channel the app is downloaded +```bash +kubectl apply -f _out/manifests/release/olm/os/cdi-subscription.yaml +``` +- Verify CDI installation plan was created +```bash +kubectl get operatorsource,catalogsourceconfig,catalogsource,subscription,installplan -n cdi +NAME PACKAGE SOURCE CHANNEL +subscription.operators.coreos.com/cdi cdi cdi beta + +NAME CSV SOURCE APPROVAL APPROVED +installplan.operators.coreos.com/install-995l9 cdioperator.0.0.0 Automatic true + +``` +- Now cdi-operator starts running but in to install CDI we need to deploy cdi cr +```bash +cluster/kubectl.sh apply -f _out/manifests/release/cdi-cr.yaml +``` +Now CDI deployment should finish its deployment successfully + +#### k8s cluster +- Generate CDI OLM manifests +- Create operator-registry container image +``` +CSV_VERSION= DOCKER_REPO= DOCKER_TAG= make docker-olm-catalog +``` +- Push operator-registry container image to dockerhub +``` +docker push DOCKER_REPO/cdi-olm-catalog:DOCKER_TAG +``` +- Create CDI namespace +```bash +kubectl create ns cdi +``` +- Configure namespace to be allowed to create operators there +```bash +kubectl apply -f _out/manifests/release/olm/operatorgroup.yaml +``` +- Install _CatalogSource_ that refers to the created operator-registry container image +```bash +kubectl apply -f _out/manifests/release/olm/k8s/cdi-catalogsource-registry.yaml +``` +- Install subscription that will point from which channel the app is downloaded +```bash +kubectl apply -f _out/manifests/release/olm/k8s/cdi-subscription.yaml +``` +- Verify CDI installation plan was created +```bash +kubectl get operatorsource,catalogsourceconfig,catalogsource,subscription,installplan -n cdi +NAME PACKAGE SOURCE CHANNEL +subscription.operators.coreos.com/cdi cdi cdi beta + +NAME CSV SOURCE APPROVAL APPROVED +installplan.operators.coreos.com/install-995l9 cdioperator.0.0.0 Automatic true + +``` +- Now cdi-operator starts running but in order for it to succeed we need to deploy cdi cr +```bash +cluster/kubectl.sh apply -f _out/manifests/release/cdi-cr.yaml +``` +Now the operator should finish its deployment successfully + ### CDI OLM update OLM mechanism supports operator update via subscription mechanism. Once subscription manifest is installed on cluster, it monitors the catalog source. CatalogSource in its turn monitors the location in quay and when new OLM bundle appears, OLM can trigger update of the operator. @@ -172,6 +296,8 @@ DOCKER_REPO= DOCKER_TAG= PULL_POLICY= VERBOSITY=< ```bash QUAY_NAMESPACE= QUAY_REPOSITORY= QUAY_USERNAME= QUAY_PASSWORD= CSV_VERSION= make olm-push ``` + + ### OKD UI - Grant cluster-admin permissions to kube-system:default diff --git a/glide.lock b/glide.lock index 3ce9b78eb7..c27113e11f 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ -hash: 0e72fc1b3276effcddfeddfcadb0245b25448a0a02997e38eb6be6f3296cb0f4 -updated: 2019-06-26T17:11:00.363299177Z +hash: 3b7f147f88ea81ed85e278d641744b9540e6a601f9872e5151f488299bbaa167 +updated: 2019-06-27T09:01:47.768925038Z imports: - name: github.com/appscode/jsonpatch version: e8422f09d27ee2c8cfb2c7f8089eb9eeb0764849 @@ -9,6 +9,8 @@ imports: version: 3ac7bf7a47d159a033b107610db8a1b6575507a4 subpackages: - quantile +- name: github.com/blang/semver + version: 1a9109f8c4a1d669a78442f567dfe8eedf982793 - name: github.com/davecgh/go-spew version: 782f4967f2dc4564575ca782fe2d04090b5faca8 subpackages: @@ -222,6 +224,12 @@ imports: - appregistry/info - appregistry/package_appr - models +- name: github.com/operator-framework/operator-lifecycle-manager + version: 73c00f855607f246bfb413566bff78e404eb8302 + subpackages: + - pkg/api/apis/operators + - pkg/api/apis/operators/v1alpha1 + - pkg/lib/version - name: github.com/operator-framework/operator-marketplace version: 1cbd326243493ff9ec589a542fa335fdc84dc3e7 subpackages: diff --git a/glide.yaml b/glide.yaml index 6b2ee20ae0..b6d9a8d841 100644 --- a/glide.yaml +++ b/glide.yaml @@ -5,6 +5,10 @@ import: subpackages: - pkg/appregistry version: 1cbd326243493ff9ec589a542fa335fdc84dc3e7 +- package: github.com/operator-framework/operator-lifecycle-manager + subpackages: + - pkg/api/apis/operators/v1alpha1 + version: 73c00f855607f246bfb413566bff78e404eb8302 - package: github.com/gorilla/mux version: ^1.6.1 - package: github.com/minio/minio-go diff --git a/hack/README.md b/hack/README.md index 0e9c615c5f..c2121e7fa8 100644 --- a/hack/README.md +++ b/hack/README.md @@ -71,7 +71,8 @@ The standard workflow is performed inside a helper container to normalize the bu - `docker-uploadproxy`: compile cdi-uploadproxy and build cdi-uploadproxy image - `docker-uploadserver`: compile cdi-uploadserver and build cdi-uploadserver image - `docker-operator`: compile cdi-operator and build cdi-operator image - - `docker-registry-cleanup`: remove all images of specifed repo from local docker registry. if not specified removes from localhost repo of current cluster instance. Accepts [make variables](#make-variables) DOCKER_PREFIX. + - `docker-olm-catalog`: pack OLM bundles in dedicated directories under olm-catalog and build olm-catalog-registry container image. Accepts [make variables](#make-variables) QUAY_NAMESPACE, QUAY_REPOSITORY, CSV_VERSION. + - `docker-registry-cleanup`: remove all images of specifed repo from local docker registry. if not specified removes from localhost repo of current cluster instance. Accepts [make variables](#make-variables) DOCKER_REPO. - `docker-functest-images`: compile and build the file host and docker registry images for functional tests - `docker-functest-image-init`: compile and build the file host init image for functional tests - `docker-functest-image-http`: only build the file host http container for functional tests diff --git a/hack/build/build-cdi-olm-catalog.sh b/hack/build/build-cdi-olm-catalog.sh new file mode 100755 index 0000000000..03271c2ad0 --- /dev/null +++ b/hack/build/build-cdi-olm-catalog.sh @@ -0,0 +1,138 @@ +#!/usr/bin/env bash + +#Copyright 2018 The CDI Authors. +# +#Licensed under the Apache License, Version 2.0 (the "License"); +#you may not use this file except in compliance with the License. +#You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +#Unless required by applicable law or agreed to in writing, software +#distributed under the License is distributed on an "AS IS" BASIS, +#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +#See the License for the specific language governing permissions and +#limitations under the License. + +set -euo pipefail + +script_dir="$(readlink -f $(dirname $0))" +source "${script_dir}"/common.sh +source "${script_dir}"/config.sh + +csv_tool="${BIN_DIR}/cdi-olm-catalog" + +(cd "${CDI_DIR}/tools/cdi-olm-catalog/" && go build -o "${csv_tool}" ./...) + + +OUT_PATH="${OUT_DIR}" +OLM_CATALOG_INIT_PATH="tools/${CDI_OLM_CATALOG}" +OLM_CATALOG_OUT_PATH=${OUT_PATH}/${OLM_CATALOG_INIT_PATH} +OLM_MANIFESTS_SRC_PATH=${OUT_PATH}/manifests/release/olm/bundle +OLM_MANIFESTS_DIR=olm-catalog +OLM_PACKAGE=${QUAY_REPOSITORY} +OLM_TMP_CRDS=${OLM_CATALOG_OUT_PATH}/${OLM_MANIFESTS_DIR}/${OLM_PACKAGE}/crds + +#create directory for olm catalog container +mkdir -p "${OLM_CATALOG_OUT_PATH}" + + +#extract CRD version supported by given CSV +function getCSVCRDVersion { + csv=$1 + local crdVersion + crdVersion=$(${csv_tool} --cmd get-csv-crd-version --csv-file $csv --crd-kind "CDI") + echo $crdVersion +} + +#locate CRD file with the provided version +function getCRD { + crdversion=$1 + crdslocation=$2 + + local crdfilename + crdfilename="none" + for crd in $(ls $crdslocation); do + if [[ $crd =~ "crd" ]]; then + if [[ $(${csv_tool} --cmd get-crd-version --crd-file $crdslocation/$crd --crd-kind "CDI") == "$crdVersion" ]]; then + crdfilename=$crd + break + fi + fi + done + + if [ "$crdfilename" = "none" ]; then + echo "Error: No matching CRD for version "$crdversion + exit -1 + fi + echo $crdfilename +} + +#copy OLM manifests of a provided csv version to a dedicated directory +function packBundle { + csv=$1 + crds=$2 + + mkdir -p ${OLM_CATALOG_OUT_PATH}/${OLM_MANIFESTS_DIR}/${OLM_PACKAGE}/${csv} + cp ${OLM_MANIFESTS_SRC_PATH}/${csv} ${OLM_CATALOG_OUT_PATH}/${OLM_MANIFESTS_DIR}/${OLM_PACKAGE}/${csv} + + crdVersion=$(getCSVCRDVersion "${OLM_MANIFESTS_SRC_PATH}/${csv}") + crdFile=$(getCRD $crdVersion $crds) + + cp $crds/$crdFile ${OLM_CATALOG_OUT_PATH}/${OLM_MANIFESTS_DIR}/${OLM_PACKAGE}/${csv}/cdi-crds.yaml +} + +#copy crds unified manifiest to temp location and split it into manifests per crd +function prepareCRDFiles { + crds=$1 + cur=$(pwd) + cp ${OLM_MANIFESTS_SRC_PATH}/*crds* $crds + cd $crds + csplit --digits=3 --quiet --elide-empty-files --prefix=cdi-crd --suffix-format=%03d.yaml $crds/cdi-crds.yaml "/--/" "{*}" + rm -rf $crds/cdi-crds.yaml + cd $cur + +} + +#iterate over all OLM bundles and for each one build a dedicated directory +function packBundles { + + csvs=$1 + crds=${OLM_TMP_CRDS} + mkdir -p $crds + prepareCRDFiles $crds + + for csv in $(ls -1 $csvs); do + if [[ $csv =~ "csv" ]]; then + echo "pack bundle for CSV "${csv} + packBundle $csv $crds + fi + done + + #cleanup temp crds directory + rm -rf $crds +} + +${BUILD_DIR}/build-copy-artifacts.sh "${OLM_CATALOG_INIT_PATH}" + +#copy Dockerfile +cp ${BUILD_DIR}/docker/${CDI_OLM_CATALOG}/* ${OLM_CATALOG_OUT_PATH}/ +cp "${OLM_CATALOG_INIT_PATH}"/* ${OLM_CATALOG_OUT_PATH}/ + +#Build directory structure expected by olm-catalog-registry +# olm-catalog--- +# | +# ---cdi-- +# | +# package manifest +# ${CSV_VERSION} directory -- +# | +# crd manifests +# csv manifests +# +# +mkdir -p ${OLM_CATALOG_OUT_PATH}/${OLM_MANIFESTS_DIR} +mkdir -p ${OLM_CATALOG_OUT_PATH}/${OLM_MANIFESTS_DIR}/${OLM_PACKAGE} +cp ${OLM_MANIFESTS_SRC_PATH}/*package* ${OLM_CATALOG_OUT_PATH}/${OLM_MANIFESTS_DIR}/${OLM_PACKAGE}/ + +packBundles ${OLM_MANIFESTS_SRC_PATH} diff --git a/hack/build/build-go.sh b/hack/build/build-go.sh index b048d5e60b..87132e1df9 100755 --- a/hack/build/build-go.sh +++ b/hack/build/build-go.sh @@ -56,7 +56,6 @@ elif [ "${go_opt}" == "build" ]; then rm -f ${outLink} ( cd $tgt - # Only build executables for linux amd64 GOOS=linux GOARCH=amd64 go build -o ${outFile} -ldflags '-extldflags "static"' -ldflags "$(cdi::version::ldflags)" diff --git a/hack/build/config.sh b/hack/build/config.sh index 50d27aece4..52dad0009d 100755 --- a/hack/build/config.sh +++ b/hack/build/config.sh @@ -19,13 +19,14 @@ APISERVER="cdi-apiserver" UPLOADPROXY="cdi-uploadproxy" UPLOADSERVER="cdi-uploadserver" OPERATOR="cdi-operator" +CDI_OLM_CATALOG="cdi-olm-catalog" FUNC_TEST_INIT="cdi-func-test-file-host-init" FUNC_TEST_HTTP="cdi-func-test-file-host-http" FUNC_TEST_REGISTRY="cdi-func-test-registry" FUNC_TEST_REGISTRY_POPULATE="cdi-func-test-registry-populate" FUNC_TEST_REGISTRY_INIT="cdi-func-test-registry-init" -BINARIES="cmd/${OPERATOR} cmd/${CONTROLLER} cmd/${IMPORTER} cmd/${CLONER} cmd/${APISERVER} cmd/${UPLOADPROXY} cmd/${UPLOADSERVER} cmd/${OPERATOR} tools/${FUNC_TEST_INIT} tools/${FUNC_TEST_REGISTRY_INIT}" +BINARIES="cmd/${OPERATOR} cmd/${CONTROLLER} cmd/${IMPORTER} cmd/${CLONER} cmd/${APISERVER} cmd/${UPLOADPROXY} cmd/${UPLOADSERVER} cmd/${OPERATOR} tools/${FUNC_TEST_INIT} tools/${FUNC_TEST_REGISTRY_INIT}" CDI_PKGS="cmd/ pkg/ test/" OPERATOR_MAIN="cmd/${OPERATOR}" @@ -36,7 +37,7 @@ APISERVER_MAIN="cmd/${APISERVER}" UPLOADPROXY_MAIN="cmd/${UPLOADPROXY}" UPLOADSERVER_MAIN="cmd/${UPLOADSERVER}" -DOCKER_IMAGES="cmd/${OPERATOR} cmd/${CONTROLLER} cmd/${IMPORTER} cmd/${CLONER} cmd/${APISERVER} cmd/${UPLOADPROXY} cmd/${UPLOADSERVER} cmd/${OPERATOR} tools/${FUNC_TEST_INIT} tools/${FUNC_TEST_HTTP} tools/${FUNC_TEST_REGISTRY} tools/${FUNC_TEST_REGISTRY_POPULATE} tools/${FUNC_TEST_REGISTRY_INIT}" +DOCKER_IMAGES="cmd/${OPERATOR} cmd/${CONTROLLER} cmd/${IMPORTER} cmd/${CLONER} cmd/${APISERVER} cmd/${UPLOADPROXY} cmd/${UPLOADSERVER} cmd/${OPERATOR} tools/${FUNC_TEST_INIT} tools/${FUNC_TEST_HTTP} tools/${FUNC_TEST_REGISTRY} tools/${FUNC_TEST_REGISTRY_POPULATE} tools/${FUNC_TEST_REGISTRY_INIT} tools/${CDI_OLM_CATALOG}" DOCKER_PREFIX=${DOCKER_PREFIX:-kubevirt} CONTROLLER_IMAGE_NAME=${CONTROLLER_IMAGE_NAME:-cdi-controller} IMPORTER_IMAGE_NAME=${IMPORTER_IMAGE_NAME:-cdi-importer} diff --git a/hack/build/docker/cdi-olm-catalog/Dockerfile b/hack/build/docker/cdi-olm-catalog/Dockerfile new file mode 100644 index 0000000000..7546456ca4 --- /dev/null +++ b/hack/build/docker/cdi-olm-catalog/Dockerfile @@ -0,0 +1,12 @@ +FROM quay.io/openshift/origin-operator-registry:4.2.0 + +COPY olm-catalog /registry + +# Initialize the database +RUN initializer --manifests /registry --output bundles.db + +# There are multiple binaries in the origin-operator-registry +# We want the registry-server +ENTRYPOINT ["registry-server"] +CMD ["--database", "bundles.db"] + diff --git a/manifests/templates/release/olm/k8s/cdi-catalogsource-registry.yaml.in b/manifests/templates/release/olm/k8s/cdi-catalogsource-registry.yaml.in new file mode 100644 index 0000000000..6555964e45 --- /dev/null +++ b/manifests/templates/release/olm/k8s/cdi-catalogsource-registry.yaml.in @@ -0,0 +1,10 @@ +apiVersion: operators.coreos.com/v1alpha1 +kind: CatalogSource +metadata: + name: {{.QuayRepository}} + namespace: {{.Namespace}} +spec: + sourceType: grpc + image: {{ .DockerRepo }}/cdi-olm-catalog:{{ .DockerTag }} + displayName: KubeVirt CDI + publisher: Red Hat diff --git a/manifests/templates/release/olm/os/cdi-catalogsource-registry.yaml.in b/manifests/templates/release/olm/os/cdi-catalogsource-registry.yaml.in new file mode 100644 index 0000000000..ffb41a4490 --- /dev/null +++ b/manifests/templates/release/olm/os/cdi-catalogsource-registry.yaml.in @@ -0,0 +1,10 @@ +apiVersion: operators.coreos.com/v1alpha1 +kind: CatalogSource +metadata: + name: cdi-operatorhub + namespace: {{.Namespace}} +spec: + sourceType: grpc + image: {{ .DockerRepo }}/cdi-olm-catalog:{{ .DockerTag }} + displayName: KubeVirt CDI + publisher: Red Hat diff --git a/manifests/templates/release/olm/os/cdi-subscription.yaml.in b/manifests/templates/release/olm/os/cdi-subscription.yaml.in index 869e6e2567..d35f206845 100644 --- a/manifests/templates/release/olm/os/cdi-subscription.yaml.in +++ b/manifests/templates/release/olm/os/cdi-subscription.yaml.in @@ -9,4 +9,3 @@ spec: source: {{.QuayRepository}} sourceNamespace: {{.Namespace}} - diff --git a/tools/cdi-olm-catalog/main.go b/tools/cdi-olm-catalog/main.go new file mode 100644 index 0000000000..4b9d472e76 --- /dev/null +++ b/tools/cdi-olm-catalog/main.go @@ -0,0 +1,233 @@ +package main + +import ( + "errors" + "flag" + "fmt" + "io/ioutil" + "strings" + + "gopkg.in/yaml.v2" + + olm "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1" + extv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "k8s.io/klog" +) + +//CSVAnnotations - CSVAnnotations of OLM CSV manifest +type CSVAnnotations struct { + // AlmExamples is an unstructured key value map stored with a resource that may be + // set by external tools to store and retrieve arbitrary metadata. They are not + // queryable and should be preserved when modifying objects. + // More info: http://kubernetes.io/docs/user-guide/annotations + // +optional + AlmExamples map[string]string `json:"alm-examples,omitempty" protobuf:"bytes,12,rep,name=annotations"` + //Capabilities + Capabilites string `json:"capabilities,omitempty" protobuf:"bytes,1,opt,name=capabilities"` + //Categories + Categories string `json:"categories,omitempty" protobuf:"bytes,1,opt,name=categories"` + //Description + Description string `json:"description,omitempty" protobuf:"bytes,1,opt,name=description"` +} + +//CSVMetadata - CSVMetadata of OLM CSV manifest +type CSVMetadata struct { + // CSVAnnnotations is an unstructured key value map stored with a resource that may be + // set by external tools to store and retrieve arbitrary metadata. They are not + // queryable and should be preserved when modifying objects. + // More info: http://kubernetes.io/docs/user-guide/annotations + // +optional + CSVAnnnotations map[string]string `json:"annotations,omitempty" protobuf:"bytes,12,rep,name=annotations"` + + // Name must be unique within a namespace. Is required when creating resources, although + // some resources may allow a client to request the generation of an appropriate name + // automatically. Name is primarily intended for creation idempotence and configuration + // definition. + // Cannot be updated. + // More info: http://kubernetes.io/docs/user-guide/identifiers#names + // +optional + Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"` + + // Namespace defines the space within each name must be unique. An empty namespace is + // equivalent to the "default" namespace, but "default" is the canonical representation. + // Not all objects are required to be scoped to a namespace - the value of this field for + // those objects will be empty. + // + // Must be a DNS_LABEL. + // Cannot be updated. + // More info: http://kubernetes.io/docs/user-guide/namespaces + // +optional + + Namespace string `json:"namespace,omitempty" protobuf:"bytes,3,opt,name=namespace"` +} + +// ClusterServiceVersionSpec declarations tell OLM how to install an operator +// that can manage apps for a given version. +type ClusterServiceVersionSpec struct { + InstallStrategy olm.NamedInstallStrategy `json:"install"` + Version string `json:"version,omitempty"` + Maturity string `json:"maturity,omitempty"` + CustomResourceDefinitions olm.CustomResourceDefinitions `json:"customresourcedefinitions,omitempty"` + APIServiceDefinitions olm.APIServiceDefinitions `json:"apiservicedefinitions,omitempty"` + NativeAPIs []metav1.GroupVersionKind `json:"nativeAPIs,omitempty"` + MinKubeVersion string `json:"minKubeVersion,omitempty"` + DisplayName string `json:"displayName"` + Description string `json:"description,omitempty"` + Keywords []string `json:"keywords,omitempty"` + Maintainers []olm.Maintainer `json:"maintainers,omitempty"` + Provider olm.AppLink `json:"provider,omitempty"` + Links []olm.AppLink `json:"links,omitempty"` + Icon []olm.Icon `json:"icon,omitempty"` + + // InstallModes specify supported installation types + // +optional + InstallModes []olm.InstallMode `json:"installModes,omitempty"` + + // The name of a CSV this one replaces. Should match the `metadata.Name` field of the old CSV. + // +optional + Replaces string `json:"replaces,omitempty"` + + // Map of string keys and values that can be used to organize and categorize + // (scope and select) objects. + // +optional + Labels map[string]string `json:"labels,omitempty" protobuf:"bytes,11,rep,name=labels"` + + // Annotations is an unstructured key value map stored with a resource that may be + // set by external tools to store and retrieve arbitrary metadata. + // +optional + Annotations map[string]string `json:"annotations,omitempty" protobuf:"bytes,12,rep,name=annotations"` + + // Label selector for related resources. + // +optional + Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,2,opt,name=selector"` +} + +//CSVManifest - struct that represents CSV manifest +type CSVManifest struct { + APIVersion string `json:"apiVersion,omitempty"` + Kind string `json:"kind,omitempty"` + CSVMetadat CSVMetadata `json:"metadata,omitempty"` + Spec ClusterServiceVersionSpec `json:"spec,omitempty"` +} + +//CustomResourceDefinition - custome resouirce definition +type CustomResourceDefinition struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // Spec describes how the user wants the resources to appear + Spec extv1beta1.CustomResourceDefinitionSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` +} + +func getCSVCRDVersion(csvFile, crdKind string) (string, error) { + var crdVersion string + var csvStruct CSVManifest + + yamlFile, err := ioutil.ReadFile(csvFile) + if err != nil { + return "", errors.New("Failed to read csv struct " + csvFile) + } + + err = yaml.Unmarshal(yamlFile, &csvStruct) + if err != nil { + return "", err + } + + crds := csvStruct.Spec.CustomResourceDefinitions.Owned + for _, crd := range crds { + if strings.Compare(crd.Kind, crdKind) == 0 { + return crd.Version, nil + } //find crd + } //for iterate over crds of csv + + return crdVersion, errors.New("No crd " + crdKind + " defined in csv " + csvFile) +} + +func getCRDVersion(crdFile, crdKind string) (string, error) { + var crdStruct CustomResourceDefinition + + yamlFile, err := ioutil.ReadFile(crdFile) + if err != nil { + return "", errors.New("Failed to read crd manifest " + crdFile) + } + + err = yaml.Unmarshal(yamlFile, &crdStruct) + if err != nil { + return "", err + } + + //sanity + if strings.Compare(crdKind, crdStruct.Spec.Names.Kind) != 0 { + return "", errors.New("CRD kind " + crdStruct.Spec.Names.Kind + " does not match provided crdKind " + crdKind) + } + + return crdStruct.Spec.Version, nil +} + +const ( + help string = "h" + getCrdVersionCmd string = "get-crd-version" + getCsvVersionCmd string = "get-csv-crd-version" + getCsvVersionCmdHelp string = "olm-csv-tool --cmd get-csv-crd-version --csv-file --crd-kind" + getCrdVersionCmdHelp string = "olm-csv-tool --cmd get-crd-version --crd-file --crd-kind" + helpInfo string = "\nUsage:\n" + getCrdVersionCmdHelp + "\n" + getCsvVersionCmdHelp +) + +func main() { + + cmd := flag.String("cmd", "h", "command") + csvFile := flag.String("csv-file", "", "csv manifest") + crdFile := flag.String("crd-file", "", "crd manifest") + crdKind := flag.String("crd-kind", "CDI", "name of crd") + flag.Parse() + + switch *cmd { + case getCrdVersionCmd: + if *crdFile == "" { + klog.Errorf(getCrdVersionCmdHelp) + klog.Error("No crd manifest provided on command %v", getCrdVersionCmd) + panic(nil) + } + + if *crdKind == "" { + klog.Errorf(getCrdVersionCmdHelp) + klog.Error("No crd-kind provided on command %v", getCrdVersionCmd) + panic(nil) + } + + crdVersion, err := getCRDVersion(*crdFile, *crdKind) + if err != nil { + panic(err) + } + fmt.Println(crdVersion) + + break + case getCsvVersionCmd: + if *csvFile == "" { + klog.Errorf(getCsvVersionCmdHelp) + klog.Error("No csv manifest provided on command %v", getCsvVersionCmd) + panic(nil) + } + if *crdKind == "" { + klog.Errorf(getCsvVersionCmdHelp) + klog.Error("No crd-kind provided on command %v", getCsvVersionCmd) + panic(nil) + } + + crdVersion, err := getCSVCRDVersion(*csvFile, *crdKind) + if err != nil { + panic(err) + } + + fmt.Println(crdVersion) + + break + case help: + fmt.Println(helpInfo) + break + default: + panic("Invalid command " + *cmd + helpInfo) + } +} diff --git a/vendor/github.com/appscode/jsonpatch/.gitignore b/vendor/github.com/appscode/jsonpatch/.gitignore index 0e9448e052..5f90593a04 100644 --- a/vendor/github.com/appscode/jsonpatch/.gitignore +++ b/vendor/github.com/appscode/jsonpatch/.gitignore @@ -23,4 +23,5 @@ _testmain.go *.test *.prof -.idea/ +/.idea +/vendor diff --git a/vendor/github.com/appscode/jsonpatch/.travis.yml b/vendor/github.com/appscode/jsonpatch/.travis.yml index 92f2439d74..0066aaafdf 100644 --- a/vendor/github.com/appscode/jsonpatch/.travis.yml +++ b/vendor/github.com/appscode/jsonpatch/.travis.yml @@ -3,8 +3,16 @@ go: - 1.x - tip +go_import_path: gomodules.xyz/jsonpatch + +cache: + directories: + - $HOME/.cache/go-build + - $GOPATH/pkg/mod + env: - GO111MODULE=on script: - - go test -v + - cd v2 + - go test -v diff --git a/vendor/github.com/appscode/jsonpatch/CHANGELOG.md b/vendor/github.com/appscode/jsonpatch/CHANGELOG.md new file mode 100644 index 0000000000..ae70e4fee5 --- /dev/null +++ b/vendor/github.com/appscode/jsonpatch/CHANGELOG.md @@ -0,0 +1,39 @@ +# Change Log + +## [v2.0.0](https://github.com/gomodules/jsonpatch/tree/v2.0.0) (2019-06-26) +[Full Changelog](https://github.com/gomodules/jsonpatch/compare/1.0.0...v2.0.0) + +**Merged pull requests:** + +- Use Major subdirectory structure to maintain dep compatiability [\#20](https://github.com/gomodules/jsonpatch/pull/20) ([tamalsaha](https://github.com/tamalsaha)) +- Prepare v2 release [\#19](https://github.com/gomodules/jsonpatch/pull/19) ([tamalsaha](https://github.com/tamalsaha)) +- Update go.mod and remove vendor folder [\#18](https://github.com/gomodules/jsonpatch/pull/18) ([tamalsaha](https://github.com/tamalsaha)) +- Change package path to gomodules.xyz/jsonpath [\#17](https://github.com/gomodules/jsonpatch/pull/17) ([tamalsaha](https://github.com/tamalsaha)) +- \[Emergency\] correct array index in backtrace [\#16](https://github.com/gomodules/jsonpatch/pull/16) ([kdada](https://github.com/kdada)) +- Added support for arrays at the root [\#15](https://github.com/gomodules/jsonpatch/pull/15) ([e-nikolov](https://github.com/e-nikolov)) +- Fix the example code in readme [\#14](https://github.com/gomodules/jsonpatch/pull/14) ([pytimer](https://github.com/pytimer)) + +## [1.0.0](https://github.com/gomodules/jsonpatch/tree/1.0.0) (2019-01-08) +**Fixed bugs:** + +- Correctly generate patch for nested object [\#8](https://github.com/gomodules/jsonpatch/issues/8) + +**Closed issues:** + +- Do releases and in SemVer [\#12](https://github.com/gomodules/jsonpatch/issues/12) +- Generated patch incorrect for Array replacement [\#1](https://github.com/gomodules/jsonpatch/issues/1) + +**Merged pull requests:** + +- Add JsonPatchOperation as type alias for Operation [\#13](https://github.com/gomodules/jsonpatch/pull/13) ([tamalsaha](https://github.com/tamalsaha)) +- Migrate to go mod [\#10](https://github.com/gomodules/jsonpatch/pull/10) ([tamalsaha](https://github.com/tamalsaha)) +- Add test for nested object [\#9](https://github.com/gomodules/jsonpatch/pull/9) ([tamalsaha](https://github.com/tamalsaha)) +- Add test for edit distance computation [\#7](https://github.com/gomodules/jsonpatch/pull/7) ([tamalsaha](https://github.com/tamalsaha)) +- Append edit distance operations from end to start [\#6](https://github.com/gomodules/jsonpatch/pull/6) ([tamalsaha](https://github.com/tamalsaha)) +- Add travis file [\#4](https://github.com/gomodules/jsonpatch/pull/4) ([tamalsaha](https://github.com/tamalsaha)) +- Run go fmt [\#3](https://github.com/gomodules/jsonpatch/pull/3) ([tamalsaha](https://github.com/tamalsaha)) +- Fix array comparison [\#2](https://github.com/gomodules/jsonpatch/pull/2) ([tamalsaha](https://github.com/tamalsaha)) + + + +\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file diff --git a/vendor/github.com/appscode/jsonpatch/README.md b/vendor/github.com/appscode/jsonpatch/README.md index bbbf72921f..302a53b306 100644 --- a/vendor/github.com/appscode/jsonpatch/README.md +++ b/vendor/github.com/appscode/jsonpatch/README.md @@ -1,19 +1,20 @@ # jsonpatch -[![Build Status](https://travis-ci.org/appscode/jsonpatch.svg?branch=master)](https://travis-ci.org/appscode/jsonpatch) -[![Go Report Card](https://goreportcard.com/badge/appscode/jsonpatch "Go Report Card")](https://goreportcard.com/report/appscode/jsonpatch) -[![GoDoc](https://godoc.org/github.com/appscode/jsonpatch?status.svg "GoDoc")](https://godoc.org/github.com/appscode/jsonpatch) +[![Build Status](https://travis-ci.org/gomodules/jsonpatch.svg?branch=master)](https://travis-ci.org/gomodules/jsonpatch) +[![Go Report Card](https://goreportcard.com/badge/gomodules.xyz/jsonpatch "Go Report Card")](https://goreportcard.com/report/gomodules.xyz/jsonpatch) +[![GoDoc](https://godoc.org/gomodules.xyz/jsonpatch/v2?status.svg "GoDoc")](https://godoc.org/gomodules.xyz/jsonpatch/v2) As per http://jsonpatch.com JSON Patch is specified in RFC 6902 from the IETF. JSON Patch allows you to generate JSON that describes changes you want to make to a document, so you don't have to send the whole doc. JSON Patch format is supported by HTTP PATCH method, allowing for standards based partial updates via REST APIs. -```console -go get github.com/appscode/jsonpatch +## Usage ## + +```go +import "gomodules.xyz/jsonpatch/v2" ``` -I tried some of the other "jsonpatch" go implementations, but none of them could diff two json documents and -generate format like jsonpatch.com specifies. Here's an example of the patch format: +I tried some of the other "jsonpatch" go implementations, but none of them could diff two json documents and generate format like jsonpatch.com specifies. Here's an example of the patch format: ```json [ @@ -32,14 +33,14 @@ package main import ( "fmt" - "github.com/appscode/jsonpatch" + "gomodules.xyz/jsonpatch/v2" ) var simpleA = `{"a":100, "b":200, "c":"hello"}` var simpleB = `{"a":100, "b":200, "c":"goodbye"}` func main() { - patch, e := jsonpatch.CreatePatch([]byte(simpleA), []byte(simpleA)) + patch, e := jsonpatch.CreatePatch([]byte(simpleA), []byte(simpleB)) if e != nil { fmt.Printf("Error creating JSON patch:%v", e) return diff --git a/vendor/github.com/appscode/jsonpatch/go.mod b/vendor/github.com/appscode/jsonpatch/go.mod index 458d129ec9..b5eaf830eb 100644 --- a/vendor/github.com/appscode/jsonpatch/go.mod +++ b/vendor/github.com/appscode/jsonpatch/go.mod @@ -1,8 +1,9 @@ -module github.com/appscode/jsonpatch +module gomodules.xyz/jsonpatch/v2 + +go 1.12 require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/evanphx/json-patch v4.0.0+incompatible - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/stretchr/testify v1.2.2 + github.com/evanphx/json-patch v4.5.0+incompatible + github.com/pkg/errors v0.8.1 // indirect + github.com/stretchr/testify v1.3.0 ) diff --git a/vendor/github.com/appscode/jsonpatch/go.sum b/vendor/github.com/appscode/jsonpatch/go.sum index 0972e0e1a9..d8f9ffe1c9 100644 --- a/vendor/github.com/appscode/jsonpatch/go.sum +++ b/vendor/github.com/appscode/jsonpatch/go.sum @@ -1,8 +1,11 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/evanphx/json-patch v4.0.0+incompatible h1:xregGRMLBeuRcwiOTHRCsPPuzCQlqhxUPbqdw+zNkLc= -github.com/evanphx/json-patch v4.0.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/evanphx/json-patch v4.5.0+incompatible h1:ouOWdg56aJriqS0huScTkVXPC5IcNrDCXZ6OoTAWu7M= +github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= diff --git a/vendor/github.com/appscode/jsonpatch/jsonpatch.go b/vendor/github.com/appscode/jsonpatch/jsonpatch.go index 3e698949e5..e7cb7d6da5 100644 --- a/vendor/github.com/appscode/jsonpatch/jsonpatch.go +++ b/vendor/github.com/appscode/jsonpatch/jsonpatch.go @@ -58,8 +58,8 @@ func NewPatch(operation, path string, value interface{}) Operation { // // An error will be returned if any of the two documents are invalid. func CreatePatch(a, b []byte) ([]Operation, error) { - aI := map[string]interface{}{} - bI := map[string]interface{}{} + var aI interface{} + var bI interface{} err := json.Unmarshal(a, &aI) if err != nil { return nil, errBadJSONDoc @@ -68,7 +68,7 @@ func CreatePatch(a, b []byte) ([]Operation, error) { if err != nil { return nil, errBadJSONDoc } - return diff(aI, bI, "", []Operation{}) + return handleValues(aI, bI, "", []Operation{}) } // Returns true if the values matches (must be json types) @@ -326,7 +326,7 @@ func backtrace(s, t []interface{}, p string, i int, j int, matrix [][]int) []Ope return append([]Operation{op}, backtrace(s, t, p, i-1, j-1, matrix)...) } - p2, _ := handleValues(s[j-1], t[j-1], makePath(p, i-1), []Operation{}) + p2, _ := handleValues(s[i-1], t[j-1], makePath(p, i-1), []Operation{}) return append(p2, backtrace(s, t, p, i-1, j-1, matrix)...) } if i > 0 && j > 0 && matrix[i-1][j-1] == matrix[i][j] { diff --git a/vendor/github.com/appscode/jsonpatch/jsonpatch_json_test.go b/vendor/github.com/appscode/jsonpatch/jsonpatch_json_test.go index 38743627f5..76ccffc880 100644 --- a/vendor/github.com/appscode/jsonpatch/jsonpatch_json_test.go +++ b/vendor/github.com/appscode/jsonpatch/jsonpatch_json_test.go @@ -3,8 +3,8 @@ package jsonpatch_test import ( "testing" - "github.com/appscode/jsonpatch" "github.com/stretchr/testify/assert" + "gomodules.xyz/jsonpatch/v2" ) func TestMarshalNullableValue(t *testing.T) { diff --git a/vendor/github.com/appscode/jsonpatch/jsonpatch_test.go b/vendor/github.com/appscode/jsonpatch/jsonpatch_test.go index 18c58be7eb..ff2f711d9c 100644 --- a/vendor/github.com/appscode/jsonpatch/jsonpatch_test.go +++ b/vendor/github.com/appscode/jsonpatch/jsonpatch_test.go @@ -4,9 +4,9 @@ import ( "encoding/json" "testing" - "github.com/appscode/jsonpatch" jp "github.com/evanphx/json-patch" "github.com/stretchr/testify/assert" + "gomodules.xyz/jsonpatch/v2" ) var simpleA = `{"a":100, "b":200, "c":"hello"}` @@ -704,7 +704,6 @@ var ( }` ) - var ( oldNestedObj = `{ "apiVersion": "kubedb.com/v1alpha1", @@ -738,6 +737,69 @@ var ( }` ) +var ( + oldArray = `{ + "apiVersion": "kubedb.com/v1alpha1", + "kind": "Elasticsearch", + "metadata": { + "name": "quick-elasticsearch", + "namespace": "demo" + }, + "spec": { + "tolerations": [ + { + "key": "node.kubernetes.io/key1", + "operator": "Equal", + "value": "value1", + "effect": "NoSchedule" + }, + { + "key": "node.kubernetes.io/key2", + "operator": "Equal", + "value": "value2", + "effect": "NoSchedule" + }, + { + "key": "node.kubernetes.io/not-ready", + "operator": "Exists", + "effect": "NoExecute", + "tolerationSeconds": 300 + }, + { + "key": "node.kubernetes.io/unreachable", + "operator": "Exists", + "effect": "NoExecute", + "tolerationSeconds": 300 + } + ] + } +}` + + newArray = `{ + "apiVersion": "kubedb.com/v1alpha1", + "kind": "Elasticsearch", + "metadata": { + "name": "quick-elasticsearch", + "namespace": "demo" + }, + "spec": { + "tolerations": [ + { + "key": "node.kubernetes.io/key2", + "operator": "Equal", + "value": "value2", + "effect": "NoSchedule" + }, + { + "key": "node.kubernetes.io/key1", + "operator": "Equal", + "value": "value1", + "effect": "NoSchedule" + } + ] + } +}` +) func TestCreatePatch(t *testing.T) { cases := []struct { @@ -779,7 +841,12 @@ func TestCreatePatch(t *testing.T) { {"Kubernetes:Annotations", oldDeployment, newDeployment}, // crd with nested object {"Nested Member Object", oldNestedObj, newNestedObj}, + // array with different order + {"Different Array", oldArray, newArray}, + {"Array at root", `[{"asdf":"qwerty"}]`, `[{"asdf":"bla"},{"asdf":"zzz"}]`}, + {"Empty array at root", `[]`, `[{"asdf":"bla"},{"asdf":"zzz"}]`}, } + for _, c := range cases { t.Run(c.name+"[src->dst]", func(t *testing.T) { check(t, c.src, c.dst) diff --git a/vendor/github.com/appscode/jsonpatch/v2/go.mod b/vendor/github.com/appscode/jsonpatch/v2/go.mod new file mode 100644 index 0000000000..b5eaf830eb --- /dev/null +++ b/vendor/github.com/appscode/jsonpatch/v2/go.mod @@ -0,0 +1,9 @@ +module gomodules.xyz/jsonpatch/v2 + +go 1.12 + +require ( + github.com/evanphx/json-patch v4.5.0+incompatible + github.com/pkg/errors v0.8.1 // indirect + github.com/stretchr/testify v1.3.0 +) diff --git a/vendor/github.com/appscode/jsonpatch/v2/go.sum b/vendor/github.com/appscode/jsonpatch/v2/go.sum new file mode 100644 index 0000000000..d8f9ffe1c9 --- /dev/null +++ b/vendor/github.com/appscode/jsonpatch/v2/go.sum @@ -0,0 +1,11 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/evanphx/json-patch v4.5.0+incompatible h1:ouOWdg56aJriqS0huScTkVXPC5IcNrDCXZ6OoTAWu7M= +github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= diff --git a/vendor/github.com/appscode/jsonpatch/v2/jsonpatch.go b/vendor/github.com/appscode/jsonpatch/v2/jsonpatch.go new file mode 100644 index 0000000000..e7cb7d6da5 --- /dev/null +++ b/vendor/github.com/appscode/jsonpatch/v2/jsonpatch.go @@ -0,0 +1,336 @@ +package jsonpatch + +import ( + "bytes" + "encoding/json" + "fmt" + "reflect" + "strings" +) + +var errBadJSONDoc = fmt.Errorf("invalid JSON Document") + +type JsonPatchOperation = Operation + +type Operation struct { + Operation string `json:"op"` + Path string `json:"path"` + Value interface{} `json:"value,omitempty"` +} + +func (j *Operation) Json() string { + b, _ := json.Marshal(j) + return string(b) +} + +func (j *Operation) MarshalJSON() ([]byte, error) { + var b bytes.Buffer + b.WriteString("{") + b.WriteString(fmt.Sprintf(`"op":"%s"`, j.Operation)) + b.WriteString(fmt.Sprintf(`,"path":"%s"`, j.Path)) + // Consider omitting Value for non-nullable operations. + if j.Value != nil || j.Operation == "replace" || j.Operation == "add" { + v, err := json.Marshal(j.Value) + if err != nil { + return nil, err + } + b.WriteString(`,"value":`) + b.Write(v) + } + b.WriteString("}") + return b.Bytes(), nil +} + +type ByPath []Operation + +func (a ByPath) Len() int { return len(a) } +func (a ByPath) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a ByPath) Less(i, j int) bool { return a[i].Path < a[j].Path } + +func NewPatch(operation, path string, value interface{}) Operation { + return Operation{Operation: operation, Path: path, Value: value} +} + +// CreatePatch creates a patch as specified in http://jsonpatch.com/ +// +// 'a' is original, 'b' is the modified document. Both are to be given as json encoded content. +// The function will return an array of JsonPatchOperations +// +// An error will be returned if any of the two documents are invalid. +func CreatePatch(a, b []byte) ([]Operation, error) { + var aI interface{} + var bI interface{} + err := json.Unmarshal(a, &aI) + if err != nil { + return nil, errBadJSONDoc + } + err = json.Unmarshal(b, &bI) + if err != nil { + return nil, errBadJSONDoc + } + return handleValues(aI, bI, "", []Operation{}) +} + +// Returns true if the values matches (must be json types) +// The types of the values must match, otherwise it will always return false +// If two map[string]interface{} are given, all elements must match. +func matchesValue(av, bv interface{}) bool { + if reflect.TypeOf(av) != reflect.TypeOf(bv) { + return false + } + switch at := av.(type) { + case string: + bt, ok := bv.(string) + if ok && bt == at { + return true + } + case float64: + bt, ok := bv.(float64) + if ok && bt == at { + return true + } + case bool: + bt, ok := bv.(bool) + if ok && bt == at { + return true + } + case map[string]interface{}: + bt, ok := bv.(map[string]interface{}) + if !ok { + return false + } + for key := range at { + if !matchesValue(at[key], bt[key]) { + return false + } + } + for key := range bt { + if !matchesValue(at[key], bt[key]) { + return false + } + } + return true + case []interface{}: + bt, ok := bv.([]interface{}) + if !ok { + return false + } + if len(bt) != len(at) { + return false + } + for key := range at { + if !matchesValue(at[key], bt[key]) { + return false + } + } + for key := range bt { + if !matchesValue(at[key], bt[key]) { + return false + } + } + return true + } + return false +} + +// From http://tools.ietf.org/html/rfc6901#section-4 : +// +// Evaluation of each reference token begins by decoding any escaped +// character sequence. This is performed by first transforming any +// occurrence of the sequence '~1' to '/', and then transforming any +// occurrence of the sequence '~0' to '~'. +// TODO decode support: +// var rfc6901Decoder = strings.NewReplacer("~1", "/", "~0", "~") + +var rfc6901Encoder = strings.NewReplacer("~", "~0", "/", "~1") + +func makePath(path string, newPart interface{}) string { + key := rfc6901Encoder.Replace(fmt.Sprintf("%v", newPart)) + if path == "" { + return "/" + key + } + if strings.HasSuffix(path, "/") { + return path + key + } + return path + "/" + key +} + +// diff returns the (recursive) difference between a and b as an array of JsonPatchOperations. +func diff(a, b map[string]interface{}, path string, patch []Operation) ([]Operation, error) { + for key, bv := range b { + p := makePath(path, key) + av, ok := a[key] + // value was added + if !ok { + patch = append(patch, NewPatch("add", p, bv)) + continue + } + // Types are the same, compare values + var err error + patch, err = handleValues(av, bv, p, patch) + if err != nil { + return nil, err + } + } + // Now add all deleted values as nil + for key := range a { + _, found := b[key] + if !found { + p := makePath(path, key) + + patch = append(patch, NewPatch("remove", p, nil)) + } + } + return patch, nil +} + +func handleValues(av, bv interface{}, p string, patch []Operation) ([]Operation, error) { + { + at := reflect.TypeOf(av) + bt := reflect.TypeOf(bv) + if at == nil && bt == nil { + // do nothing + return patch, nil + } else if at == nil && bt != nil { + return append(patch, NewPatch("add", p, bv)), nil + } else if at != bt { + // If types have changed, replace completely (preserves null in destination) + return append(patch, NewPatch("replace", p, bv)), nil + } + } + + var err error + switch at := av.(type) { + case map[string]interface{}: + bt := bv.(map[string]interface{}) + patch, err = diff(at, bt, p, patch) + if err != nil { + return nil, err + } + case string, float64, bool: + if !matchesValue(av, bv) { + patch = append(patch, NewPatch("replace", p, bv)) + } + case []interface{}: + bt := bv.([]interface{}) + if isSimpleArray(at) && isSimpleArray(bt) { + patch = append(patch, compareEditDistance(at, bt, p)...) + } else { + n := min(len(at), len(bt)) + for i := len(at) - 1; i >= n; i-- { + patch = append(patch, NewPatch("remove", makePath(p, i), nil)) + } + for i := n; i < len(bt); i++ { + patch = append(patch, NewPatch("add", makePath(p, i), bt[i])) + } + for i := 0; i < n; i++ { + var err error + patch, err = handleValues(at[i], bt[i], makePath(p, i), patch) + if err != nil { + return nil, err + } + } + } + default: + panic(fmt.Sprintf("Unknown type:%T ", av)) + } + return patch, nil +} + +func isBasicType(a interface{}) bool { + switch a.(type) { + case string, float64, bool: + default: + return false + } + return true +} + +func isSimpleArray(a []interface{}) bool { + for i := range a { + switch a[i].(type) { + case string, float64, bool: + default: + val := reflect.ValueOf(a[i]) + if val.Kind() == reflect.Map { + for _, k := range val.MapKeys() { + av := val.MapIndex(k) + if av.Kind() == reflect.Ptr || av.Kind() == reflect.Interface { + if av.IsNil() { + continue + } + av = av.Elem() + } + if av.Kind() != reflect.String && av.Kind() != reflect.Float64 && av.Kind() != reflect.Bool { + return false + } + } + return true + } + return false + } + } + return true +} + +// https://en.wikipedia.org/wiki/Wagner%E2%80%93Fischer_algorithm +// Adapted from https://github.com/texttheater/golang-levenshtein +func compareEditDistance(s, t []interface{}, p string) []Operation { + m := len(s) + n := len(t) + + d := make([][]int, m+1) + for i := 0; i <= m; i++ { + d[i] = make([]int, n+1) + d[i][0] = i + } + for j := 0; j <= n; j++ { + d[0][j] = j + } + + for j := 1; j <= n; j++ { + for i := 1; i <= m; i++ { + if reflect.DeepEqual(s[i-1], t[j-1]) { + d[i][j] = d[i-1][j-1] // no op required + } else { + del := d[i-1][j] + 1 + add := d[i][j-1] + 1 + rep := d[i-1][j-1] + 1 + d[i][j] = min(rep, min(add, del)) + } + } + } + + return backtrace(s, t, p, m, n, d) +} + +func min(x int, y int) int { + if y < x { + return y + } + return x +} + +func backtrace(s, t []interface{}, p string, i int, j int, matrix [][]int) []Operation { + if i > 0 && matrix[i-1][j]+1 == matrix[i][j] { + op := NewPatch("remove", makePath(p, i-1), nil) + return append([]Operation{op}, backtrace(s, t, p, i-1, j, matrix)...) + } + if j > 0 && matrix[i][j-1]+1 == matrix[i][j] { + op := NewPatch("add", makePath(p, i), t[j-1]) + return append([]Operation{op}, backtrace(s, t, p, i, j-1, matrix)...) + } + if i > 0 && j > 0 && matrix[i-1][j-1]+1 == matrix[i][j] { + if isBasicType(s[0]) { + op := NewPatch("replace", makePath(p, i-1), t[j-1]) + return append([]Operation{op}, backtrace(s, t, p, i-1, j-1, matrix)...) + } + + p2, _ := handleValues(s[i-1], t[j-1], makePath(p, i-1), []Operation{}) + return append(p2, backtrace(s, t, p, i-1, j-1, matrix)...) + } + if i > 0 && j > 0 && matrix[i-1][j-1] == matrix[i][j] { + return backtrace(s, t, p, i-1, j-1, matrix) + } + return []Operation{} +} diff --git a/vendor/github.com/appscode/jsonpatch/v2/jsonpatch_json_test.go b/vendor/github.com/appscode/jsonpatch/v2/jsonpatch_json_test.go new file mode 100644 index 0000000000..76ccffc880 --- /dev/null +++ b/vendor/github.com/appscode/jsonpatch/v2/jsonpatch_json_test.go @@ -0,0 +1,33 @@ +package jsonpatch_test + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "gomodules.xyz/jsonpatch/v2" +) + +func TestMarshalNullableValue(t *testing.T) { + p1 := jsonpatch.Operation{ + Operation: "replace", + Path: "/a1", + Value: nil, + } + assert.JSONEq(t, `{"op":"replace", "path":"/a1","value":null}`, p1.Json()) + + p2 := jsonpatch.Operation{ + Operation: "replace", + Path: "/a2", + Value: "v2", + } + assert.JSONEq(t, `{"op":"replace", "path":"/a2", "value":"v2"}`, p2.Json()) +} + +func TestMarshalNonNullableValue(t *testing.T) { + p1 := jsonpatch.Operation{ + Operation: "remove", + Path: "/a1", + } + assert.JSONEq(t, `{"op":"remove", "path":"/a1"}`, p1.Json()) + +} diff --git a/vendor/github.com/appscode/jsonpatch/v2/jsonpatch_test.go b/vendor/github.com/appscode/jsonpatch/v2/jsonpatch_test.go new file mode 100644 index 0000000000..ff2f711d9c --- /dev/null +++ b/vendor/github.com/appscode/jsonpatch/v2/jsonpatch_test.go @@ -0,0 +1,874 @@ +package jsonpatch_test + +import ( + "encoding/json" + "testing" + + jp "github.com/evanphx/json-patch" + "github.com/stretchr/testify/assert" + "gomodules.xyz/jsonpatch/v2" +) + +var simpleA = `{"a":100, "b":200, "c":"hello"}` +var simpleB = `{"a":100, "b":200, "c":"goodbye"}` +var simpleC = `{"a":100, "b":100, "c":"hello"}` +var simpleD = `{"a":100, "b":200, "c":"hello", "d":"foo"}` +var simpleE = `{"a":100, "b":200}` +var simplef = `{"a":100, "b":100, "d":"foo"}` +var simpleG = `{"a":100, "b":null, "d":"foo"}` +var empty = `{}` + +var arraySrc = ` +{ + "spec": { + "loadBalancerSourceRanges": [ + "192.101.0.0/16", + "192.0.0.0/24" + ] + } +} +` + +var arrayDst = ` +{ + "spec": { + "loadBalancerSourceRanges": [ + "192.101.0.0/24" + ] + } +} +` + +var complexBase = `{"a":100, "b":[{"c1":"hello", "d1":"foo"},{"c2":"hello2", "d2":"foo2"} ], "e":{"f":200, "g":"h", "i":"j"}}` +var complexA = `{"a":100, "b":[{"c1":"goodbye", "d1":"foo"},{"c2":"hello2", "d2":"foo2"} ], "e":{"f":200, "g":"h", "i":"j"}}` +var complexB = `{"a":100, "b":[{"c1":"hello", "d1":"foo"},{"c2":"hello2", "d2":"foo2"} ], "e":{"f":100, "g":"h", "i":"j"}}` +var complexC = `{"a":100, "b":[{"c1":"hello", "d1":"foo"},{"c2":"hello2", "d2":"foo2"} ], "e":{"f":200, "g":"h", "i":"j"}, "k":[{"l":"m"}, {"l":"o"}]}` +var complexD = `{"a":100, "b":[{"c1":"hello", "d1":"foo"},{"c2":"hello2", "d2":"foo2"}, {"c3":"hello3", "d3":"foo3"} ], "e":{"f":200, "g":"h", "i":"j"}}` +var complexE = `{"a":100, "b":[{"c1":"hello", "d1":"foo"},{"c2":"hello2", "d2":"foo2"} ], "e":{"f":200, "g":"h", "i":"j"}}` + +var point = `{"type":"Point", "coordinates":[0.0, 1.0]}` +var lineString = `{"type":"LineString", "coordinates":[[0.0, 1.0], [2.0, 3.0]]}` + +var hyperComplexBase = ` +{ + "goods": [ + { + "id": "0001", + "type": "donut", + "name": "Cake", + "ppu": 0.55, + "batters": + { + "batter": + [ + { "id": "1001", "type": "Regular" }, + { "id": "1002", "type": "Chocolate" }, + { "id": "1003", "type": "Blueberry" }, + { "id": "1004", "type": "Devil's Food" } + ] + }, + "topping": + [ + { "id": "5001", "type": "None" }, + { "id": "5002", "type": "Glazed" }, + { "id": "5005", "type": "Sugar" }, + { "id": "5007", "type": "Powdered Sugar" }, + { "id": "5006", "type": "Chocolate with Sprinkles" }, + { "id": "5003", "type": "Chocolate" }, + { "id": "5004", "type": "Maple" } + ] + }, + { + "id": "0002", + "type": "donut", + "name": "Raised", + "ppu": 0.55, + "batters": + { + "batter": + [ + { "id": "1001", "type": "Regular" } + ] + }, + "topping": + [ + { "id": "5001", "type": "None" }, + { "id": "5002", "type": "Glazed" }, + { "id": "5005", "type": "Sugar" }, + { "id": "5003", "type": "Chocolate" }, + { "id": "5004", "type": "Maple" } + ] + }, + { + "id": "0003", + "type": "donut", + "name": "Old Fashioned", + "ppu": 0.55, + "batters": + { + "batter": + [ + { "id": "1001", "type": "Regular" }, + { "id": "1002", "type": "Chocolate" } + ] + }, + "topping": + [ + { "id": "5001", "type": "None" }, + { "id": "5002", "type": "Glazed" }, + { "id": "5003", "type": "Chocolate" }, + { "id": "5004", "type": "Maple" } + ] + } +] +}` + +var hyperComplexA = ` +{ + "goods": [ + { + "id": "0001", + "type": "donut", + "name": "Cake", + "ppu": 0.55, + "batters": + { + "batter": + [ + { "id": "1001", "type": "Regular" }, + { "id": "1002", "type": "Chocolate" }, + { "id": "1003", "type": "Strawberry" }, + { "id": "1004", "type": "Devil's Food" } + ] + }, + "topping": + [ + { "id": "5001", "type": "None" }, + { "id": "5002", "type": "Glazed" }, + { "id": "5005", "type": "Sugar" }, + { "id": "5007", "type": "Powdered Sugar" }, + { "id": "5006", "type": "Chocolate with Sprinkles" }, + { "id": "5003", "type": "Chocolate" }, + { "id": "5004", "type": "Maple" } + ] + }, + { + "id": "0002", + "type": "donut", + "name": "Raised", + "ppu": 0.55, + "batters": + { + "batter": + [ + { "id": "1001", "type": "Regular" } + ] + }, + "topping": + [ + { "id": "5001", "type": "None" }, + { "id": "5002", "type": "Glazed" }, + { "id": "5005", "type": "Sugar" }, + { "id": "5003", "type": "Chocolate" }, + { "id": "5004", "type": "Maple" } + ] + }, + { + "id": "0003", + "type": "donut", + "name": "Old Fashioned", + "ppu": 0.55, + "batters": + { + "batter": + [ + { "id": "1001", "type": "Regular" }, + { "id": "1002", "type": "Chocolate" }, + { "id": "1003", "type": "Vanilla" } + ] + }, + "topping": + [ + { "id": "5001", "type": "None" }, + { "id": "5002", "type": "Glazed" }, + { "id": "5004", "type": "Maple" } + ] + } +] +}` + +var superComplexBase = ` +{ + "annotations": { + "annotation": [ + { + "name": "version", + "value": "8" + }, + { + "name": "versionTag", + "value": "Published on May 13, 2015 at 8:48pm (MST)" + } + ] + }, + "attributes": { + "attribute-key": [ + { + "id": "3b05c943-d81a-436f-b242-8b519e7a6f30", + "properties": { + "visible": true + } + }, + { + "id": "d794c7ee-2a4b-4da4-bba7-e8b973d50c4b", + "properties": { + "visible": true + } + }, + { + "id": "a0259458-517c-480f-9f04-9b54b1b2af1f", + "properties": { + "visible": true + } + }, + { + "id": "9415f39d-c396-4458-9019-fc076c847964", + "properties": { + "visible": true + } + }, + { + "id": "0a2e49a9-8989-42fb-97da-cc66334f828b", + "properties": { + "visible": true + } + }, + { + "id": "27f5f14a-ea97-4feb-b22a-6ff754a31212", + "properties": { + "visible": true + } + }, + { + "id": "6f810508-4615-4fd0-9e87-80f9c94f9ad8", + "properties": { + "visible": true + } + }, + { + "id": "3451b1b2-7365-455c-8bb1-0b464d4d3ba1", + "properties": { + "visible": true + } + }, + { + "id": "a82ec957-8c26-41ea-8af6-6dd75c384801", + "properties": { + "visible": true + } + }, + { + "id": "736c5496-9a6e-4a82-aa00-456725796432", + "properties": { + "visible": true + } + }, + { + "id": "2d428b3c-9d3b-4ec1-bf98-e00673599d60", + "properties": { + "visible": true + } + }, + { + "id": "68566ebb-811d-4337-aba9-a8a8baf90e4b", + "properties": { + "visible": true + } + }, + { + "id": "ca88bab1-a1ea-40cc-8f96-96d1e9f1217d", + "properties": { + "visible": true + } + }, + { + "id": "c63a12c8-542d-47f3-bee1-30b5fe2b0690", + "properties": { + "visible": true + } + }, + { + "id": "cbd9e3bc-6a49-432a-a906-b1674c1de24c", + "properties": { + "visible": true + } + }, + { + "id": "03262f07-8a15-416d-a3f5-e2bf561c78f9", + "properties": { + "visible": true + } + }, + { + "id": "e5c93b87-83fc-45b6-b4d5-bf1e3f523075", + "properties": { + "visible": true + } + }, + { + "id": "72260ac5-3d51-49d7-bb31-f794dd129f1c", + "properties": { + "visible": true + } + }, + { + "id": "d856bde1-1b42-4935-9bee-c37e886c9ecf", + "properties": { + "visible": true + } + }, + { + "id": "62380509-bedf-4134-95c3-77ff377a4a6a", + "properties": { + "visible": true + } + }, + { + "id": "f4ed5ac9-b386-49a6-a0a0-6f3341ce9021", + "properties": { + "visible": true + } + }, + { + "id": "528d2bd2-87fe-4a49-954a-c93a03256929", + "properties": { + "visible": true + } + }, + { + "id": "ff8951f1-61a7-416b-9223-fac4bb6dac50", + "properties": { + "visible": true + } + }, + { + "id": "95c2b011-d782-4042-8a07-6aa4a5765c2e", + "properties": { + "visible": true + } + }, + { + "id": "dbe5837b-0624-4a05-91f3-67b5bd9b812a", + "properties": { + "visible": true + } + }, + { + "id": "13f198ed-82ab-4e51-8144-bfaa5bf77fd5", + "properties": { + "visible": true + } + }, + { + "id": "025312eb-12b6-47e6-9750-0fb31ddc2111", + "properties": { + "visible": true + } + }, + { + "id": "24292d58-db66-4ef3-8f4f-005d7b719433", + "properties": { + "visible": true + } + }, + { + "id": "22e5b5c4-821c-413a-a5b1-ab866d9a03bb", + "properties": { + "visible": true + } + }, + { + "id": "2fde0aac-df89-403d-998e-854b949c7b57", + "properties": { + "visible": true + } + }, + { + "id": "8b576876-5c16-4178-805e-24984c24fac3", + "properties": { + "visible": true + } + }, + { + "id": "415b7d2a-b362-4f1e-b83a-927802328ecb", + "properties": { + "visible": true + } + }, + { + "id": "8ef24fc2-ab25-4f22-9d9f-61902b49dc01", + "properties": { + "visible": true + } + }, + { + "id": "2299b09e-9f8e-4b79-a55c-a7edacde2c85", + "properties": { + "visible": true + } + }, + { + "id": "bf506538-f438-425c-be85-5aa2f9b075b8", + "properties": { + "visible": true + } + }, + { + "id": "2b501dc6-799d-4675-9144-fac77c50c57c", + "properties": { + "visible": true + } + }, + { + "id": "c0446da1-e069-417e-bd5a-34edcd028edc", + "properties": { + "visible": true + } + } + ] + } +}` + +var superComplexA = ` +{ + "annotations": { + "annotation": [ + { + "name": "version", + "value": "8" + }, + { + "name": "versionTag", + "value": "Published on May 13, 2015 at 8:48pm (MST)" + } + ] + }, + "attributes": { + "attribute-key": [ + { + "id": "3b05c943-d81a-436f-b242-8b519e7a6f30", + "properties": { + "visible": true + } + }, + { + "id": "d794c7ee-2a4b-4da4-bba7-e8b973d50c4b", + "properties": { + "visible": true + } + }, + { + "id": "a0259458-517c-480f-9f04-9b54b1b2af1f", + "properties": { + "visible": true + } + }, + { + "id": "9415f39d-c396-4458-9019-fc076c847964", + "properties": { + "visible": true + } + }, + { + "id": "0a2e49a9-8989-42fb-97da-cc66334f828b", + "properties": { + "visible": true + } + }, + { + "id": "27f5f14a-ea97-4feb-b22a-6ff754a31212", + "properties": { + "visible": true + } + }, + { + "id": "6f810508-4615-4fd0-9e87-80f9c94f9ad8", + "properties": { + "visible": true + } + }, + { + "id": "3451b1b2-7365-455c-8bb1-0b464d4d3ba1", + "properties": { + "visible": true + } + }, + { + "id": "a82ec957-8c26-41ea-8af6-6dd75c384801", + "properties": { + "visible": true + } + }, + { + "id": "736c5496-9a6e-4a82-aa00-456725796432", + "properties": { + "visible": true + } + }, + { + "id": "2d428b3c-9d3b-4ec1-bf98-e00673599d60", + "properties": { + "visible": true + } + }, + { + "id": "68566ebb-811d-4337-aba9-a8a8baf90e4b", + "properties": { + "visible": true + } + }, + { + "id": "ca88bab1-a1ea-40cc-8f96-96d1e9f1217d", + "properties": { + "visible": true + } + }, + { + "id": "c63a12c8-542d-47f3-bee1-30b5fe2b0690", + "properties": { + "visible": true + } + }, + { + "id": "cbd9e3bc-6a49-432a-a906-b1674c1de24c", + "properties": { + "visible": true + } + }, + { + "id": "03262f07-8a15-416d-a3f5-e2bf561c78f9", + "properties": { + "visible": true + } + }, + { + "id": "e5c93b87-83fc-45b6-b4d5-bf1e3f523075", + "properties": { + "visible": true + } + }, + { + "id": "72260ac5-3d51-49d7-bb31-f794dd129f1c", + "properties": { + "visible": true + } + }, + { + "id": "d856bde1-1b42-4935-9bee-c37e886c9ecf", + "properties": { + "visible": true + } + }, + { + "id": "62380509-bedf-4134-95c3-77ff377a4a6a", + "properties": { + "visible": true + } + }, + { + "id": "f4ed5ac9-b386-49a6-a0a0-6f3341ce9021", + "properties": { + "visible": true + } + }, + { + "id": "528d2bd2-87fe-4a49-954a-c93a03256929", + "properties": { + "visible": true + } + }, + { + "id": "ff8951f1-61a7-416b-9223-fac4bb6dac50", + "properties": { + "visible": true + } + }, + { + "id": "95c2b011-d782-4042-8a07-6aa4a5765c2e", + "properties": { + "visible": true + } + }, + { + "id": "dbe5837b-0624-4a05-91f3-67b5bd9b812a", + "properties": { + "visible": true + } + }, + { + "id": "13f198ed-82ab-4e51-8144-bfaa5bf77fd5", + "properties": { + "visible": true + } + }, + { + "id": "025312eb-12b6-47e6-9750-0fb31ddc2111", + "properties": { + "visible": true + } + }, + { + "id": "24292d58-db66-4ef3-8f4f-005d7b719433", + "properties": { + "visible": true + } + }, + { + "id": "22e5b5c4-821c-413a-a5b1-ab866d9a03bb", + "properties": { + "visible": true + } + }, + { + "id": "2fde0aac-df89-403d-998e-854b949c7b57", + "properties": { + "visible": true + } + }, + { + "id": "8b576876-5c16-4178-805e-24984c24fac3", + "properties": { + "visible": true + } + }, + { + "id": "415b7d2a-b362-4f1e-b83a-927802328ecb", + "properties": { + "visible": true + } + }, + { + "id": "8ef24fc2-ab25-4f22-9d9f-61902b49dc01", + "properties": { + "visible": true + } + }, + { + "id": "2299b09e-9f8e-4b79-a55c-a7edacde2c85", + "properties": { + "visible": true + } + }, + { + "id": "bf506538-f438-425c-be85-5aa2f9b075b8", + "properties": { + "visible": true + } + }, + { + "id": "2b501dc6-799d-4675-9144-fac77c50c57c", + "properties": { + "visible": true + } + }, + { + "id": "c0446da1-e069-417e-bd5a-34edcd028edc", + "properties": { + "visible": false + } + } + ] + } +}` + +var ( + oldDeployment = `{ + "apiVersion": "apps/v1beta1", + "kind": "Deployment", + "metadata": { + "annotations": { + "k8s.io/app": "busy-dep" + } + } +}` + + newDeployment = `{ + "apiVersion": "apps/v1beta1", + "kind": "Deployment", + "metadata": { + "annotations": { + "k8s.io/app": "busy-dep", + "docker.com/commit": "github.com/myrepo#xyz" + } + } +}` +) + +var ( + oldNestedObj = `{ + "apiVersion": "kubedb.com/v1alpha1", + "kind": "Elasticsearch", + "metadata": { + "name": "quick-elasticsearch", + "namespace": "demo" + }, + "spec": { + "doNotPause": true, + "version": "5.6" + } +}` + + newNestedObj = `{ + "apiVersion": "kubedb.com/v1alpha1", + "kind": "Elasticsearch", + "metadata": { + "name": "quick-elasticsearch", + "namespace": "demo" + }, + "spec": { + "doNotPause": true, + "version": "5.6", + "storageType": "Durable", + "updateStrategy": { + "type": "RollingUpdate" + }, + "terminationPolicy": "Pause" + } +}` +) + +var ( + oldArray = `{ + "apiVersion": "kubedb.com/v1alpha1", + "kind": "Elasticsearch", + "metadata": { + "name": "quick-elasticsearch", + "namespace": "demo" + }, + "spec": { + "tolerations": [ + { + "key": "node.kubernetes.io/key1", + "operator": "Equal", + "value": "value1", + "effect": "NoSchedule" + }, + { + "key": "node.kubernetes.io/key2", + "operator": "Equal", + "value": "value2", + "effect": "NoSchedule" + }, + { + "key": "node.kubernetes.io/not-ready", + "operator": "Exists", + "effect": "NoExecute", + "tolerationSeconds": 300 + }, + { + "key": "node.kubernetes.io/unreachable", + "operator": "Exists", + "effect": "NoExecute", + "tolerationSeconds": 300 + } + ] + } +}` + + newArray = `{ + "apiVersion": "kubedb.com/v1alpha1", + "kind": "Elasticsearch", + "metadata": { + "name": "quick-elasticsearch", + "namespace": "demo" + }, + "spec": { + "tolerations": [ + { + "key": "node.kubernetes.io/key2", + "operator": "Equal", + "value": "value2", + "effect": "NoSchedule" + }, + { + "key": "node.kubernetes.io/key1", + "operator": "Equal", + "value": "value1", + "effect": "NoSchedule" + } + ] + } +}` +) + +func TestCreatePatch(t *testing.T) { + cases := []struct { + name string + src string + dst string + }{ + // simple + {"Simple:OneNullReplace", simplef, simpleG}, + {"Simple:Same", simpleA, simpleA}, + {"Simple:OneStringReplace", simpleA, simpleB}, + {"Simple:OneIntReplace", simpleA, simpleC}, + {"Simple:OneAdd", simpleA, simpleD}, + {"Simple:OneRemove", simpleA, simpleE}, + {"Simple:VsEmpty", simpleA, empty}, + // array types + {"Array:Same", arraySrc, arraySrc}, + {"Array:BoolReplace", arraySrc, arrayDst}, + {"Array:AlmostSame", `{"Lines":[1,2,3,4,5,6,7,8,9,10]}`, `{"Lines":[2,3,4,5,6,7,8,9,10,11]}`}, + {"Array:Remove", `{"x":["A", "B", "C"]}`, `{"x":["D"]}`}, + {"Array:EditDistance", `{"letters":["A","B","C","D","E","F","G","H","I","J","K"]}`, `{"letters":["L","M","N"]}`}, + // complex types + {"Complex:Same", complexBase, complexBase}, + {"Complex:OneStringReplaceInArray", complexBase, complexA}, + {"Complex:OneIntReplace", complexBase, complexB}, + {"Complex:OneAdd", complexBase, complexC}, + {"Complex:OneAddToArray", complexBase, complexC}, + {"Complex:VsEmpty", complexBase, empty}, + // geojson + {"GeoJson:PointLineStringReplace", point, lineString}, + {"GeoJson:LineStringPointReplace", lineString, point}, + // HyperComplex + {"HyperComplex:Same", hyperComplexBase, hyperComplexBase}, + {"HyperComplex:BoolReplace", hyperComplexBase, hyperComplexA}, + // SuperComplex + {"SuperComplex:Same", superComplexBase, superComplexBase}, + {"SuperComplex:BoolReplace", superComplexBase, superComplexA}, + // map + {"Kubernetes:Annotations", oldDeployment, newDeployment}, + // crd with nested object + {"Nested Member Object", oldNestedObj, newNestedObj}, + // array with different order + {"Different Array", oldArray, newArray}, + {"Array at root", `[{"asdf":"qwerty"}]`, `[{"asdf":"bla"},{"asdf":"zzz"}]`}, + {"Empty array at root", `[]`, `[{"asdf":"bla"},{"asdf":"zzz"}]`}, + } + + for _, c := range cases { + t.Run(c.name+"[src->dst]", func(t *testing.T) { + check(t, c.src, c.dst) + }) + t.Run(c.name+"[dst->src]", func(t *testing.T) { + check(t, c.dst, c.src) + }) + } +} + +func check(t *testing.T, src, dst string) { + patch, err := jsonpatch.CreatePatch([]byte(src), []byte(dst)) + assert.Nil(t, err) + + data, err := json.Marshal(patch) + assert.Nil(t, err) + + p2, err := jp.DecodePatch(data) + assert.Nil(t, err) + + d2, err := p2.Apply([]byte(src)) + assert.Nil(t, err) + + assert.JSONEq(t, dst, string(d2)) +} diff --git a/vendor/github.com/blang/semver/.gx/lastpubver b/vendor/github.com/blang/semver/.gx/lastpubver new file mode 100644 index 0000000000..54339b2411 --- /dev/null +++ b/vendor/github.com/blang/semver/.gx/lastpubver @@ -0,0 +1 @@ +3.6.1: Qmc2TuykruVht9jiXbBXdGenbQhdsUMWCn61B8QFakH2Aw diff --git a/vendor/github.com/blang/semver/.travis.yml b/vendor/github.com/blang/semver/.travis.yml new file mode 100644 index 0000000000..a85d26954b --- /dev/null +++ b/vendor/github.com/blang/semver/.travis.yml @@ -0,0 +1,26 @@ +language: go +matrix: + include: + - go: 1.4.x + - go: 1.5.x + - go: 1.6.x + - go: 1.7.x + - go: 1.8.x + - go: 1.9.x + - go: 1.10.x + - go: 1.11.x + - go: 1.12.x + - go: tip + allow_failures: + - go: tip +install: +- go get golang.org/x/tools/cmd/cover +- go get github.com/mattn/goveralls +script: +- echo "Test and track coverage" ; $HOME/gopath/bin/goveralls -package "." -service=travis-ci + -repotoken=$COVERALLS_TOKEN +- echo "Build examples" ; cd examples && go build +- echo "Check if gofmt'd" ; diff -u <(echo -n) <(gofmt -d -s .) +env: + global: + secure: HroGEAUQpVq9zX1b1VIkraLiywhGbzvNnTZq2TMxgK7JHP8xqNplAeF1izrR2i4QLL9nsY+9WtYss4QuPvEtZcVHUobw6XnL6radF7jS1LgfYZ9Y7oF+zogZ2I5QUMRLGA7rcxQ05s7mKq3XZQfeqaNts4bms/eZRefWuaFZbkw= diff --git a/vendor/github.com/blang/semver/LICENSE b/vendor/github.com/blang/semver/LICENSE new file mode 100644 index 0000000000..5ba5c86fcb --- /dev/null +++ b/vendor/github.com/blang/semver/LICENSE @@ -0,0 +1,22 @@ +The MIT License + +Copyright (c) 2014 Benedikt Lang + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/vendor/github.com/blang/semver/README.md b/vendor/github.com/blang/semver/README.md new file mode 100644 index 0000000000..e05f986518 --- /dev/null +++ b/vendor/github.com/blang/semver/README.md @@ -0,0 +1,194 @@ +semver for golang [![Build Status](https://travis-ci.org/blang/semver.svg?branch=master)](https://travis-ci.org/blang/semver) [![GoDoc](https://godoc.org/github.com/blang/semver?status.svg)](https://godoc.org/github.com/blang/semver) [![Coverage Status](https://img.shields.io/coveralls/blang/semver.svg)](https://coveralls.io/r/blang/semver?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/blang/semver)](https://goreportcard.com/report/github.com/blang/semver) +====== + +semver is a [Semantic Versioning](http://semver.org/) library written in golang. It fully covers spec version `2.0.0`. + +Usage +----- +```bash +$ go get github.com/blang/semver +``` +Note: Always vendor your dependencies or fix on a specific version tag. + +```go +import github.com/blang/semver +v1, err := semver.Make("1.0.0-beta") +v2, err := semver.Make("2.0.0-beta") +v1.Compare(v2) +``` + +Also check the [GoDocs](http://godoc.org/github.com/blang/semver). + +Why should I use this lib? +----- + +- Fully spec compatible +- No reflection +- No regex +- Fully tested (Coverage >99%) +- Readable parsing/validation errors +- Fast (See [Benchmarks](#benchmarks)) +- Only Stdlib +- Uses values instead of pointers +- Many features, see below + + +Features +----- + +- Parsing and validation at all levels +- Comparator-like comparisons +- Compare Helper Methods +- InPlace manipulation +- Ranges `>=1.0.0 <2.0.0 || >=3.0.0 !3.0.1-beta.1` +- Wildcards `>=1.x`, `<=2.5.x` +- Sortable (implements sort.Interface) +- database/sql compatible (sql.Scanner/Valuer) +- encoding/json compatible (json.Marshaler/Unmarshaler) + +Ranges +------ + +A `Range` is a set of conditions which specify which versions satisfy the range. + +A condition is composed of an operator and a version. The supported operators are: + +- `<1.0.0` Less than `1.0.0` +- `<=1.0.0` Less than or equal to `1.0.0` +- `>1.0.0` Greater than `1.0.0` +- `>=1.0.0` Greater than or equal to `1.0.0` +- `1.0.0`, `=1.0.0`, `==1.0.0` Equal to `1.0.0` +- `!1.0.0`, `!=1.0.0` Not equal to `1.0.0`. Excludes version `1.0.0`. + +Note that spaces between the operator and the version will be gracefully tolerated. + +A `Range` can link multiple `Ranges` separated by space: + +Ranges can be linked by logical AND: + + - `>1.0.0 <2.0.0` would match between both ranges, so `1.1.1` and `1.8.7` but not `1.0.0` or `2.0.0` + - `>1.0.0 <3.0.0 !2.0.3-beta.2` would match every version between `1.0.0` and `3.0.0` except `2.0.3-beta.2` + +Ranges can also be linked by logical OR: + + - `<2.0.0 || >=3.0.0` would match `1.x.x` and `3.x.x` but not `2.x.x` + +AND has a higher precedence than OR. It's not possible to use brackets. + +Ranges can be combined by both AND and OR + + - `>1.0.0 <2.0.0 || >3.0.0 !4.2.1` would match `1.2.3`, `1.9.9`, `3.1.1`, but not `4.2.1`, `2.1.1` + +Range usage: + +``` +v, err := semver.Parse("1.2.3") +expectedRange, err := semver.ParseRange(">1.0.0 <2.0.0 || >=3.0.0") +if expectedRange(v) { + //valid +} + +``` + +Example +----- + +Have a look at full examples in [examples/main.go](examples/main.go) + +```go +import github.com/blang/semver + +v, err := semver.Make("0.0.1-alpha.preview+123.github") +fmt.Printf("Major: %d\n", v.Major) +fmt.Printf("Minor: %d\n", v.Minor) +fmt.Printf("Patch: %d\n", v.Patch) +fmt.Printf("Pre: %s\n", v.Pre) +fmt.Printf("Build: %s\n", v.Build) + +// Prerelease versions array +if len(v.Pre) > 0 { + fmt.Println("Prerelease versions:") + for i, pre := range v.Pre { + fmt.Printf("%d: %q\n", i, pre) + } +} + +// Build meta data array +if len(v.Build) > 0 { + fmt.Println("Build meta data:") + for i, build := range v.Build { + fmt.Printf("%d: %q\n", i, build) + } +} + +v001, err := semver.Make("0.0.1") +// Compare using helpers: v.GT(v2), v.LT, v.GTE, v.LTE +v001.GT(v) == true +v.LT(v001) == true +v.GTE(v) == true +v.LTE(v) == true + +// Or use v.Compare(v2) for comparisons (-1, 0, 1): +v001.Compare(v) == 1 +v.Compare(v001) == -1 +v.Compare(v) == 0 + +// Manipulate Version in place: +v.Pre[0], err = semver.NewPRVersion("beta") +if err != nil { + fmt.Printf("Error parsing pre release version: %q", err) +} + +fmt.Println("\nValidate versions:") +v.Build[0] = "?" + +err = v.Validate() +if err != nil { + fmt.Printf("Validation failed: %s\n", err) +} +``` + + +Benchmarks +----- + + BenchmarkParseSimple-4 5000000 390 ns/op 48 B/op 1 allocs/op + BenchmarkParseComplex-4 1000000 1813 ns/op 256 B/op 7 allocs/op + BenchmarkParseAverage-4 1000000 1171 ns/op 163 B/op 4 allocs/op + BenchmarkStringSimple-4 20000000 119 ns/op 16 B/op 1 allocs/op + BenchmarkStringLarger-4 10000000 206 ns/op 32 B/op 2 allocs/op + BenchmarkStringComplex-4 5000000 324 ns/op 80 B/op 3 allocs/op + BenchmarkStringAverage-4 5000000 273 ns/op 53 B/op 2 allocs/op + BenchmarkValidateSimple-4 200000000 9.33 ns/op 0 B/op 0 allocs/op + BenchmarkValidateComplex-4 3000000 469 ns/op 0 B/op 0 allocs/op + BenchmarkValidateAverage-4 5000000 256 ns/op 0 B/op 0 allocs/op + BenchmarkCompareSimple-4 100000000 11.8 ns/op 0 B/op 0 allocs/op + BenchmarkCompareComplex-4 50000000 30.8 ns/op 0 B/op 0 allocs/op + BenchmarkCompareAverage-4 30000000 41.5 ns/op 0 B/op 0 allocs/op + BenchmarkSort-4 3000000 419 ns/op 256 B/op 2 allocs/op + BenchmarkRangeParseSimple-4 2000000 850 ns/op 192 B/op 5 allocs/op + BenchmarkRangeParseAverage-4 1000000 1677 ns/op 400 B/op 10 allocs/op + BenchmarkRangeParseComplex-4 300000 5214 ns/op 1440 B/op 30 allocs/op + BenchmarkRangeMatchSimple-4 50000000 25.6 ns/op 0 B/op 0 allocs/op + BenchmarkRangeMatchAverage-4 30000000 56.4 ns/op 0 B/op 0 allocs/op + BenchmarkRangeMatchComplex-4 10000000 153 ns/op 0 B/op 0 allocs/op + +See benchmark cases at [semver_test.go](semver_test.go) + + +Motivation +----- + +I simply couldn't find any lib supporting the full spec. Others were just wrong or used reflection and regex which i don't like. + + +Contribution +----- + +Feel free to make a pull request. For bigger changes create a issue first to discuss about it. + + +License +----- + +See [LICENSE](LICENSE) file. diff --git a/vendor/github.com/blang/semver/examples/main.go b/vendor/github.com/blang/semver/examples/main.go new file mode 100644 index 0000000000..7bd1c551d8 --- /dev/null +++ b/vendor/github.com/blang/semver/examples/main.go @@ -0,0 +1,84 @@ +package main + +import ( + "fmt" + + "github.com/blang/semver" +) + +func main() { + v, err := semver.Parse("0.0.1-alpha.preview.222+123.github") + if err != nil { + fmt.Printf("Error while parsing (not valid): %q", err) + } + fmt.Printf("Version to string: %q\n", v) + + fmt.Printf("Major: %d\n", v.Major) + fmt.Printf("Minor: %d\n", v.Minor) + fmt.Printf("Patch: %d\n", v.Patch) + + // Prerelease versions + if len(v.Pre) > 0 { + fmt.Println("Prerelease versions:") + for i, pre := range v.Pre { + fmt.Printf("%d: %q\n", i, pre) + } + } + + // Build meta data + if len(v.Build) > 0 { + fmt.Println("Build meta data:") + for i, build := range v.Build { + fmt.Printf("%d: %q\n", i, build) + } + } + + // Make == Parse (Value), New for Pointer + v001, _ := semver.Make("0.0.1") + + fmt.Println("\nUse Version.Compare for comparisons (-1, 0, 1):") + fmt.Printf("%q is greater than %q: Compare == %d\n", v001, v, v001.Compare(v)) + fmt.Printf("%q is less than %q: Compare == %d\n", v, v001, v.Compare(v001)) + fmt.Printf("%q is equal to %q: Compare == %d\n", v, v, v.Compare(v)) + + fmt.Println("\nUse comparison helpers returning booleans:") + fmt.Printf("%q is greater than %q: %t\n", v001, v, v001.GT(v)) + fmt.Printf("%q is greater than equal %q: %t\n", v001, v, v001.GTE(v)) + fmt.Printf("%q is greater than equal %q: %t\n", v, v, v.GTE(v)) + fmt.Printf("%q is less than %q: %t\n", v, v001, v.LT(v001)) + fmt.Printf("%q is less than equal %q: %t\n", v, v001, v.LTE(v001)) + fmt.Printf("%q is less than equal %q: %t\n", v, v, v.LTE(v)) + + fmt.Println("\nManipulate Version in place:") + v.Pre[0], err = semver.NewPRVersion("beta") + if err != nil { + fmt.Printf("Error parsing pre release version: %q", err) + } + fmt.Printf("Version to string: %q\n", v) + + fmt.Println("\nCompare Prerelease versions:") + pre1, _ := semver.NewPRVersion("123") + pre2, _ := semver.NewPRVersion("alpha") + pre3, _ := semver.NewPRVersion("124") + fmt.Printf("%q is less than %q: Compare == %d\n", pre1, pre2, pre1.Compare(pre2)) + fmt.Printf("%q is greater than %q: Compare == %d\n", pre3, pre1, pre3.Compare(pre1)) + fmt.Printf("%q is equal to %q: Compare == %d\n", pre1, pre1, pre1.Compare(pre1)) + + fmt.Println("\nValidate versions:") + v.Build[0] = "?" + + err = v.Validate() + if err != nil { + fmt.Printf("Validation failed: %s\n", err) + } + + fmt.Println("Create valid build meta data:") + b1, _ := semver.NewBuildVersion("build123") + v.Build[0] = b1 + fmt.Printf("Version with new build version %q\n", v) + + _, err = semver.NewBuildVersion("build?123") + if err != nil { + fmt.Printf("Create build version failed: %s\n", err) + } +} diff --git a/vendor/github.com/blang/semver/go.mod b/vendor/github.com/blang/semver/go.mod new file mode 100644 index 0000000000..d0083058ef --- /dev/null +++ b/vendor/github.com/blang/semver/go.mod @@ -0,0 +1 @@ +module github.com/blang/semver diff --git a/vendor/github.com/blang/semver/json.go b/vendor/github.com/blang/semver/json.go new file mode 100644 index 0000000000..a74bf7c449 --- /dev/null +++ b/vendor/github.com/blang/semver/json.go @@ -0,0 +1,23 @@ +package semver + +import ( + "encoding/json" +) + +// MarshalJSON implements the encoding/json.Marshaler interface. +func (v Version) MarshalJSON() ([]byte, error) { + return json.Marshal(v.String()) +} + +// UnmarshalJSON implements the encoding/json.Unmarshaler interface. +func (v *Version) UnmarshalJSON(data []byte) (err error) { + var versionString string + + if err = json.Unmarshal(data, &versionString); err != nil { + return + } + + *v, err = Parse(versionString) + + return +} diff --git a/vendor/github.com/blang/semver/json_test.go b/vendor/github.com/blang/semver/json_test.go new file mode 100644 index 0000000000..c635dea16f --- /dev/null +++ b/vendor/github.com/blang/semver/json_test.go @@ -0,0 +1,49 @@ +package semver + +import ( + "encoding/json" + "strconv" + "testing" +) + +func TestJSONMarshal(t *testing.T) { + versionString := "3.1.4-alpha.1.5.9+build.2.6.5" + v, err := Parse(versionString) + if err != nil { + t.Fatal(err) + } + + versionJSON, err := json.Marshal(v) + if err != nil { + t.Fatal(err) + } + + quotedVersionString := strconv.Quote(versionString) + + if string(versionJSON) != quotedVersionString { + t.Fatalf("JSON marshaled semantic version not equal: expected %q, got %q", quotedVersionString, string(versionJSON)) + } +} + +func TestJSONUnmarshal(t *testing.T) { + versionString := "3.1.4-alpha.1.5.9+build.2.6.5" + quotedVersionString := strconv.Quote(versionString) + + var v Version + if err := json.Unmarshal([]byte(quotedVersionString), &v); err != nil { + t.Fatal(err) + } + + if v.String() != versionString { + t.Fatalf("JSON unmarshaled semantic version not equal: expected %q, got %q", versionString, v.String()) + } + + badVersionString := strconv.Quote("3.1.4.1.5.9.2.6.5-other-digits-of-pi") + if err := json.Unmarshal([]byte(badVersionString), &v); err == nil { + t.Fatal("expected JSON unmarshal error, got nil") + } + + if err := json.Unmarshal([]byte("3.1"), &v); err == nil { + t.Fatal("expected JSON unmarshal error, got nil") + } +} diff --git a/vendor/github.com/blang/semver/package.json b/vendor/github.com/blang/semver/package.json new file mode 100644 index 0000000000..78e27c5cdd --- /dev/null +++ b/vendor/github.com/blang/semver/package.json @@ -0,0 +1,17 @@ +{ + "author": "blang", + "bugs": { + "URL": "https://github.com/blang/semver/issues", + "url": "https://github.com/blang/semver/issues" + }, + "gx": { + "dvcsimport": "github.com/blang/semver" + }, + "gxVersion": "0.10.0", + "language": "go", + "license": "MIT", + "name": "semver", + "releaseCmd": "git commit -a -m \"gx publish $VERSION\"", + "version": "3.6.1" +} + diff --git a/vendor/github.com/blang/semver/range.go b/vendor/github.com/blang/semver/range.go new file mode 100644 index 0000000000..95f7139b97 --- /dev/null +++ b/vendor/github.com/blang/semver/range.go @@ -0,0 +1,416 @@ +package semver + +import ( + "fmt" + "strconv" + "strings" + "unicode" +) + +type wildcardType int + +const ( + noneWildcard wildcardType = iota + majorWildcard wildcardType = 1 + minorWildcard wildcardType = 2 + patchWildcard wildcardType = 3 +) + +func wildcardTypefromInt(i int) wildcardType { + switch i { + case 1: + return majorWildcard + case 2: + return minorWildcard + case 3: + return patchWildcard + default: + return noneWildcard + } +} + +type comparator func(Version, Version) bool + +var ( + compEQ comparator = func(v1 Version, v2 Version) bool { + return v1.Compare(v2) == 0 + } + compNE = func(v1 Version, v2 Version) bool { + return v1.Compare(v2) != 0 + } + compGT = func(v1 Version, v2 Version) bool { + return v1.Compare(v2) == 1 + } + compGE = func(v1 Version, v2 Version) bool { + return v1.Compare(v2) >= 0 + } + compLT = func(v1 Version, v2 Version) bool { + return v1.Compare(v2) == -1 + } + compLE = func(v1 Version, v2 Version) bool { + return v1.Compare(v2) <= 0 + } +) + +type versionRange struct { + v Version + c comparator +} + +// rangeFunc creates a Range from the given versionRange. +func (vr *versionRange) rangeFunc() Range { + return Range(func(v Version) bool { + return vr.c(v, vr.v) + }) +} + +// Range represents a range of versions. +// A Range can be used to check if a Version satisfies it: +// +// range, err := semver.ParseRange(">1.0.0 <2.0.0") +// range(semver.MustParse("1.1.1") // returns true +type Range func(Version) bool + +// OR combines the existing Range with another Range using logical OR. +func (rf Range) OR(f Range) Range { + return Range(func(v Version) bool { + return rf(v) || f(v) + }) +} + +// AND combines the existing Range with another Range using logical AND. +func (rf Range) AND(f Range) Range { + return Range(func(v Version) bool { + return rf(v) && f(v) + }) +} + +// ParseRange parses a range and returns a Range. +// If the range could not be parsed an error is returned. +// +// Valid ranges are: +// - "<1.0.0" +// - "<=1.0.0" +// - ">1.0.0" +// - ">=1.0.0" +// - "1.0.0", "=1.0.0", "==1.0.0" +// - "!1.0.0", "!=1.0.0" +// +// A Range can consist of multiple ranges separated by space: +// Ranges can be linked by logical AND: +// - ">1.0.0 <2.0.0" would match between both ranges, so "1.1.1" and "1.8.7" but not "1.0.0" or "2.0.0" +// - ">1.0.0 <3.0.0 !2.0.3-beta.2" would match every version between 1.0.0 and 3.0.0 except 2.0.3-beta.2 +// +// Ranges can also be linked by logical OR: +// - "<2.0.0 || >=3.0.0" would match "1.x.x" and "3.x.x" but not "2.x.x" +// +// AND has a higher precedence than OR. It's not possible to use brackets. +// +// Ranges can be combined by both AND and OR +// +// - `>1.0.0 <2.0.0 || >3.0.0 !4.2.1` would match `1.2.3`, `1.9.9`, `3.1.1`, but not `4.2.1`, `2.1.1` +func ParseRange(s string) (Range, error) { + parts := splitAndTrim(s) + orParts, err := splitORParts(parts) + if err != nil { + return nil, err + } + expandedParts, err := expandWildcardVersion(orParts) + if err != nil { + return nil, err + } + var orFn Range + for _, p := range expandedParts { + var andFn Range + for _, ap := range p { + opStr, vStr, err := splitComparatorVersion(ap) + if err != nil { + return nil, err + } + vr, err := buildVersionRange(opStr, vStr) + if err != nil { + return nil, fmt.Errorf("Could not parse Range %q: %s", ap, err) + } + rf := vr.rangeFunc() + + // Set function + if andFn == nil { + andFn = rf + } else { // Combine with existing function + andFn = andFn.AND(rf) + } + } + if orFn == nil { + orFn = andFn + } else { + orFn = orFn.OR(andFn) + } + + } + return orFn, nil +} + +// splitORParts splits the already cleaned parts by '||'. +// Checks for invalid positions of the operator and returns an +// error if found. +func splitORParts(parts []string) ([][]string, error) { + var ORparts [][]string + last := 0 + for i, p := range parts { + if p == "||" { + if i == 0 { + return nil, fmt.Errorf("First element in range is '||'") + } + ORparts = append(ORparts, parts[last:i]) + last = i + 1 + } + } + if last == len(parts) { + return nil, fmt.Errorf("Last element in range is '||'") + } + ORparts = append(ORparts, parts[last:]) + return ORparts, nil +} + +// buildVersionRange takes a slice of 2: operator and version +// and builds a versionRange, otherwise an error. +func buildVersionRange(opStr, vStr string) (*versionRange, error) { + c := parseComparator(opStr) + if c == nil { + return nil, fmt.Errorf("Could not parse comparator %q in %q", opStr, strings.Join([]string{opStr, vStr}, "")) + } + v, err := Parse(vStr) + if err != nil { + return nil, fmt.Errorf("Could not parse version %q in %q: %s", vStr, strings.Join([]string{opStr, vStr}, ""), err) + } + + return &versionRange{ + v: v, + c: c, + }, nil + +} + +// inArray checks if a byte is contained in an array of bytes +func inArray(s byte, list []byte) bool { + for _, el := range list { + if el == s { + return true + } + } + return false +} + +// splitAndTrim splits a range string by spaces and cleans whitespaces +func splitAndTrim(s string) (result []string) { + last := 0 + var lastChar byte + excludeFromSplit := []byte{'>', '<', '='} + for i := 0; i < len(s); i++ { + if s[i] == ' ' && !inArray(lastChar, excludeFromSplit) { + if last < i-1 { + result = append(result, s[last:i]) + } + last = i + 1 + } else if s[i] != ' ' { + lastChar = s[i] + } + } + if last < len(s)-1 { + result = append(result, s[last:]) + } + + for i, v := range result { + result[i] = strings.Replace(v, " ", "", -1) + } + + // parts := strings.Split(s, " ") + // for _, x := range parts { + // if s := strings.TrimSpace(x); len(s) != 0 { + // result = append(result, s) + // } + // } + return +} + +// splitComparatorVersion splits the comparator from the version. +// Input must be free of leading or trailing spaces. +func splitComparatorVersion(s string) (string, string, error) { + i := strings.IndexFunc(s, unicode.IsDigit) + if i == -1 { + return "", "", fmt.Errorf("Could not get version from string: %q", s) + } + return strings.TrimSpace(s[0:i]), s[i:], nil +} + +// getWildcardType will return the type of wildcard that the +// passed version contains +func getWildcardType(vStr string) wildcardType { + parts := strings.Split(vStr, ".") + nparts := len(parts) + wildcard := parts[nparts-1] + + possibleWildcardType := wildcardTypefromInt(nparts) + if wildcard == "x" { + return possibleWildcardType + } + + return noneWildcard +} + +// createVersionFromWildcard will convert a wildcard version +// into a regular version, replacing 'x's with '0's, handling +// special cases like '1.x.x' and '1.x' +func createVersionFromWildcard(vStr string) string { + // handle 1.x.x + vStr2 := strings.Replace(vStr, ".x.x", ".x", 1) + vStr2 = strings.Replace(vStr2, ".x", ".0", 1) + parts := strings.Split(vStr2, ".") + + // handle 1.x + if len(parts) == 2 { + return vStr2 + ".0" + } + + return vStr2 +} + +// incrementMajorVersion will increment the major version +// of the passed version +func incrementMajorVersion(vStr string) (string, error) { + parts := strings.Split(vStr, ".") + i, err := strconv.Atoi(parts[0]) + if err != nil { + return "", err + } + parts[0] = strconv.Itoa(i + 1) + + return strings.Join(parts, "."), nil +} + +// incrementMajorVersion will increment the minor version +// of the passed version +func incrementMinorVersion(vStr string) (string, error) { + parts := strings.Split(vStr, ".") + i, err := strconv.Atoi(parts[1]) + if err != nil { + return "", err + } + parts[1] = strconv.Itoa(i + 1) + + return strings.Join(parts, "."), nil +} + +// expandWildcardVersion will expand wildcards inside versions +// following these rules: +// +// * when dealing with patch wildcards: +// >= 1.2.x will become >= 1.2.0 +// <= 1.2.x will become < 1.3.0 +// > 1.2.x will become >= 1.3.0 +// < 1.2.x will become < 1.2.0 +// != 1.2.x will become < 1.2.0 >= 1.3.0 +// +// * when dealing with minor wildcards: +// >= 1.x will become >= 1.0.0 +// <= 1.x will become < 2.0.0 +// > 1.x will become >= 2.0.0 +// < 1.0 will become < 1.0.0 +// != 1.x will become < 1.0.0 >= 2.0.0 +// +// * when dealing with wildcards without +// version operator: +// 1.2.x will become >= 1.2.0 < 1.3.0 +// 1.x will become >= 1.0.0 < 2.0.0 +func expandWildcardVersion(parts [][]string) ([][]string, error) { + var expandedParts [][]string + for _, p := range parts { + var newParts []string + for _, ap := range p { + if strings.Contains(ap, "x") { + opStr, vStr, err := splitComparatorVersion(ap) + if err != nil { + return nil, err + } + + versionWildcardType := getWildcardType(vStr) + flatVersion := createVersionFromWildcard(vStr) + + var resultOperator string + var shouldIncrementVersion bool + switch opStr { + case ">": + resultOperator = ">=" + shouldIncrementVersion = true + case ">=": + resultOperator = ">=" + case "<": + resultOperator = "<" + case "<=": + resultOperator = "<" + shouldIncrementVersion = true + case "", "=", "==": + newParts = append(newParts, ">="+flatVersion) + resultOperator = "<" + shouldIncrementVersion = true + case "!=", "!": + newParts = append(newParts, "<"+flatVersion) + resultOperator = ">=" + shouldIncrementVersion = true + } + + var resultVersion string + if shouldIncrementVersion { + switch versionWildcardType { + case patchWildcard: + resultVersion, _ = incrementMinorVersion(flatVersion) + case minorWildcard: + resultVersion, _ = incrementMajorVersion(flatVersion) + } + } else { + resultVersion = flatVersion + } + + ap = resultOperator + resultVersion + } + newParts = append(newParts, ap) + } + expandedParts = append(expandedParts, newParts) + } + + return expandedParts, nil +} + +func parseComparator(s string) comparator { + switch s { + case "==": + fallthrough + case "": + fallthrough + case "=": + return compEQ + case ">": + return compGT + case ">=": + return compGE + case "<": + return compLT + case "<=": + return compLE + case "!": + fallthrough + case "!=": + return compNE + } + + return nil +} + +// MustParseRange is like ParseRange but panics if the range cannot be parsed. +func MustParseRange(s string) Range { + r, err := ParseRange(s) + if err != nil { + panic(`semver: ParseRange(` + s + `): ` + err.Error()) + } + return r +} diff --git a/vendor/github.com/blang/semver/range_test.go b/vendor/github.com/blang/semver/range_test.go new file mode 100644 index 0000000000..fc116704f9 --- /dev/null +++ b/vendor/github.com/blang/semver/range_test.go @@ -0,0 +1,581 @@ +package semver + +import ( + "reflect" + "strings" + "testing" +) + +type wildcardTypeTest struct { + input string + wildcardType wildcardType +} + +type comparatorTest struct { + input string + comparator func(comparator) bool +} + +func TestParseComparator(t *testing.T) { + compatorTests := []comparatorTest{ + {">", testGT}, + {">=", testGE}, + {"<", testLT}, + {"<=", testLE}, + {"", testEQ}, + {"=", testEQ}, + {"==", testEQ}, + {"!=", testNE}, + {"!", testNE}, + {"-", nil}, + {"<==", nil}, + {"<<", nil}, + {">>", nil}, + } + + for _, tc := range compatorTests { + if c := parseComparator(tc.input); c == nil { + if tc.comparator != nil { + t.Errorf("Comparator nil for case %q\n", tc.input) + } + } else if !tc.comparator(c) { + t.Errorf("Invalid comparator for case %q\n", tc.input) + } + } +} + +var ( + v1 = MustParse("1.2.2") + v2 = MustParse("1.2.3") + v3 = MustParse("1.2.4") +) + +func testEQ(f comparator) bool { + return f(v1, v1) && !f(v1, v2) +} + +func testNE(f comparator) bool { + return !f(v1, v1) && f(v1, v2) +} + +func testGT(f comparator) bool { + return f(v2, v1) && f(v3, v2) && !f(v1, v2) && !f(v1, v1) +} + +func testGE(f comparator) bool { + return f(v2, v1) && f(v3, v2) && !f(v1, v2) +} + +func testLT(f comparator) bool { + return f(v1, v2) && f(v2, v3) && !f(v2, v1) && !f(v1, v1) +} + +func testLE(f comparator) bool { + return f(v1, v2) && f(v2, v3) && !f(v2, v1) +} + +func TestSplitAndTrim(t *testing.T) { + tests := []struct { + i string + s []string + }{ + {"1.2.3 1.2.3", []string{"1.2.3", "1.2.3"}}, + {" 1.2.3 1.2.3 ", []string{"1.2.3", "1.2.3"}}, // Spaces + {" >= 1.2.3 <= 1.2.3 ", []string{">=1.2.3", "<=1.2.3"}}, // Spaces between operator and version + {"1.2.3 || >=1.2.3 <1.2.3", []string{"1.2.3", "||", ">=1.2.3", "<1.2.3"}}, + {" 1.2.3 || >=1.2.3 <1.2.3 ", []string{"1.2.3", "||", ">=1.2.3", "<1.2.3"}}, + } + + for _, tc := range tests { + p := splitAndTrim(tc.i) + if !reflect.DeepEqual(p, tc.s) { + t.Errorf("Invalid for case %q: Expected %q, got: %q", tc.i, tc.s, p) + } + } +} + +func TestSplitComparatorVersion(t *testing.T) { + tests := []struct { + i string + p []string + }{ + {">1.2.3", []string{">", "1.2.3"}}, + {">=1.2.3", []string{">=", "1.2.3"}}, + {"<1.2.3", []string{"<", "1.2.3"}}, + {"<=1.2.3", []string{"<=", "1.2.3"}}, + {"1.2.3", []string{"", "1.2.3"}}, + {"=1.2.3", []string{"=", "1.2.3"}}, + {"==1.2.3", []string{"==", "1.2.3"}}, + {"!=1.2.3", []string{"!=", "1.2.3"}}, + {"!1.2.3", []string{"!", "1.2.3"}}, + {"error", nil}, + } + for _, tc := range tests { + if op, v, err := splitComparatorVersion(tc.i); err != nil { + if tc.p != nil { + t.Errorf("Invalid for case %q: Expected %q, got error %q", tc.i, tc.p, err) + } + } else if op != tc.p[0] { + t.Errorf("Invalid operator for case %q: Expected %q, got: %q", tc.i, tc.p[0], op) + } else if v != tc.p[1] { + t.Errorf("Invalid version for case %q: Expected %q, got: %q", tc.i, tc.p[1], v) + } + + } +} + +func TestBuildVersionRange(t *testing.T) { + tests := []struct { + opStr string + vStr string + c func(comparator) bool + v string + }{ + {">", "1.2.3", testGT, "1.2.3"}, + {">=", "1.2.3", testGE, "1.2.3"}, + {"<", "1.2.3", testLT, "1.2.3"}, + {"<=", "1.2.3", testLE, "1.2.3"}, + {"", "1.2.3", testEQ, "1.2.3"}, + {"=", "1.2.3", testEQ, "1.2.3"}, + {"==", "1.2.3", testEQ, "1.2.3"}, + {"!=", "1.2.3", testNE, "1.2.3"}, + {"!", "1.2.3", testNE, "1.2.3"}, + {">>", "1.2.3", nil, ""}, // Invalid comparator + {"=", "invalid", nil, ""}, // Invalid version + } + + for _, tc := range tests { + if r, err := buildVersionRange(tc.opStr, tc.vStr); err != nil { + if tc.c != nil { + t.Errorf("Invalid for case %q: Expected %q, got error %q", strings.Join([]string{tc.opStr, tc.vStr}, ""), tc.v, err) + } + } else if r == nil { + t.Errorf("Invalid for case %q: got nil", strings.Join([]string{tc.opStr, tc.vStr}, "")) + } else { + // test version + if tv := MustParse(tc.v); !r.v.EQ(tv) { + t.Errorf("Invalid for case %q: Expected version %q, got: %q", strings.Join([]string{tc.opStr, tc.vStr}, ""), tv, r.v) + } + // test comparator + if r.c == nil { + t.Errorf("Invalid for case %q: got nil comparator", strings.Join([]string{tc.opStr, tc.vStr}, "")) + continue + } + if !tc.c(r.c) { + t.Errorf("Invalid comparator for case %q\n", strings.Join([]string{tc.opStr, tc.vStr}, "")) + } + } + } + +} + +func TestSplitORParts(t *testing.T) { + tests := []struct { + i []string + o [][]string + }{ + {[]string{">1.2.3", "||", "<1.2.3", "||", "=1.2.3"}, [][]string{ + {">1.2.3"}, + {"<1.2.3"}, + {"=1.2.3"}, + }}, + {[]string{">1.2.3", "<1.2.3", "||", "=1.2.3"}, [][]string{ + {">1.2.3", "<1.2.3"}, + {"=1.2.3"}, + }}, + {[]string{">1.2.3", "||"}, nil}, + {[]string{"||", ">1.2.3"}, nil}, + } + for _, tc := range tests { + o, err := splitORParts(tc.i) + if err != nil && tc.o != nil { + t.Errorf("Unexpected error for case %q: %s", tc.i, err) + } + if !reflect.DeepEqual(tc.o, o) { + t.Errorf("Invalid for case %q: Expected %q, got: %q", tc.i, tc.o, o) + } + } +} + +func TestGetWildcardType(t *testing.T) { + wildcardTypeTests := []wildcardTypeTest{ + {"x", majorWildcard}, + {"1.x", minorWildcard}, + {"1.2.x", patchWildcard}, + {"fo.o.b.ar", noneWildcard}, + } + + for _, tc := range wildcardTypeTests { + o := getWildcardType(tc.input) + if o != tc.wildcardType { + t.Errorf("Invalid for case: %q: Expected %q, got: %q", tc.input, tc.wildcardType, o) + } + } +} + +func TestCreateVersionFromWildcard(t *testing.T) { + tests := []struct { + i string + s string + }{ + {"1.2.x", "1.2.0"}, + {"1.x", "1.0.0"}, + } + + for _, tc := range tests { + p := createVersionFromWildcard(tc.i) + if p != tc.s { + t.Errorf("Invalid for case %q: Expected %q, got: %q", tc.i, tc.s, p) + } + } +} + +func TestIncrementMajorVersion(t *testing.T) { + tests := []struct { + i string + s string + }{ + {"1.2.3", "2.2.3"}, + {"1.2", "2.2"}, + {"foo.bar", ""}, + } + + for _, tc := range tests { + p, _ := incrementMajorVersion(tc.i) + if p != tc.s { + t.Errorf("Invalid for case %q: Expected %q, got: %q", tc.i, tc.s, p) + } + } +} + +func TestIncrementMinorVersion(t *testing.T) { + tests := []struct { + i string + s string + }{ + {"1.2.3", "1.3.3"}, + {"1.2", "1.3"}, + {"foo.bar", ""}, + } + + for _, tc := range tests { + p, _ := incrementMinorVersion(tc.i) + if p != tc.s { + t.Errorf("Invalid for case %q: Expected %q, got: %q", tc.i, tc.s, p) + } + } +} + +func TestExpandWildcardVersion(t *testing.T) { + tests := []struct { + i [][]string + o [][]string + }{ + {[][]string{{"foox"}}, nil}, + {[][]string{{">=1.2.x"}}, [][]string{{">=1.2.0"}}}, + {[][]string{{"<=1.2.x"}}, [][]string{{"<1.3.0"}}}, + {[][]string{{">1.2.x"}}, [][]string{{">=1.3.0"}}}, + {[][]string{{"<1.2.x"}}, [][]string{{"<1.2.0"}}}, + {[][]string{{"!=1.2.x"}}, [][]string{{"<1.2.0", ">=1.3.0"}}}, + {[][]string{{">=1.x"}}, [][]string{{">=1.0.0"}}}, + {[][]string{{"<=1.x"}}, [][]string{{"<2.0.0"}}}, + {[][]string{{">1.x"}}, [][]string{{">=2.0.0"}}}, + {[][]string{{"<1.x"}}, [][]string{{"<1.0.0"}}}, + {[][]string{{"!=1.x"}}, [][]string{{"<1.0.0", ">=2.0.0"}}}, + {[][]string{{"1.2.x"}}, [][]string{{">=1.2.0", "<1.3.0"}}}, + {[][]string{{"1.x"}}, [][]string{{">=1.0.0", "<2.0.0"}}}, + } + + for _, tc := range tests { + o, _ := expandWildcardVersion(tc.i) + if !reflect.DeepEqual(tc.o, o) { + t.Errorf("Invalid for case %q: Expected %q, got: %q", tc.i, tc.o, o) + } + } +} + +func TestVersionRangeToRange(t *testing.T) { + vr := versionRange{ + v: MustParse("1.2.3"), + c: compLT, + } + rf := vr.rangeFunc() + if !rf(MustParse("1.2.2")) || rf(MustParse("1.2.3")) { + t.Errorf("Invalid conversion to range func") + } +} + +func TestRangeAND(t *testing.T) { + v := MustParse("1.2.2") + v1 := MustParse("1.2.1") + v2 := MustParse("1.2.3") + rf1 := Range(func(v Version) bool { + return v.GT(v1) + }) + rf2 := Range(func(v Version) bool { + return v.LT(v2) + }) + rf := rf1.AND(rf2) + if rf(v1) { + t.Errorf("Invalid rangefunc, accepted: %s", v1) + } + if rf(v2) { + t.Errorf("Invalid rangefunc, accepted: %s", v2) + } + if !rf(v) { + t.Errorf("Invalid rangefunc, did not accept: %s", v) + } +} + +func TestRangeOR(t *testing.T) { + tests := []struct { + v Version + b bool + }{ + {MustParse("1.2.0"), true}, + {MustParse("1.2.2"), false}, + {MustParse("1.2.4"), true}, + } + v1 := MustParse("1.2.1") + v2 := MustParse("1.2.3") + rf1 := Range(func(v Version) bool { + return v.LT(v1) + }) + rf2 := Range(func(v Version) bool { + return v.GT(v2) + }) + rf := rf1.OR(rf2) + for _, tc := range tests { + if r := rf(tc.v); r != tc.b { + t.Errorf("Invalid for case %q: Expected %t, got %t", tc.v, tc.b, r) + } + } +} + +func TestParseRange(t *testing.T) { + type tv struct { + v string + b bool + } + tests := []struct { + i string + t []tv + }{ + // Simple expressions + {">1.2.3", []tv{ + {"1.2.2", false}, + {"1.2.3", false}, + {"1.2.4", true}, + }}, + {">=1.2.3", []tv{ + {"1.2.3", true}, + {"1.2.4", true}, + {"1.2.2", false}, + }}, + {"<1.2.3", []tv{ + {"1.2.2", true}, + {"1.2.3", false}, + {"1.2.4", false}, + }}, + {"<=1.2.3", []tv{ + {"1.2.2", true}, + {"1.2.3", true}, + {"1.2.4", false}, + }}, + {"1.2.3", []tv{ + {"1.2.2", false}, + {"1.2.3", true}, + {"1.2.4", false}, + }}, + {"=1.2.3", []tv{ + {"1.2.2", false}, + {"1.2.3", true}, + {"1.2.4", false}, + }}, + {"==1.2.3", []tv{ + {"1.2.2", false}, + {"1.2.3", true}, + {"1.2.4", false}, + }}, + {"!=1.2.3", []tv{ + {"1.2.2", true}, + {"1.2.3", false}, + {"1.2.4", true}, + }}, + {"!1.2.3", []tv{ + {"1.2.2", true}, + {"1.2.3", false}, + {"1.2.4", true}, + }}, + // Simple Expression errors + {">>1.2.3", nil}, + {"!1.2.3", nil}, + {"1.0", nil}, + {"string", nil}, + {"", nil}, + {"fo.ob.ar.x", nil}, + // AND Expressions + {">1.2.2 <1.2.4", []tv{ + {"1.2.2", false}, + {"1.2.3", true}, + {"1.2.4", false}, + }}, + {"<1.2.2 <1.2.4", []tv{ + {"1.2.1", true}, + {"1.2.2", false}, + {"1.2.3", false}, + {"1.2.4", false}, + }}, + {">1.2.2 <1.2.5 !=1.2.4", []tv{ + {"1.2.2", false}, + {"1.2.3", true}, + {"1.2.4", false}, + {"1.2.5", false}, + }}, + {">1.2.2 <1.2.5 !1.2.4", []tv{ + {"1.2.2", false}, + {"1.2.3", true}, + {"1.2.4", false}, + {"1.2.5", false}, + }}, + // OR Expressions + {">1.2.2 || <1.2.4", []tv{ + {"1.2.2", true}, + {"1.2.3", true}, + {"1.2.4", true}, + }}, + {"<1.2.2 || >1.2.4", []tv{ + {"1.2.2", false}, + {"1.2.3", false}, + {"1.2.4", false}, + }}, + // Wildcard expressions + {">1.x", []tv{ + {"0.1.9", false}, + {"1.2.6", false}, + {"1.9.0", false}, + {"2.0.0", true}, + }}, + {">1.2.x", []tv{ + {"1.1.9", false}, + {"1.2.6", false}, + {"1.3.0", true}, + }}, + // Combined Expressions + {">1.2.2 <1.2.4 || >=2.0.0", []tv{ + {"1.2.2", false}, + {"1.2.3", true}, + {"1.2.4", false}, + {"2.0.0", true}, + {"2.0.1", true}, + }}, + {"1.x || >=2.0.x <2.2.x", []tv{ + {"0.9.2", false}, + {"1.2.2", true}, + {"2.0.0", true}, + {"2.1.8", true}, + {"2.2.0", false}, + }}, + {">1.2.2 <1.2.4 || >=2.0.0 <3.0.0", []tv{ + {"1.2.2", false}, + {"1.2.3", true}, + {"1.2.4", false}, + {"2.0.0", true}, + {"2.0.1", true}, + {"2.9.9", true}, + {"3.0.0", false}, + }}, + } + + for _, tc := range tests { + r, err := ParseRange(tc.i) + if err != nil && tc.t != nil { + t.Errorf("Error parsing range %q: %s", tc.i, err) + continue + } + for _, tvc := range tc.t { + v := MustParse(tvc.v) + if res := r(v); res != tvc.b { + t.Errorf("Invalid for case %q matching %q: Expected %t, got: %t", tc.i, tvc.v, tvc.b, res) + } + } + + } +} + +func TestMustParseRange(t *testing.T) { + testCase := ">1.2.2 <1.2.4 || >=2.0.0 <3.0.0" + r := MustParseRange(testCase) + if !r(MustParse("1.2.3")) { + t.Errorf("Unexpected range behavior on MustParseRange") + } +} + +func TestMustParseRange_panic(t *testing.T) { + defer func() { + if recover() == nil { + t.Errorf("Should have panicked") + } + }() + _ = MustParseRange("invalid version") +} + +func BenchmarkRangeParseSimple(b *testing.B) { + const VERSION = ">1.0.0" + b.ReportAllocs() + b.ResetTimer() + for n := 0; n < b.N; n++ { + ParseRange(VERSION) + } +} + +func BenchmarkRangeParseAverage(b *testing.B) { + const VERSION = ">=1.0.0 <2.0.0" + b.ReportAllocs() + b.ResetTimer() + for n := 0; n < b.N; n++ { + ParseRange(VERSION) + } +} + +func BenchmarkRangeParseComplex(b *testing.B) { + const VERSION = ">=1.0.0 <2.0.0 || >=3.0.1 <4.0.0 !=3.0.3 || >=5.0.0" + b.ReportAllocs() + b.ResetTimer() + for n := 0; n < b.N; n++ { + ParseRange(VERSION) + } +} + +func BenchmarkRangeMatchSimple(b *testing.B) { + const VERSION = ">1.0.0" + r, _ := ParseRange(VERSION) + v := MustParse("2.0.0") + b.ReportAllocs() + b.ResetTimer() + for n := 0; n < b.N; n++ { + r(v) + } +} + +func BenchmarkRangeMatchAverage(b *testing.B) { + const VERSION = ">=1.0.0 <2.0.0" + r, _ := ParseRange(VERSION) + v := MustParse("1.2.3") + b.ReportAllocs() + b.ResetTimer() + for n := 0; n < b.N; n++ { + r(v) + } +} + +func BenchmarkRangeMatchComplex(b *testing.B) { + const VERSION = ">=1.0.0 <2.0.0 || >=3.0.1 <4.0.0 !=3.0.3 || >=5.0.0" + r, _ := ParseRange(VERSION) + v := MustParse("5.0.1") + b.ReportAllocs() + b.ResetTimer() + for n := 0; n < b.N; n++ { + r(v) + } +} diff --git a/vendor/github.com/blang/semver/semver.go b/vendor/github.com/blang/semver/semver.go new file mode 100644 index 0000000000..4165bc791e --- /dev/null +++ b/vendor/github.com/blang/semver/semver.go @@ -0,0 +1,455 @@ +package semver + +import ( + "errors" + "fmt" + "strconv" + "strings" +) + +const ( + numbers string = "0123456789" + alphas = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-" + alphanum = alphas + numbers +) + +// SpecVersion is the latest fully supported spec version of semver +var SpecVersion = Version{ + Major: 2, + Minor: 0, + Patch: 0, +} + +// Version represents a semver compatible version +type Version struct { + Major uint64 + Minor uint64 + Patch uint64 + Pre []PRVersion + Build []string //No Precedence +} + +// Version to string +func (v Version) String() string { + b := make([]byte, 0, 5) + b = strconv.AppendUint(b, v.Major, 10) + b = append(b, '.') + b = strconv.AppendUint(b, v.Minor, 10) + b = append(b, '.') + b = strconv.AppendUint(b, v.Patch, 10) + + if len(v.Pre) > 0 { + b = append(b, '-') + b = append(b, v.Pre[0].String()...) + + for _, pre := range v.Pre[1:] { + b = append(b, '.') + b = append(b, pre.String()...) + } + } + + if len(v.Build) > 0 { + b = append(b, '+') + b = append(b, v.Build[0]...) + + for _, build := range v.Build[1:] { + b = append(b, '.') + b = append(b, build...) + } + } + + return string(b) +} + +// Equals checks if v is equal to o. +func (v Version) Equals(o Version) bool { + return (v.Compare(o) == 0) +} + +// EQ checks if v is equal to o. +func (v Version) EQ(o Version) bool { + return (v.Compare(o) == 0) +} + +// NE checks if v is not equal to o. +func (v Version) NE(o Version) bool { + return (v.Compare(o) != 0) +} + +// GT checks if v is greater than o. +func (v Version) GT(o Version) bool { + return (v.Compare(o) == 1) +} + +// GTE checks if v is greater than or equal to o. +func (v Version) GTE(o Version) bool { + return (v.Compare(o) >= 0) +} + +// GE checks if v is greater than or equal to o. +func (v Version) GE(o Version) bool { + return (v.Compare(o) >= 0) +} + +// LT checks if v is less than o. +func (v Version) LT(o Version) bool { + return (v.Compare(o) == -1) +} + +// LTE checks if v is less than or equal to o. +func (v Version) LTE(o Version) bool { + return (v.Compare(o) <= 0) +} + +// LE checks if v is less than or equal to o. +func (v Version) LE(o Version) bool { + return (v.Compare(o) <= 0) +} + +// Compare compares Versions v to o: +// -1 == v is less than o +// 0 == v is equal to o +// 1 == v is greater than o +func (v Version) Compare(o Version) int { + if v.Major != o.Major { + if v.Major > o.Major { + return 1 + } + return -1 + } + if v.Minor != o.Minor { + if v.Minor > o.Minor { + return 1 + } + return -1 + } + if v.Patch != o.Patch { + if v.Patch > o.Patch { + return 1 + } + return -1 + } + + // Quick comparison if a version has no prerelease versions + if len(v.Pre) == 0 && len(o.Pre) == 0 { + return 0 + } else if len(v.Pre) == 0 && len(o.Pre) > 0 { + return 1 + } else if len(v.Pre) > 0 && len(o.Pre) == 0 { + return -1 + } + + i := 0 + for ; i < len(v.Pre) && i < len(o.Pre); i++ { + if comp := v.Pre[i].Compare(o.Pre[i]); comp == 0 { + continue + } else if comp == 1 { + return 1 + } else { + return -1 + } + } + + // If all pr versions are the equal but one has further prversion, this one greater + if i == len(v.Pre) && i == len(o.Pre) { + return 0 + } else if i == len(v.Pre) && i < len(o.Pre) { + return -1 + } else { + return 1 + } + +} + +// IncrementPatch increments the patch version +func (v *Version) IncrementPatch() error { + if v.Major == 0 { + return fmt.Errorf("Patch version can not be incremented for %q", v.String()) + } + v.Patch += 1 + return nil +} + +// IncrementMinor increments the minor version +func (v *Version) IncrementMinor() error { + if v.Major == 0 { + return fmt.Errorf("Minor version can not be incremented for %q", v.String()) + } + v.Minor += 1 + v.Patch = 0 + return nil +} + +// IncrementMajor increments the major version +func (v *Version) IncrementMajor() error { + if v.Major == 0 { + return fmt.Errorf("Major version can not be incremented for %q", v.String()) + } + v.Major += 1 + v.Minor = 0 + v.Patch = 0 + return nil +} + +// Validate validates v and returns error in case +func (v Version) Validate() error { + // Major, Minor, Patch already validated using uint64 + + for _, pre := range v.Pre { + if !pre.IsNum { //Numeric prerelease versions already uint64 + if len(pre.VersionStr) == 0 { + return fmt.Errorf("Prerelease can not be empty %q", pre.VersionStr) + } + if !containsOnly(pre.VersionStr, alphanum) { + return fmt.Errorf("Invalid character(s) found in prerelease %q", pre.VersionStr) + } + } + } + + for _, build := range v.Build { + if len(build) == 0 { + return fmt.Errorf("Build meta data can not be empty %q", build) + } + if !containsOnly(build, alphanum) { + return fmt.Errorf("Invalid character(s) found in build meta data %q", build) + } + } + + return nil +} + +// New is an alias for Parse and returns a pointer, parses version string and returns a validated Version or error +func New(s string) (vp *Version, err error) { + v, err := Parse(s) + vp = &v + return +} + +// Make is an alias for Parse, parses version string and returns a validated Version or error +func Make(s string) (Version, error) { + return Parse(s) +} + +// ParseTolerant allows for certain version specifications that do not strictly adhere to semver +// specs to be parsed by this library. It does so by normalizing versions before passing them to +// Parse(). It currently trims spaces, removes a "v" prefix, adds a 0 patch number to versions +// with only major and minor components specified, and removes leading 0s. +func ParseTolerant(s string) (Version, error) { + s = strings.TrimSpace(s) + s = strings.TrimPrefix(s, "v") + + // Split into major.minor.(patch+pr+meta) + parts := strings.SplitN(s, ".", 3) + // Remove leading zeros. + for i, p := range parts { + if len(p) > 1 { + parts[i] = strings.TrimPrefix(p, "0") + } + } + // Fill up shortened versions. + if len(parts) < 3 { + if strings.ContainsAny(parts[len(parts)-1], "+-") { + return Version{}, errors.New("Short version cannot contain PreRelease/Build meta data") + } + for len(parts) < 3 { + parts = append(parts, "0") + } + } + s = strings.Join(parts, ".") + + return Parse(s) +} + +// Parse parses version string and returns a validated Version or error +func Parse(s string) (Version, error) { + if len(s) == 0 { + return Version{}, errors.New("Version string empty") + } + + // Split into major.minor.(patch+pr+meta) + parts := strings.SplitN(s, ".", 3) + if len(parts) != 3 { + return Version{}, errors.New("No Major.Minor.Patch elements found") + } + + // Major + if !containsOnly(parts[0], numbers) { + return Version{}, fmt.Errorf("Invalid character(s) found in major number %q", parts[0]) + } + if hasLeadingZeroes(parts[0]) { + return Version{}, fmt.Errorf("Major number must not contain leading zeroes %q", parts[0]) + } + major, err := strconv.ParseUint(parts[0], 10, 64) + if err != nil { + return Version{}, err + } + + // Minor + if !containsOnly(parts[1], numbers) { + return Version{}, fmt.Errorf("Invalid character(s) found in minor number %q", parts[1]) + } + if hasLeadingZeroes(parts[1]) { + return Version{}, fmt.Errorf("Minor number must not contain leading zeroes %q", parts[1]) + } + minor, err := strconv.ParseUint(parts[1], 10, 64) + if err != nil { + return Version{}, err + } + + v := Version{} + v.Major = major + v.Minor = minor + + var build, prerelease []string + patchStr := parts[2] + + if buildIndex := strings.IndexRune(patchStr, '+'); buildIndex != -1 { + build = strings.Split(patchStr[buildIndex+1:], ".") + patchStr = patchStr[:buildIndex] + } + + if preIndex := strings.IndexRune(patchStr, '-'); preIndex != -1 { + prerelease = strings.Split(patchStr[preIndex+1:], ".") + patchStr = patchStr[:preIndex] + } + + if !containsOnly(patchStr, numbers) { + return Version{}, fmt.Errorf("Invalid character(s) found in patch number %q", patchStr) + } + if hasLeadingZeroes(patchStr) { + return Version{}, fmt.Errorf("Patch number must not contain leading zeroes %q", patchStr) + } + patch, err := strconv.ParseUint(patchStr, 10, 64) + if err != nil { + return Version{}, err + } + + v.Patch = patch + + // Prerelease + for _, prstr := range prerelease { + parsedPR, err := NewPRVersion(prstr) + if err != nil { + return Version{}, err + } + v.Pre = append(v.Pre, parsedPR) + } + + // Build meta data + for _, str := range build { + if len(str) == 0 { + return Version{}, errors.New("Build meta data is empty") + } + if !containsOnly(str, alphanum) { + return Version{}, fmt.Errorf("Invalid character(s) found in build meta data %q", str) + } + v.Build = append(v.Build, str) + } + + return v, nil +} + +// MustParse is like Parse but panics if the version cannot be parsed. +func MustParse(s string) Version { + v, err := Parse(s) + if err != nil { + panic(`semver: Parse(` + s + `): ` + err.Error()) + } + return v +} + +// PRVersion represents a PreRelease Version +type PRVersion struct { + VersionStr string + VersionNum uint64 + IsNum bool +} + +// NewPRVersion creates a new valid prerelease version +func NewPRVersion(s string) (PRVersion, error) { + if len(s) == 0 { + return PRVersion{}, errors.New("Prerelease is empty") + } + v := PRVersion{} + if containsOnly(s, numbers) { + if hasLeadingZeroes(s) { + return PRVersion{}, fmt.Errorf("Numeric PreRelease version must not contain leading zeroes %q", s) + } + num, err := strconv.ParseUint(s, 10, 64) + + // Might never be hit, but just in case + if err != nil { + return PRVersion{}, err + } + v.VersionNum = num + v.IsNum = true + } else if containsOnly(s, alphanum) { + v.VersionStr = s + v.IsNum = false + } else { + return PRVersion{}, fmt.Errorf("Invalid character(s) found in prerelease %q", s) + } + return v, nil +} + +// IsNumeric checks if prerelease-version is numeric +func (v PRVersion) IsNumeric() bool { + return v.IsNum +} + +// Compare compares two PreRelease Versions v and o: +// -1 == v is less than o +// 0 == v is equal to o +// 1 == v is greater than o +func (v PRVersion) Compare(o PRVersion) int { + if v.IsNum && !o.IsNum { + return -1 + } else if !v.IsNum && o.IsNum { + return 1 + } else if v.IsNum && o.IsNum { + if v.VersionNum == o.VersionNum { + return 0 + } else if v.VersionNum > o.VersionNum { + return 1 + } else { + return -1 + } + } else { // both are Alphas + if v.VersionStr == o.VersionStr { + return 0 + } else if v.VersionStr > o.VersionStr { + return 1 + } else { + return -1 + } + } +} + +// PreRelease version to string +func (v PRVersion) String() string { + if v.IsNum { + return strconv.FormatUint(v.VersionNum, 10) + } + return v.VersionStr +} + +func containsOnly(s string, set string) bool { + return strings.IndexFunc(s, func(r rune) bool { + return !strings.ContainsRune(set, r) + }) == -1 +} + +func hasLeadingZeroes(s string) bool { + return len(s) > 1 && s[0] == '0' +} + +// NewBuildVersion creates a new valid build version +func NewBuildVersion(s string) (string, error) { + if len(s) == 0 { + return "", errors.New("Buildversion is empty") + } + if !containsOnly(s, alphanum) { + return "", fmt.Errorf("Invalid character(s) found in build meta data %q", s) + } + return s, nil +} diff --git a/vendor/github.com/blang/semver/semver_test.go b/vendor/github.com/blang/semver/semver_test.go new file mode 100644 index 0000000000..8e5d80c709 --- /dev/null +++ b/vendor/github.com/blang/semver/semver_test.go @@ -0,0 +1,518 @@ +package semver + +import ( + "testing" +) + +func prstr(s string) PRVersion { + return PRVersion{s, 0, false} +} + +func prnum(i uint64) PRVersion { + return PRVersion{"", i, true} +} + +type formatTest struct { + v Version + result string +} + +var formatTests = []formatTest{ + {Version{1, 2, 3, nil, nil}, "1.2.3"}, + {Version{0, 0, 1, nil, nil}, "0.0.1"}, + {Version{0, 0, 1, []PRVersion{prstr("alpha"), prstr("preview")}, []string{"123", "456"}}, "0.0.1-alpha.preview+123.456"}, + {Version{1, 2, 3, []PRVersion{prstr("alpha"), prnum(1)}, []string{"123", "456"}}, "1.2.3-alpha.1+123.456"}, + {Version{1, 2, 3, []PRVersion{prstr("alpha"), prnum(1)}, nil}, "1.2.3-alpha.1"}, + {Version{1, 2, 3, nil, []string{"123", "456"}}, "1.2.3+123.456"}, + // Prereleases and build metadata hyphens + {Version{1, 2, 3, []PRVersion{prstr("alpha"), prstr("b-eta")}, []string{"123", "b-uild"}}, "1.2.3-alpha.b-eta+123.b-uild"}, + {Version{1, 2, 3, nil, []string{"123", "b-uild"}}, "1.2.3+123.b-uild"}, + {Version{1, 2, 3, []PRVersion{prstr("alpha"), prstr("b-eta")}, nil}, "1.2.3-alpha.b-eta"}, +} + +var tolerantFormatTests = []formatTest{ + {Version{1, 2, 3, nil, nil}, "v1.2.3"}, + {Version{1, 2, 3, nil, nil}, " 1.2.3 "}, + {Version{1, 2, 3, nil, nil}, "01.02.03"}, + {Version{0, 0, 3, nil, nil}, "00.0.03"}, + {Version{1, 2, 0, nil, nil}, "1.2"}, + {Version{1, 0, 0, nil, nil}, "1"}, +} + +func TestStringer(t *testing.T) { + for _, test := range formatTests { + if res := test.v.String(); res != test.result { + t.Errorf("Stringer, expected %q but got %q", test.result, res) + } + } +} + +func TestParse(t *testing.T) { + for _, test := range formatTests { + if v, err := Parse(test.result); err != nil { + t.Errorf("Error parsing %q: %q", test.result, err) + } else if comp := v.Compare(test.v); comp != 0 { + t.Errorf("Parsing, expected %q but got %q, comp: %d ", test.v, v, comp) + } else if err := v.Validate(); err != nil { + t.Errorf("Error validating parsed version %q: %q", test.v, err) + } + } +} + +func TestParseTolerant(t *testing.T) { + for _, test := range tolerantFormatTests { + if v, err := ParseTolerant(test.result); err != nil { + t.Errorf("Error parsing %q: %q", test.result, err) + } else if comp := v.Compare(test.v); comp != 0 { + t.Errorf("Parsing, expected %q but got %q, comp: %d ", test.v, v, comp) + } else if err := v.Validate(); err != nil { + t.Errorf("Error validating parsed version %q: %q", test.v, err) + } + } +} + +func TestMustParse(t *testing.T) { + _ = MustParse("32.2.1-alpha") +} + +func TestMustParse_panic(t *testing.T) { + defer func() { + if recover() == nil { + t.Errorf("Should have panicked") + } + }() + _ = MustParse("invalid version") +} + +func TestValidate(t *testing.T) { + for _, test := range formatTests { + if err := test.v.Validate(); err != nil { + t.Errorf("Error validating %q: %q", test.v, err) + } + } +} + +type compareTest struct { + v1 Version + v2 Version + result int +} + +var compareTests = []compareTest{ + {Version{1, 0, 0, nil, nil}, Version{1, 0, 0, nil, nil}, 0}, + {Version{2, 0, 0, nil, nil}, Version{1, 0, 0, nil, nil}, 1}, + {Version{0, 1, 0, nil, nil}, Version{0, 1, 0, nil, nil}, 0}, + {Version{0, 2, 0, nil, nil}, Version{0, 1, 0, nil, nil}, 1}, + {Version{0, 0, 1, nil, nil}, Version{0, 0, 1, nil, nil}, 0}, + {Version{0, 0, 2, nil, nil}, Version{0, 0, 1, nil, nil}, 1}, + {Version{1, 2, 3, nil, nil}, Version{1, 2, 3, nil, nil}, 0}, + {Version{2, 2, 4, nil, nil}, Version{1, 2, 4, nil, nil}, 1}, + {Version{1, 3, 3, nil, nil}, Version{1, 2, 3, nil, nil}, 1}, + {Version{1, 2, 4, nil, nil}, Version{1, 2, 3, nil, nil}, 1}, + + // Spec Examples #11 + {Version{1, 0, 0, nil, nil}, Version{2, 0, 0, nil, nil}, -1}, + {Version{2, 0, 0, nil, nil}, Version{2, 1, 0, nil, nil}, -1}, + {Version{2, 1, 0, nil, nil}, Version{2, 1, 1, nil, nil}, -1}, + + // Spec Examples #9 + {Version{1, 0, 0, nil, nil}, Version{1, 0, 0, []PRVersion{prstr("alpha")}, nil}, 1}, + {Version{1, 0, 0, []PRVersion{prstr("alpha")}, nil}, Version{1, 0, 0, []PRVersion{prstr("alpha"), prnum(1)}, nil}, -1}, + {Version{1, 0, 0, []PRVersion{prstr("alpha"), prnum(1)}, nil}, Version{1, 0, 0, []PRVersion{prstr("alpha"), prstr("beta")}, nil}, -1}, + {Version{1, 0, 0, []PRVersion{prstr("alpha"), prstr("beta")}, nil}, Version{1, 0, 0, []PRVersion{prstr("beta")}, nil}, -1}, + {Version{1, 0, 0, []PRVersion{prstr("beta")}, nil}, Version{1, 0, 0, []PRVersion{prstr("beta"), prnum(2)}, nil}, -1}, + {Version{1, 0, 0, []PRVersion{prstr("beta"), prnum(2)}, nil}, Version{1, 0, 0, []PRVersion{prstr("beta"), prnum(11)}, nil}, -1}, + {Version{1, 0, 0, []PRVersion{prstr("beta"), prnum(11)}, nil}, Version{1, 0, 0, []PRVersion{prstr("rc"), prnum(1)}, nil}, -1}, + {Version{1, 0, 0, []PRVersion{prstr("rc"), prnum(1)}, nil}, Version{1, 0, 0, nil, nil}, -1}, + + // Ignore Build metadata + {Version{1, 0, 0, nil, []string{"1", "2", "3"}}, Version{1, 0, 0, nil, nil}, 0}, +} + +func TestCompare(t *testing.T) { + for _, test := range compareTests { + if res := test.v1.Compare(test.v2); res != test.result { + t.Errorf("Comparing %q : %q, expected %d but got %d", test.v1, test.v2, test.result, res) + } + //Test counterpart + if res := test.v2.Compare(test.v1); res != -test.result { + t.Errorf("Comparing %q : %q, expected %d but got %d", test.v2, test.v1, -test.result, res) + } + } +} + +type wrongformatTest struct { + v *Version + str string +} + +var wrongformatTests = []wrongformatTest{ + {nil, ""}, + {nil, "."}, + {nil, "1."}, + {nil, ".1"}, + {nil, "a.b.c"}, + {nil, "1.a.b"}, + {nil, "1.1.a"}, + {nil, "1.a.1"}, + {nil, "a.1.1"}, + {nil, ".."}, + {nil, "1.."}, + {nil, "1.1."}, + {nil, "1..1"}, + {nil, "1.1.+123"}, + {nil, "1.1.-beta"}, + {nil, "-1.1.1"}, + {nil, "1.-1.1"}, + {nil, "1.1.-1"}, + // giant numbers + {nil, "20000000000000000000.1.1"}, + {nil, "1.20000000000000000000.1"}, + {nil, "1.1.20000000000000000000"}, + {nil, "1.1.1-20000000000000000000"}, + // Leading zeroes + {nil, "01.1.1"}, + {nil, "001.1.1"}, + {nil, "1.01.1"}, + {nil, "1.001.1"}, + {nil, "1.1.01"}, + {nil, "1.1.001"}, + {nil, "1.1.1-01"}, + {nil, "1.1.1-001"}, + {nil, "1.1.1-beta.01"}, + {nil, "1.1.1-beta.001"}, + {&Version{0, 0, 0, []PRVersion{prstr("!")}, nil}, "0.0.0-!"}, + {&Version{0, 0, 0, nil, []string{"!"}}, "0.0.0+!"}, + // empty prversion + {&Version{0, 0, 0, []PRVersion{prstr(""), prstr("alpha")}, nil}, "0.0.0-.alpha"}, + // empty build meta data + {&Version{0, 0, 0, []PRVersion{prstr("alpha")}, []string{""}}, "0.0.0-alpha+"}, + {&Version{0, 0, 0, []PRVersion{prstr("alpha")}, []string{"test", ""}}, "0.0.0-alpha+test."}, +} + +func TestWrongFormat(t *testing.T) { + for _, test := range wrongformatTests { + + if res, err := Parse(test.str); err == nil { + t.Errorf("Parsing wrong format version %q, expected error but got %q", test.str, res) + } + + if test.v != nil { + if err := test.v.Validate(); err == nil { + t.Errorf("Validating wrong format version %q (%q), expected error", test.v, test.str) + } + } + } +} + +var wrongTolerantFormatTests = []wrongformatTest{ + {nil, "1.0+abc"}, + {nil, "1.0-rc.1"}, +} + +func TestWrongTolerantFormat(t *testing.T) { + for _, test := range wrongTolerantFormatTests { + if res, err := ParseTolerant(test.str); err == nil { + t.Errorf("Parsing wrong format version %q, expected error but got %q", test.str, res) + } + } +} + +func TestCompareHelper(t *testing.T) { + v := Version{1, 0, 0, []PRVersion{prstr("alpha")}, nil} + v1 := Version{1, 0, 0, nil, nil} + if !v.EQ(v) { + t.Errorf("%q should be equal to %q", v, v) + } + if !v.Equals(v) { + t.Errorf("%q should be equal to %q", v, v) + } + if !v1.NE(v) { + t.Errorf("%q should not be equal to %q", v1, v) + } + if !v.GTE(v) { + t.Errorf("%q should be greater than or equal to %q", v, v) + } + if !v.LTE(v) { + t.Errorf("%q should be less than or equal to %q", v, v) + } + if !v.LT(v1) { + t.Errorf("%q should be less than %q", v, v1) + } + if !v.LTE(v1) { + t.Errorf("%q should be less than or equal %q", v, v1) + } + if !v.LE(v1) { + t.Errorf("%q should be less than or equal %q", v, v1) + } + if !v1.GT(v) { + t.Errorf("%q should be greater than %q", v1, v) + } + if !v1.GTE(v) { + t.Errorf("%q should be greater than or equal %q", v1, v) + } + if !v1.GE(v) { + t.Errorf("%q should be greater than or equal %q", v1, v) + } +} + +const ( + MAJOR = iota + MINOR + PATCH +) + +type incrementTest struct { + version Version + incrementType int + expectingError bool + expectedVersion Version +} + +var incrementTests = []incrementTest{ + {Version{1, 2, 3, nil, nil}, PATCH, false, Version{1, 2, 4, nil, nil}}, + {Version{1, 2, 3, nil, nil}, MINOR, false, Version{1, 3, 0, nil, nil}}, + {Version{1, 2, 3, nil, nil}, MAJOR, false, Version{2, 0, 0, nil, nil}}, + {Version{0, 1, 2, nil, nil}, PATCH, true, Version{}}, + {Version{0, 1, 2, nil, nil}, MINOR, true, Version{}}, + {Version{0, 1, 2, nil, nil}, MAJOR, true, Version{}}, +} + +func TestIncrements(t *testing.T) { + for _, test := range incrementTests { + var originalVersion = Version{ + test.version.Major, + test.version.Minor, + test.version.Patch, + test.version.Pre, + test.version.Build, + } + var err error + switch test.incrementType { + case PATCH: + err = test.version.IncrementPatch() + case MINOR: + err = test.version.IncrementMinor() + case MAJOR: + err = test.version.IncrementMajor() + } + if test.expectingError { + if err == nil { + t.Errorf("Increment version %q, expecting error, got %q", test.version, err) + } + if test.version.NE(originalVersion) { + t.Errorf("Increment version, expecting %q, got %q", test.expectedVersion, test.version) + } + } else { + if (err != nil) && !test.expectingError { + t.Errorf("Increment version %q, not expecting error, got %q", test.version, err) + } + if test.version.NE(test.expectedVersion) { + t.Errorf("Increment version, expecting %q, got %q", test.expectedVersion, test.version) + } + } + } +} + +func TestPreReleaseVersions(t *testing.T) { + p1, err := NewPRVersion("123") + if !p1.IsNumeric() { + t.Errorf("Expected numeric prversion, got %q", p1) + } + if p1.VersionNum != 123 { + t.Error("Wrong prversion number") + } + if err != nil { + t.Errorf("Not expected error %q", err) + } + p2, err := NewPRVersion("alpha") + if p2.IsNumeric() { + t.Errorf("Expected non-numeric prversion, got %q", p2) + } + if p2.VersionStr != "alpha" { + t.Error("Wrong prversion string") + } + if err != nil { + t.Errorf("Not expected error %q", err) + } +} + +func TestBuildMetaDataVersions(t *testing.T) { + _, err := NewBuildVersion("123") + if err != nil { + t.Errorf("Unexpected error %q", err) + } + + _, err = NewBuildVersion("build") + if err != nil { + t.Errorf("Unexpected error %q", err) + } + + _, err = NewBuildVersion("test?") + if err == nil { + t.Error("Expected error, got none") + } + + _, err = NewBuildVersion("") + if err == nil { + t.Error("Expected error, got none") + } +} + +func TestNewHelper(t *testing.T) { + v, err := New("1.2.3") + if err != nil { + t.Fatalf("Unexpected error %q", err) + } + + // New returns pointer + if v == nil { + t.Fatal("Version is nil") + } + if v.Compare(Version{1, 2, 3, nil, nil}) != 0 { + t.Fatal("Unexpected comparison problem") + } +} + +func TestMakeHelper(t *testing.T) { + v, err := Make("1.2.3") + if err != nil { + t.Fatalf("Unexpected error %q", err) + } + if v.Compare(Version{1, 2, 3, nil, nil}) != 0 { + t.Fatal("Unexpected comparison problem") + } +} + +func BenchmarkParseSimple(b *testing.B) { + const VERSION = "0.0.1" + b.ReportAllocs() + b.ResetTimer() + for n := 0; n < b.N; n++ { + Parse(VERSION) + } +} + +func BenchmarkParseComplex(b *testing.B) { + const VERSION = "0.0.1-alpha.preview+123.456" + b.ReportAllocs() + b.ResetTimer() + for n := 0; n < b.N; n++ { + Parse(VERSION) + } +} + +func BenchmarkParseAverage(b *testing.B) { + l := len(formatTests) + b.ReportAllocs() + b.ResetTimer() + for n := 0; n < b.N; n++ { + Parse(formatTests[n%l].result) + } +} + +func BenchmarkParseTolerantAverage(b *testing.B) { + l := len(tolerantFormatTests) + b.ReportAllocs() + b.ResetTimer() + for n := 0; n < b.N; n++ { + ParseTolerant(tolerantFormatTests[n%l].result) + } +} + +func BenchmarkStringSimple(b *testing.B) { + const VERSION = "0.0.1" + v, _ := Parse(VERSION) + b.ReportAllocs() + b.ResetTimer() + for n := 0; n < b.N; n++ { + _ = v.String() + } +} + +func BenchmarkStringLarger(b *testing.B) { + const VERSION = "11.15.2012" + v, _ := Parse(VERSION) + b.ReportAllocs() + b.ResetTimer() + for n := 0; n < b.N; n++ { + _ = v.String() + } +} + +func BenchmarkStringComplex(b *testing.B) { + const VERSION = "0.0.1-alpha.preview+123.456" + v, _ := Parse(VERSION) + b.ReportAllocs() + b.ResetTimer() + for n := 0; n < b.N; n++ { + _ = v.String() + } +} + +func BenchmarkStringAverage(b *testing.B) { + l := len(formatTests) + b.ReportAllocs() + b.ResetTimer() + for n := 0; n < b.N; n++ { + _ = formatTests[n%l].v.String() + } +} + +func BenchmarkValidateSimple(b *testing.B) { + const VERSION = "0.0.1" + v, _ := Parse(VERSION) + b.ReportAllocs() + b.ResetTimer() + for n := 0; n < b.N; n++ { + v.Validate() + } +} + +func BenchmarkValidateComplex(b *testing.B) { + const VERSION = "0.0.1-alpha.preview+123.456" + v, _ := Parse(VERSION) + b.ReportAllocs() + b.ResetTimer() + for n := 0; n < b.N; n++ { + v.Validate() + } +} + +func BenchmarkValidateAverage(b *testing.B) { + l := len(formatTests) + b.ReportAllocs() + b.ResetTimer() + for n := 0; n < b.N; n++ { + formatTests[n%l].v.Validate() + } +} + +func BenchmarkCompareSimple(b *testing.B) { + const VERSION = "0.0.1" + v, _ := Parse(VERSION) + b.ReportAllocs() + b.ResetTimer() + for n := 0; n < b.N; n++ { + v.Compare(v) + } +} + +func BenchmarkCompareComplex(b *testing.B) { + const VERSION = "0.0.1-alpha.preview+123.456" + v, _ := Parse(VERSION) + b.ReportAllocs() + b.ResetTimer() + for n := 0; n < b.N; n++ { + v.Compare(v) + } +} + +func BenchmarkCompareAverage(b *testing.B) { + l := len(compareTests) + b.ReportAllocs() + b.ResetTimer() + for n := 0; n < b.N; n++ { + compareTests[n%l].v1.Compare((compareTests[n%l].v2)) + } +} diff --git a/vendor/github.com/blang/semver/sort.go b/vendor/github.com/blang/semver/sort.go new file mode 100644 index 0000000000..e18f880826 --- /dev/null +++ b/vendor/github.com/blang/semver/sort.go @@ -0,0 +1,28 @@ +package semver + +import ( + "sort" +) + +// Versions represents multiple versions. +type Versions []Version + +// Len returns length of version collection +func (s Versions) Len() int { + return len(s) +} + +// Swap swaps two versions inside the collection by its indices +func (s Versions) Swap(i, j int) { + s[i], s[j] = s[j], s[i] +} + +// Less checks if version at index i is less than version at index j +func (s Versions) Less(i, j int) bool { + return s[i].LT(s[j]) +} + +// Sort sorts a slice of versions +func Sort(versions []Version) { + sort.Sort(Versions(versions)) +} diff --git a/vendor/github.com/blang/semver/sort_test.go b/vendor/github.com/blang/semver/sort_test.go new file mode 100644 index 0000000000..68893972a2 --- /dev/null +++ b/vendor/github.com/blang/semver/sort_test.go @@ -0,0 +1,30 @@ +package semver + +import ( + "reflect" + "testing" +) + +func TestSort(t *testing.T) { + v100, _ := Parse("1.0.0") + v010, _ := Parse("0.1.0") + v001, _ := Parse("0.0.1") + versions := []Version{v010, v100, v001} + Sort(versions) + + correct := []Version{v001, v010, v100} + if !reflect.DeepEqual(versions, correct) { + t.Fatalf("Sort returned wrong order: %s", versions) + } +} + +func BenchmarkSort(b *testing.B) { + v100, _ := Parse("1.0.0") + v010, _ := Parse("0.1.0") + v001, _ := Parse("0.0.1") + b.ReportAllocs() + b.ResetTimer() + for n := 0; n < b.N; n++ { + Sort([]Version{v010, v100, v001}) + } +} diff --git a/vendor/github.com/blang/semver/sql.go b/vendor/github.com/blang/semver/sql.go new file mode 100644 index 0000000000..db958134f3 --- /dev/null +++ b/vendor/github.com/blang/semver/sql.go @@ -0,0 +1,30 @@ +package semver + +import ( + "database/sql/driver" + "fmt" +) + +// Scan implements the database/sql.Scanner interface. +func (v *Version) Scan(src interface{}) (err error) { + var str string + switch src := src.(type) { + case string: + str = src + case []byte: + str = string(src) + default: + return fmt.Errorf("version.Scan: cannot convert %T to string", src) + } + + if t, err := Parse(str); err == nil { + *v = t + } + + return +} + +// Value implements the database/sql/driver.Valuer interface. +func (v Version) Value() (driver.Value, error) { + return v.String(), nil +} diff --git a/vendor/github.com/blang/semver/sql_test.go b/vendor/github.com/blang/semver/sql_test.go new file mode 100644 index 0000000000..ebf48b584a --- /dev/null +++ b/vendor/github.com/blang/semver/sql_test.go @@ -0,0 +1,38 @@ +package semver + +import ( + "testing" +) + +type scanTest struct { + val interface{} + shouldError bool + expected string +} + +var scanTests = []scanTest{ + {"1.2.3", false, "1.2.3"}, + {[]byte("1.2.3"), false, "1.2.3"}, + {7, true, ""}, + {7e4, true, ""}, + {true, true, ""}, +} + +func TestScanString(t *testing.T) { + for _, tc := range scanTests { + s := &Version{} + err := s.Scan(tc.val) + if tc.shouldError { + if err == nil { + t.Fatalf("Scan did not return an error on %v (%T)", tc.val, tc.val) + } + } else { + if err != nil { + t.Fatalf("Scan returned an unexpected error: %s (%T) on %v (%T)", tc.val, tc.val, tc.val, tc.val) + } + if val, _ := s.Value(); val != tc.expected { + t.Errorf("Wrong Value returned, expected %q, got %q", tc.expected, val) + } + } + } +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/catalogsource_types.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/catalogsource_types.go new file mode 100644 index 0000000000..71e253f1cf --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/catalogsource_types.go @@ -0,0 +1,115 @@ +package operators + +import ( + "fmt" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +) + +// CatalogSourceKind is the PascalCase name of a CatalogSource's kind. +const CatalogSourceKind = "CatalogSource" + +// SourceType indicates the type of backing store for a CatalogSource +type SourceType string + +const ( + // SourceTypeInternal (deprecated) specifies a CatalogSource of type SourceTypeConfigmap + SourceTypeInternal SourceType = "internal" + + // SourceTypeConfigmap specifies a CatalogSource that generates a configmap-server registry + SourceTypeConfigmap SourceType = "configmap" + + // SourceTypeGrpc specifies a CatalogSource that can use an operator registry image to generate a + // registry-server or connect to a pre-existing registry at an address. + SourceTypeGrpc SourceType = "grpc" +) + +type CatalogSourceSpec struct { + // SourceType is the type of source + SourceType SourceType + + // ConfigMap is the name of the ConfigMap to be used to back a configmap-server registry. + // Only used when SourceType = SourceTypeConfigmap or SourceTypeInternal. + // +Optional + ConfigMap string + + // Address is a host that OLM can use to connect to a pre-existing registry. + // Format: : + // Only used when SourceType = SourceTypeGrpc. + // Ignored when the Image field is set. + // +Optional + Address string + + // Image is an operator-registry container image to instantiate a registry-server with. + // Only used when SourceType = SourceTypeGrpc. + // If present, the address field is ignored. + // +Optional + Image string + + // Secrets represent set of secrets that can be used to access the contents of the catalog. + // It is best to keep this list small, since each will need to be tried for every catalog entry. + // +Optional + Secrets []string + + // Metadata + DisplayName string + Description string + Publisher string + Icon Icon +} + +type RegistryServiceStatus struct { + Protocol string + ServiceName string + ServiceNamespace string + Port string + CreatedAt metav1.Time +} + +func (s *RegistryServiceStatus) Address() string { + return fmt.Sprintf("%s.%s.svc.cluster.local:%s", s.ServiceName, s.ServiceNamespace, s.Port) +} + +type CatalogSourceStatus struct { + ConfigMapResource *ConfigMapResourceReference + RegistryServiceStatus *RegistryServiceStatus + LastSync metav1.Time +} + +type ConfigMapResourceReference struct { + Name string + Namespace string + + UID types.UID + ResourceVersion string +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// CatalogSource is a repository of CSVs, CRDs, and operator packages. +type CatalogSource struct { + metav1.TypeMeta + metav1.ObjectMeta + + Spec CatalogSourceSpec + Status CatalogSourceStatus +} + +func (c *CatalogSource) Address() string { + if c.Spec.Address != "" { + return c.Spec.Address + } + return c.Status.RegistryServiceStatus.Address() +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// CatalogSourceList is a list of CatalogSource resources. +type CatalogSourceList struct { + metav1.TypeMeta + metav1.ListMeta + + Items []CatalogSource +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/clusterserviceversion_types.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/clusterserviceversion_types.go new file mode 100644 index 0000000000..94398e72e6 --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/clusterserviceversion_types.go @@ -0,0 +1,488 @@ +package operators + +import ( + "encoding/json" + "fmt" + "sort" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/version" +) + +// ClusterServiceVersionKind is the PascalCase name of a CSV's kind. +const ClusterServiceVersionKind = "ClusterServiceVersion" + +// InstallModeType is a supported type of install mode for CSV installation +type InstallModeType string + +const ( + // InstallModeTypeOwnNamespace indicates that the operator can be a member of an `OperatorGroup` that selects its own namespace. + InstallModeTypeOwnNamespace InstallModeType = "OwnNamespace" + // InstallModeTypeSingleNamespace indicates that the operator can be a member of an `OperatorGroup` that selects one namespace. + InstallModeTypeSingleNamespace InstallModeType = "SingleNamespace" + // InstallModeTypeMultiNamespace indicates that the operator can be a member of an `OperatorGroup` that selects more than one namespace. + InstallModeTypeMultiNamespace InstallModeType = "MultiNamespace" + // InstallModeTypeAllNamespaces indicates that the operator can be a member of an `OperatorGroup` that selects all namespaces (target namespace set is the empty string ""). + InstallModeTypeAllNamespaces InstallModeType = "AllNamespaces" +) + +// InstallMode associates an InstallModeType with a flag representing if the CSV supports it +type InstallMode struct { + Type InstallModeType + Supported bool +} + +// InstallModeSet is a mapping of unique InstallModeTypes to whether they are supported. +type InstallModeSet map[InstallModeType]bool + +// NamedInstallStrategy represents the block of an ClusterServiceVersion resource +// where the install strategy is specified. +type NamedInstallStrategy struct { + StrategyName string + StrategySpecRaw json.RawMessage +} + +// StatusDescriptor describes a field in a status block of a CRD so that OLM can consume it +type StatusDescriptor struct { + Path string + DisplayName string + Description string + XDescriptors []string + Value *json.RawMessage +} + +// SpecDescriptor describes a field in a spec block of a CRD so that OLM can consume it +type SpecDescriptor struct { + Path string + DisplayName string + Description string + XDescriptors []string + Value *json.RawMessage +} + +// ActionDescriptor describes a declarative action that can be performed on a custom resource instance +type ActionDescriptor struct { + Path string + DisplayName string + Description string + XDescriptors []string + Value *json.RawMessage +} + +// CRDDescription provides details to OLM about the CRDs +type CRDDescription struct { + Name string + Version string + Kind string + DisplayName string + Description string + Resources []APIResourceReference + StatusDescriptors []StatusDescriptor + SpecDescriptors []SpecDescriptor + ActionDescriptor []ActionDescriptor +} + +// APIServiceDescription provides details to OLM about apis provided via aggregation +type APIServiceDescription struct { + Name string + Group string + Version string + Kind string + DeploymentName string + ContainerPort int32 + DisplayName string + Description string + Resources []APIResourceReference + StatusDescriptors []StatusDescriptor + SpecDescriptors []SpecDescriptor + ActionDescriptor []ActionDescriptor +} + +// APIResourceReference is a Kubernetes resource type used by a custom resource +type APIResourceReference struct { + Name string + Kind string + Version string +} + +// GetName returns the name of an APIService as derived from its group and version. +func (d APIServiceDescription) GetName() string { + return fmt.Sprintf("%s.%s", d.Version, d.Group) +} + +// CustomResourceDefinitions declares all of the CRDs managed or required by +// an operator being ran by ClusterServiceVersion. +// +// If the CRD is present in the Owned list, it is implicitly required. +type CustomResourceDefinitions struct { + Owned []CRDDescription + Required []CRDDescription +} + +// APIServiceDefinitions declares all of the extension apis managed or required by +// an operator being ran by ClusterServiceVersion. +type APIServiceDefinitions struct { + Owned []APIServiceDescription + Required []APIServiceDescription +} + +// ClusterServiceVersionSpec declarations tell OLM how to install an operator +// that can manage apps for a given version. +type ClusterServiceVersionSpec struct { + InstallStrategy NamedInstallStrategy + Version version.OperatorVersion + Maturity string + CustomResourceDefinitions CustomResourceDefinitions + APIServiceDefinitions APIServiceDefinitions + NativeAPIs []metav1.GroupVersionKind + MinKubeVersion string + DisplayName string + Description string + Keywords []string + Maintainers []Maintainer + Provider AppLink + Links []AppLink + Icon []Icon + + // InstallModes specify supported installation types + // +optional + InstallModes []InstallMode + + // The name of a CSV this one replaces. Should match the `metadata.Name` field of the old CSV. + // +optional + Replaces string + + // Map of string keys and values that can be used to organize and categorize + // (scope and select) objects. + // +optional + Labels map[string]string + + // Annotations is an unstructured key value map stored with a resource that may be + // set by external tools to store and retrieve arbitrary metadata. + // +optional + Annotations map[string]string + + // Label selector for related resources. + // +optional + Selector *metav1.LabelSelector +} + +type Maintainer struct { + Name string + Email string +} + +type AppLink struct { + Name string + URL string +} + +type Icon struct { + Data string + MediaType string +} + +// ClusterServiceVersionPhase is a label for the condition of a ClusterServiceVersion at the current time. +type ClusterServiceVersionPhase string + +// These are the valid phases of ClusterServiceVersion +const ( + CSVPhaseNone = "" + // CSVPhasePending means the csv has been accepted by the system, but the install strategy has not been attempted. + // This is likely because there are unmet requirements. + CSVPhasePending ClusterServiceVersionPhase = "Pending" + // CSVPhaseInstallReady means that the requirements are met but the install strategy has not been run. + CSVPhaseInstallReady ClusterServiceVersionPhase = "InstallReady" + // CSVPhaseInstalling means that the install strategy has been initiated but not completed. + CSVPhaseInstalling ClusterServiceVersionPhase = "Installing" + // CSVPhaseSucceeded means that the resources in the CSV were created successfully. + CSVPhaseSucceeded ClusterServiceVersionPhase = "Succeeded" + // CSVPhaseFailed means that the install strategy could not be successfully completed. + CSVPhaseFailed ClusterServiceVersionPhase = "Failed" + // CSVPhaseUnknown means that for some reason the state of the csv could not be obtained. + CSVPhaseUnknown ClusterServiceVersionPhase = "Unknown" + // CSVPhaseReplacing means that a newer CSV has been created and the csv's resources will be transitioned to a new owner. + CSVPhaseReplacing ClusterServiceVersionPhase = "Replacing" + // CSVPhaseDeleting means that a CSV has been replaced by a new one and will be checked for safety before being deleted + CSVPhaseDeleting ClusterServiceVersionPhase = "Deleting" + // CSVPhaseAny matches all other phases in CSV queries + CSVPhaseAny ClusterServiceVersionPhase = "" +) + +// ConditionReason is a camelcased reason for the state transition +type ConditionReason string + +const ( + CSVReasonRequirementsUnknown ConditionReason = "RequirementsUnknown" + CSVReasonRequirementsNotMet ConditionReason = "RequirementsNotMet" + CSVReasonRequirementsMet ConditionReason = "AllRequirementsMet" + CSVReasonOwnerConflict ConditionReason = "OwnerConflict" + CSVReasonComponentFailed ConditionReason = "InstallComponentFailed" + CSVReasonInvalidStrategy ConditionReason = "InvalidInstallStrategy" + CSVReasonWaiting ConditionReason = "InstallWaiting" + CSVReasonInstallSuccessful ConditionReason = "InstallSucceeded" + CSVReasonInstallCheckFailed ConditionReason = "InstallCheckFailed" + CSVReasonComponentUnhealthy ConditionReason = "ComponentUnhealthy" + CSVReasonBeingReplaced ConditionReason = "BeingReplaced" + CSVReasonReplaced ConditionReason = "Replaced" + CSVReasonNeedsReinstall ConditionReason = "NeedsReinstall" + CSVReasonNeedsCertRotation ConditionReason = "NeedsCertRotation" + CSVReasonAPIServiceResourceIssue ConditionReason = "APIServiceResourceIssue" + CSVReasonAPIServiceResourcesNeedReinstall ConditionReason = "APIServiceResourcesNeedReinstall" + CSVReasonAPIServiceInstallFailed ConditionReason = "APIServiceInstallFailed" + CSVReasonCopied ConditionReason = "Copied" + CSVReasonInvalidInstallModes ConditionReason = "InvalidInstallModes" + CSVReasonNoTargetNamespaces ConditionReason = "NoTargetNamespaces" + CSVReasonUnsupportedOperatorGroup ConditionReason = "UnsupportedOperatorGroup" + CSVReasonNoOperatorGroup ConditionReason = "NoOperatorGroup" + CSVReasonTooManyOperatorGroups ConditionReason = "TooManyOperatorGroups" + CSVReasonInterOperatorGroupOwnerConflict ConditionReason = "InterOperatorGroupOwnerConflict" + CSVReasonCannotModifyStaticOperatorGroupProvidedAPIs ConditionReason = "CannotModifyStaticOperatorGroupProvidedAPIs" +) + +// Conditions appear in the status as a record of state transitions on the ClusterServiceVersion +type ClusterServiceVersionCondition struct { + // Condition of the ClusterServiceVersion + Phase ClusterServiceVersionPhase + // A human readable message indicating details about why the ClusterServiceVersion is in this condition. + // +optional + Message string + // A brief CamelCase message indicating details about why the ClusterServiceVersion is in this state. + // e.g. 'RequirementsNotMet' + // +optional + Reason ConditionReason + // Last time we updated the status + // +optional + LastUpdateTime metav1.Time + // Last time the status transitioned from one status to another. + // +optional + LastTransitionTime metav1.Time +} + +// OwnsCRD determines whether the current CSV owns a paritcular CRD. +func (csv ClusterServiceVersion) OwnsCRD(name string) bool { + for _, desc := range csv.Spec.CustomResourceDefinitions.Owned { + if desc.Name == name { + return true + } + } + + return false +} + +// OwnsAPIService determines whether the current CSV owns a paritcular APIService. +func (csv ClusterServiceVersion) OwnsAPIService(name string) bool { + for _, desc := range csv.Spec.APIServiceDefinitions.Owned { + apiServiceName := fmt.Sprintf("%s.%s", desc.Version, desc.Group) + if apiServiceName == name { + return true + } + } + + return false +} + +// StatusReason is a camelcased reason for the status of a RequirementStatus or DependentStatus +type StatusReason string + +const ( + RequirementStatusReasonPresent StatusReason = "Present" + RequirementStatusReasonNotPresent StatusReason = "NotPresent" + RequirementStatusReasonPresentNotSatisfied StatusReason = "PresentNotSatisfied" + // The CRD is present but the Established condition is False (not available) + RequirementStatusReasonNotAvailable StatusReason = "PresentNotAvailable" + DependentStatusReasonSatisfied StatusReason = "Satisfied" + DependentStatusReasonNotSatisfied StatusReason = "NotSatisfied" +) + +// DependentStatus is the status for a dependent requirement (to prevent infinite nesting) +type DependentStatus struct { + Group string + Version string + Kind string + Status StatusReason + UUID string + Message string +} + +type RequirementStatus struct { + Group string + Version string + Kind string + Name string + Status StatusReason + Message string + UUID string + Dependents []DependentStatus +} + +// ClusterServiceVersionStatus represents information about the status of a pod. Status may trail the actual +// state of a system. +type ClusterServiceVersionStatus struct { + // Current condition of the ClusterServiceVersion + Phase ClusterServiceVersionPhase + // A human readable message indicating details about why the ClusterServiceVersion is in this condition. + // +optional + Message string + // A brief CamelCase message indicating details about why the ClusterServiceVersion is in this state. + // e.g. 'RequirementsNotMet' + // +optional + Reason ConditionReason + // Last time we updated the status + // +optional + LastUpdateTime metav1.Time + // Last time the status transitioned from one status to another. + // +optional + LastTransitionTime metav1.Time + // List of conditions, a history of state transitions + Conditions []ClusterServiceVersionCondition + // The status of each requirement for this CSV + RequirementStatus []RequirementStatus + // Last time the owned APIService certs were updated + // +optional + CertsLastUpdated metav1.Time + // Time the owned APIService certs will rotate next + // +optional + CertsRotateAt metav1.Time +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// ClusterServiceVersion is a Custom Resource of type `ClusterServiceVersionSpec`. +type ClusterServiceVersion struct { + metav1.TypeMeta + metav1.ObjectMeta + + Spec ClusterServiceVersionSpec + Status ClusterServiceVersionStatus +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ClusterServiceVersionList represents a list of ClusterServiceVersions. +type ClusterServiceVersionList struct { + metav1.TypeMeta + metav1.ListMeta + + Items []ClusterServiceVersion +} + +// GetAllCRDDescriptions returns a deduplicated set of CRDDescriptions that is +// the union of the owned and required CRDDescriptions. +// +// Descriptions with the same name prefer the value in Owned. +// Descriptions are returned in alphabetical order. +func (csv ClusterServiceVersion) GetAllCRDDescriptions() []CRDDescription { + set := make(map[string]CRDDescription) + for _, required := range csv.Spec.CustomResourceDefinitions.Required { + set[required.Name] = required + } + + for _, owned := range csv.Spec.CustomResourceDefinitions.Owned { + set[owned.Name] = owned + } + + keys := make([]string, 0) + for key := range set { + keys = append(keys, key) + } + sort.StringSlice(keys).Sort() + + descs := make([]CRDDescription, 0) + for _, key := range keys { + descs = append(descs, set[key]) + } + + return descs +} + +// GetAllAPIServiceDescriptions returns a deduplicated set of APIServiceDescriptions that is +// the union of the owned and required APIServiceDescriptions. +// +// Descriptions with the same name prefer the value in Owned. +// Descriptions are returned in alphabetical order. +func (csv ClusterServiceVersion) GetAllAPIServiceDescriptions() []APIServiceDescription { + set := make(map[string]APIServiceDescription) + for _, required := range csv.Spec.APIServiceDefinitions.Required { + name := fmt.Sprintf("%s.%s", required.Version, required.Group) + set[name] = required + } + + for _, owned := range csv.Spec.APIServiceDefinitions.Owned { + name := fmt.Sprintf("%s.%s", owned.Version, owned.Group) + set[name] = owned + } + + keys := make([]string, 0) + for key := range set { + keys = append(keys, key) + } + sort.StringSlice(keys).Sort() + + descs := make([]APIServiceDescription, 0) + for _, key := range keys { + descs = append(descs, set[key]) + } + + return descs +} + +// GetRequiredAPIServiceDescriptions returns a deduplicated set of required APIServiceDescriptions +// with the intersection of required and owned removed +// Equivalent to the set subtraction required - owned +// +// Descriptions are returned in alphabetical order. +func (csv ClusterServiceVersion) GetRequiredAPIServiceDescriptions() []APIServiceDescription { + set := make(map[string]APIServiceDescription) + for _, required := range csv.Spec.APIServiceDefinitions.Required { + name := fmt.Sprintf("%s.%s", required.Version, required.Group) + set[name] = required + } + + // Remove any shared owned from the set + for _, owned := range csv.Spec.APIServiceDefinitions.Owned { + name := fmt.Sprintf("%s.%s", owned.Version, owned.Group) + if _, ok := set[name]; ok { + delete(set, name) + } + } + + keys := make([]string, 0) + for key := range set { + keys = append(keys, key) + } + sort.StringSlice(keys).Sort() + + descs := make([]APIServiceDescription, 0) + for _, key := range keys { + descs = append(descs, set[key]) + } + + return descs +} + +// GetOwnedAPIServiceDescriptions returns a deduplicated set of owned APIServiceDescriptions +// +// Descriptions are returned in alphabetical order. +func (csv ClusterServiceVersion) GetOwnedAPIServiceDescriptions() []APIServiceDescription { + set := make(map[string]APIServiceDescription) + for _, owned := range csv.Spec.APIServiceDefinitions.Owned { + name := owned.GetName() + set[name] = owned + } + + keys := make([]string, 0) + for key := range set { + keys = append(keys, key) + } + sort.StringSlice(keys).Sort() + + descs := make([]APIServiceDescription, 0) + for _, key := range keys { + descs = append(descs, set[key]) + } + + return descs +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/doc.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/doc.go new file mode 100644 index 0000000000..bc8a343494 --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/doc.go @@ -0,0 +1,5 @@ +// +k8s:deepcopy-gen=package +// +groupName=operators.coreos.com + +// Package operators contains all resource types of the operators.coreos.com API group. +package operators diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/install/install.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/install/install.go new file mode 100644 index 0000000000..9d7b7b4c5f --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/install/install.go @@ -0,0 +1,18 @@ +package install + +import ( + "k8s.io/apimachinery/pkg/runtime" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + + "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators" + "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1" + "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1" +) + +// Install registers the API group and adds all of its types to the given scheme. +func Install(scheme *runtime.Scheme) { + utilruntime.Must(operators.AddToScheme(scheme)) + utilruntime.Must(v1alpha1.AddToScheme(scheme)) + utilruntime.Must(v1.AddToScheme(scheme)) + utilruntime.Must(scheme.SetVersionPriority(v1.SchemeGroupVersion, v1alpha1.SchemeGroupVersion)) +} \ No newline at end of file diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/installplan_types.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/installplan_types.go new file mode 100644 index 0000000000..045f48d371 --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/installplan_types.go @@ -0,0 +1,248 @@ +package operators + +import ( + "errors" + "fmt" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// InstallPlanKind is the PascalCase name of an InstallPlan's kind. +const InstallPlanKind = "InstallPlan" + +// Approval is the user approval policy for an InstallPlan. +type Approval string + +const ( + ApprovalAutomatic Approval = "Automatic" + ApprovalManual Approval = "Manual" +) + +// InstallPlanSpec defines a set of Application resources to be installed +type InstallPlanSpec struct { + CatalogSource string + CatalogSourceNamespace string + ClusterServiceVersionNames []string + Approval Approval + Approved bool +} + +// InstallPlanPhase is the current status of a InstallPlan as a whole. +type InstallPlanPhase string + +const ( + InstallPlanPhaseNone InstallPlanPhase = "" + InstallPlanPhasePlanning InstallPlanPhase = "Planning" + InstallPlanPhaseRequiresApproval InstallPlanPhase = "RequiresApproval" + InstallPlanPhaseInstalling InstallPlanPhase = "Installing" + InstallPlanPhaseComplete InstallPlanPhase = "Complete" + InstallPlanPhaseFailed InstallPlanPhase = "Failed" +) + +// InstallPlanConditionType describes the state of an InstallPlan at a certain point as a whole. +type InstallPlanConditionType string + +const ( + InstallPlanResolved InstallPlanConditionType = "Resolved" + InstallPlanInstalled InstallPlanConditionType = "Installed" +) + +// ConditionReason is a camelcased reason for the state transition. +type InstallPlanConditionReason string + +const ( + InstallPlanReasonPlanUnknown InstallPlanConditionReason = "PlanUnknown" + InstallPlanReasonInstallCheckFailed InstallPlanConditionReason = "InstallCheckFailed" + InstallPlanReasonDependencyConflict InstallPlanConditionReason = "DependenciesConflict" + InstallPlanReasonComponentFailed InstallPlanConditionReason = "InstallComponentFailed" +) + +// StepStatus is the current status of a particular resource an in +// InstallPlan +type StepStatus string + +const ( + StepStatusUnknown StepStatus = "Unknown" + StepStatusNotPresent StepStatus = "NotPresent" + StepStatusPresent StepStatus = "Present" + StepStatusCreated StepStatus = "Created" +) + +// ErrInvalidInstallPlan is the error returned by functions that operate on +// InstallPlans when the InstallPlan does not contain totally valid data. +var ErrInvalidInstallPlan = errors.New("the InstallPlan contains invalid data") + +// InstallPlanStatus represents the information about the status of +// steps required to complete installation. +// +// Status may trail the actual state of a system. +type InstallPlanStatus struct { + Phase InstallPlanPhase + Conditions []InstallPlanCondition + CatalogSources []string + Plan []*Step +} + +// InstallPlanCondition represents the overall status of the execution of +// an InstallPlan. +type InstallPlanCondition struct { + Type InstallPlanConditionType + Status corev1.ConditionStatus // True, False, or Unknown + LastUpdateTime metav1.Time + LastTransitionTime metav1.Time + Reason InstallPlanConditionReason + Message string +} + +// allow overwriting `now` function for deterministic tests +var now = metav1.Now + +// GetCondition returns the InstallPlanCondition of the given type if it exists in the InstallPlanStatus' Conditions. +// Returns a condition of the given type with a ConditionStatus of "Unknown" if not found. +func (s InstallPlanStatus) GetCondition(conditionType InstallPlanConditionType) InstallPlanCondition { + for _, cond := range s.Conditions { + if cond.Type == conditionType { + return cond + } + } + + return InstallPlanCondition{ + Type: conditionType, + Status: corev1.ConditionUnknown, + } +} + +// SetCondition adds or updates a condition, using `Type` as merge key. +func (s *InstallPlanStatus) SetCondition(cond InstallPlanCondition) InstallPlanCondition { + for i, existing := range s.Conditions { + if existing.Type != cond.Type { + continue + } + if existing.Status == cond.Status { + cond.LastTransitionTime = existing.LastTransitionTime + } + s.Conditions[i] = cond + return cond + } + s.Conditions = append(s.Conditions, cond) + return cond +} + +func ConditionFailed(cond InstallPlanConditionType, reason InstallPlanConditionReason, message string, now *metav1.Time) InstallPlanCondition { + return InstallPlanCondition{ + Type: cond, + Status: corev1.ConditionFalse, + Reason: reason, + Message: message, + LastUpdateTime: *now, + LastTransitionTime: *now, + } +} + +func ConditionMet(cond InstallPlanConditionType, now *metav1.Time) InstallPlanCondition { + return InstallPlanCondition{ + Type: cond, + Status: corev1.ConditionTrue, + LastUpdateTime: *now, + LastTransitionTime: *now, + } +} + +// Step represents the status of an individual step in an InstallPlan. +type Step struct { + Resolving string + Resource StepResource + Status StepStatus +} + +// ManifestsMatch returns true if the CSV manifests in the StepResources of the given list of steps +// matches those in the InstallPlanStatus. +func (s *InstallPlanStatus) CSVManifestsMatch(steps []*Step) bool { + if s.Plan == nil && steps == nil { + return true + } + if s.Plan == nil || steps == nil { + return false + } + + manifests := make(map[string]struct{}) + for _, step := range s.Plan { + resource := step.Resource + if resource.Kind != ClusterServiceVersionKind { + continue + } + manifests[resource.Manifest] = struct{}{} + } + + for _, step := range steps { + resource := step.Resource + if resource.Kind != ClusterServiceVersionKind { + continue + } + if _, ok := manifests[resource.Manifest]; !ok { + return false + } + delete(manifests, resource.Manifest) + } + + if len(manifests) == 0 { + return true + } + + return false +} + +func (s *Step) String() string { + return fmt.Sprintf("%s: %s (%s)", s.Resolving, s.Resource, s.Status) +} + +// StepResource represents the status of a resource to be tracked by an +// InstallPlan. +type StepResource struct { + CatalogSource string + CatalogSourceNamespace string + Group string + Version string + Kind string + Name string + Manifest string +} + +func (r StepResource) String() string { + return fmt.Sprintf("%s[%s/%s/%s (%s/%s)]", r.Name, r.Group, r.Version, r.Kind, r.CatalogSource, r.CatalogSourceNamespace) +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// InstallPlan defines the installation of a set of operators. +type InstallPlan struct { + metav1.TypeMeta + metav1.ObjectMeta + + Spec InstallPlanSpec + Status InstallPlanStatus +} + +// EnsureCatalogSource ensures that a CatalogSource is present in the Status +// block of an InstallPlan. +func (p *InstallPlan) EnsureCatalogSource(sourceName string) { + for _, srcName := range p.Status.CatalogSources { + if srcName == sourceName { + return + } + } + + p.Status.CatalogSources = append(p.Status.CatalogSources, sourceName) +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// InstallPlanList is a list of InstallPlan resources. +type InstallPlanList struct { + metav1.TypeMeta + metav1.ListMeta + + Items []InstallPlan +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/operatorgroup_types.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/operatorgroup_types.go new file mode 100644 index 0000000000..b102d9ca1d --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/operatorgroup_types.go @@ -0,0 +1,75 @@ +package operators + +import ( + "sort" + "strings" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// OperatorGroupKind is the PascalCase name of an OperatorGroup's kind. +const OperatorGroupKind = "OperatorGroup" + +const ( + OperatorGroupAnnotationKey = "olm.operatorGroup" + OperatorGroupNamespaceAnnotationKey = "olm.operatorNamespace" + OperatorGroupTargetsAnnotationKey = "olm.targetNamespaces" + OperatorGroupProvidedAPIsAnnotationKey = "olm.providedAPIs" +) + +// OperatorGroupSpec is the spec for an OperatorGroup resource. +type OperatorGroupSpec struct { + // Selector selects the OperatorGroup's target namespaces. + // +optional + Selector *metav1.LabelSelector + + // TargetNamespaces is an explicit set of namespaces to target. + // If it is set, Selector is ignored. + // +optional + TargetNamespaces []string + + // ServiceAccount to bind OperatorGroup roles to. + ServiceAccount corev1.ServiceAccount + + // Static tells OLM not to update the OperatorGroup's providedAPIs annotation + // +optional + StaticProvidedAPIs bool +} + +// OperatorGroupStatus is the status for an OperatorGroupResource. +type OperatorGroupStatus struct { + // Namespaces is the set of target namespaces for the OperatorGroup. + Namespaces []string + + // LastUpdated is a timestamp of the last time the OperatorGroup's status was Updated. + LastUpdated metav1.Time +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// OperatorGroup is the unit of multitenancy for OLM managed operators. +// It constrains the installation of operators in its namespace to a specified set of target namespaces. +type OperatorGroup struct { + metav1.TypeMeta + metav1.ObjectMeta + + Spec OperatorGroupSpec + Status OperatorGroupStatus +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// OperatorGroupList is a list of OperatorGroup resources. +type OperatorGroupList struct { + metav1.TypeMeta + metav1.ListMeta + + Items []OperatorGroup +} + +func (o *OperatorGroup) BuildTargetNamespaces() string { + sort.Strings(o.Status.Namespaces) + return strings.Join(o.Status.Namespaces, ",") +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/reference/reference.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/reference/reference.go new file mode 100644 index 0000000000..1157820c19 --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/reference/reference.go @@ -0,0 +1,22 @@ +package reference + +import ( + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime" + ref "k8s.io/client-go/tools/reference" + + "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/install" +) + +var scheme = runtime.NewScheme() + +func init() { + // Register all OLM types with the scheme + install.Install(scheme) +} + +// GetReference returns an ObjectReference for the given object. +// The objects dynamic type must be an OLM type. +func GetReference(obj runtime.Object) (*corev1.ObjectReference, error) { + return ref.GetReference(scheme, obj) +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/reference/reference_test.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/reference/reference_test.go new file mode 100644 index 0000000000..b83e7f5d3f --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/reference/reference_test.go @@ -0,0 +1,295 @@ +package reference + +import ( + "fmt" + "reflect" + "testing" + + "github.com/stretchr/testify/require" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/types" + + "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators" + v1 "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1" + "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1" +) + +func TestGetReference(t *testing.T) { + type args struct { + obj runtime.Object + } + type want struct { + ref *corev1.ObjectReference + err error + } + tests := []struct { + name string + args args + want want + }{ + { + name: "Nil/Error", + args: args{obj: nil}, + want: want{ + ref: nil, + err: fmt.Errorf("can't reference a nil object"), + }, + }, + { + name: "v1/Pod/NotRegistered/Error", + args: args{&corev1.Pod{}}, + want: want{ + ref: nil, + err: runtime.NewNotRegisteredErrForType(scheme.Name(), reflect.TypeOf(corev1.Pod{})), + }, + }, + { + name: "v1alpha1/ClusterServiceVersion", + args: args{ + &v1alpha1.ClusterServiceVersion{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "ns", + Name: "csv", + UID: types.UID("uid"), + SelfLink: buildSelfLink(v1alpha1.SchemeGroupVersion.String(), "clusterserviceversions", "ns", "csv"), + }, + }, + }, + want: want{ + ref: &corev1.ObjectReference{ + Namespace: "ns", + Name: "csv", + UID: types.UID("uid"), + Kind: v1alpha1.ClusterServiceVersionKind, + APIVersion: v1alpha1.SchemeGroupVersion.String(), + }, + err: nil, + }, + }, + { + name: "v1alpha1/InstallPlan", + args: args{ + &v1alpha1.InstallPlan{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "ns", + Name: "ip", + UID: types.UID("uid"), + SelfLink: buildSelfLink(v1alpha1.SchemeGroupVersion.String(), "installplans", "ns", "ip"), + }, + }, + }, + want: want{ + ref: &corev1.ObjectReference{ + Namespace: "ns", + Name: "ip", + UID: types.UID("uid"), + Kind: v1alpha1.InstallPlanKind, + APIVersion: v1alpha1.SchemeGroupVersion.String(), + }, + err: nil, + }, + }, + { + name: "v1alpha1/Subscription", + args: args{ + &v1alpha1.Subscription{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "ns", + Name: "sub", + UID: types.UID("uid"), + SelfLink: buildSelfLink(v1alpha1.SchemeGroupVersion.String(), "subscriptions", "ns", "sub"), + }, + }, + }, + want: want{ + ref: &corev1.ObjectReference{ + Namespace: "ns", + Name: "sub", + UID: types.UID("uid"), + Kind: v1alpha1.SubscriptionKind, + APIVersion: v1alpha1.SchemeGroupVersion.String(), + }, + err: nil, + }, + }, + { + name: "v1alpha1/CatalogSource", + args: args{ + &v1alpha1.CatalogSource{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "ns", + Name: "catsrc", + UID: types.UID("uid"), + SelfLink: buildSelfLink(v1alpha1.SchemeGroupVersion.String(), "catalogsources", "ns", "catsrc"), + }, + }, + }, + want: want{ + ref: &corev1.ObjectReference{ + Namespace: "ns", + Name: "catsrc", + UID: types.UID("uid"), + Kind: v1alpha1.CatalogSourceKind, + APIVersion: v1alpha1.SchemeGroupVersion.String(), + }, + err: nil, + }, + }, + { + name: "v1/OperatorGroup", + args: args{ + &v1.OperatorGroup{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "ns", + Name: "og", + UID: types.UID("uid"), + SelfLink: buildSelfLink(v1.SchemeGroupVersion.String(), "operatorgroups", "ns", "og"), + }, + }, + }, + want: want{ + ref: &corev1.ObjectReference{ + Namespace: "ns", + Name: "og", + UID: types.UID("uid"), + Kind: v1.OperatorGroupKind, + APIVersion: v1.SchemeGroupVersion.String(), + }, + err: nil, + }, + }, + { + name: "internalversion/ClusterServiceVersion", + args: args{ + &operators.ClusterServiceVersion{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "ns", + Name: "csv", + UID: types.UID("uid"), + SelfLink: buildSelfLink(operators.SchemeGroupVersion.String(), "clusterserviceversions", "ns", "csv"), + }, + }, + }, + want: want{ + ref: &corev1.ObjectReference{ + Namespace: "ns", + Name: "csv", + UID: types.UID("uid"), + Kind: operators.ClusterServiceVersionKind, + APIVersion: operators.SchemeGroupVersion.String(), + }, + err: nil, + }, + }, + { + name: "internalversion/InstallPlan", + args: args{ + &v1alpha1.InstallPlan{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "ns", + Name: "ip", + UID: types.UID("uid"), + SelfLink: buildSelfLink(operators.SchemeGroupVersion.String(), "installplans", "ns", "ip"), + }, + }, + }, + want: want{ + ref: &corev1.ObjectReference{ + Namespace: "ns", + Name: "ip", + UID: types.UID("uid"), + Kind: operators.InstallPlanKind, + APIVersion: operators.SchemeGroupVersion.String(), + }, + err: nil, + }, + }, + { + name: "internalversion/Subscription", + args: args{ + &v1alpha1.Subscription{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "ns", + Name: "sub", + UID: types.UID("uid"), + SelfLink: buildSelfLink(operators.SchemeGroupVersion.String(), "subscriptions", "ns", "sub"), + }, + }, + }, + want: want{ + ref: &corev1.ObjectReference{ + Namespace: "ns", + Name: "sub", + UID: types.UID("uid"), + Kind: operators.SubscriptionKind, + APIVersion: operators.SchemeGroupVersion.String(), + }, + err: nil, + }, + }, + { + name: "internalversion/CatalogSource", + args: args{ + &v1alpha1.CatalogSource{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "ns", + Name: "catsrc", + UID: types.UID("uid"), + SelfLink: buildSelfLink(operators.SchemeGroupVersion.String(), "catalogsources", "ns", "catsrc"), + }, + }, + }, + want: want{ + ref: &corev1.ObjectReference{ + Namespace: "ns", + Name: "catsrc", + UID: types.UID("uid"), + Kind: operators.CatalogSourceKind, + APIVersion: operators.SchemeGroupVersion.String(), + }, + err: nil, + }, + }, + { + name: "internalversion/OperatorGroup", + args: args{ + &v1.OperatorGroup{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "ns", + Name: "og", + UID: types.UID("uid"), + SelfLink: buildSelfLink(operators.SchemeGroupVersion.String(), "operatorgroups", "ns", "og"), + }, + }, + }, + want: want{ + ref: &corev1.ObjectReference{ + Namespace: "ns", + Name: "og", + UID: types.UID("uid"), + Kind: operators.OperatorGroupKind, + APIVersion: operators.SchemeGroupVersion.String(), + }, + err: nil, + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + ref, err := GetReference(tt.args.obj) + require.Equal(t, tt.want.err, err) + require.Equal(t, tt.want.ref, ref) + }) + } +} + +// buildSelfLink returns a selfLink. +func buildSelfLink(groupVersion, plural, namespace, name string) string { + if namespace == metav1.NamespaceAll { + return fmt.Sprintf("/apis/%s/%s/%s", groupVersion, plural, name) + } + return fmt.Sprintf("/apis/%s/namespaces/%s/%s/%s", groupVersion, namespace, plural, name) +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/register.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/register.go new file mode 100644 index 0000000000..784b040264 --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/register.go @@ -0,0 +1,50 @@ +package operators + +import ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +const ( + // GroupName is the group name used in this package. + GroupName = "operators.coreos.com" + // GroupVersion is the group version used in this package. + GroupVersion = runtime.APIVersionInternal +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder initializes a scheme builder + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + // AddToScheme is a global function that registers this API group & version to a scheme + AddToScheme = SchemeBuilder.AddToScheme +) + +// addKnownTypes adds the list of known types to Scheme +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &CatalogSource{}, + &CatalogSourceList{}, + &InstallPlan{}, + &InstallPlanList{}, + &Subscription{}, + &SubscriptionList{}, + &ClusterServiceVersion{}, + &ClusterServiceVersionList{}, + &OperatorGroup{}, + &OperatorGroupList{}, + ) + return nil +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/subscription_types.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/subscription_types.go new file mode 100644 index 0000000000..b32a727661 --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/subscription_types.go @@ -0,0 +1,264 @@ +package operators + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +) + +// SubscriptionKind is the PascalCase name of a Subscription's kind. +const SubscriptionKind = "Subscription" + +// SubscriptionState tracks when updates are available, installing, or service is up to date +type SubscriptionState string + +const ( + SubscriptionStateNone = "" + SubscriptionStateFailed = "UpgradeFailed" + SubscriptionStateUpgradeAvailable = "UpgradeAvailable" + SubscriptionStateUpgradePending = "UpgradePending" + SubscriptionStateAtLatest = "AtLatestKnown" +) + +const ( + SubscriptionReasonInvalidCatalog ConditionReason = "InvalidCatalog" + SubscriptionReasonUpgradeSucceeded ConditionReason = "UpgradeSucceeded" +) + +// SubscriptionSpec defines an Application that can be installed +type SubscriptionSpec struct { + CatalogSource string + CatalogSourceNamespace string + Package string + Channel string + StartingCSV string + InstallPlanApproval Approval +} + +// SubscriptionConditionType indicates an explicit state condition about a Subscription in "abnormal-true" +// polarity form (see https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties). +type SubscriptionConditionType string + +const ( + // SubscriptionCatalogSourcesUnhealthy indicates that some or all of the CatalogSources to be used in resolution are unhealthy. + SubscriptionCatalogSourcesUnhealthy SubscriptionConditionType = "CatalogSourcesUnhealthy" + + // SubscriptionInstallPlanMissing indicates that a Subscription's InstallPlan is missing. + SubscriptionInstallPlanMissing SubscriptionConditionType = "InstallPlanMissing" + + // SubscriptionInstallPlanPending indicates that a Subscription's InstallPlan is pending installation. + SubscriptionInstallPlanPending SubscriptionConditionType = "InstallPlanPending" + + // SubscriptionInstallPlanFailed indicates that the installation of a Subscription's InstallPlan has failed. + SubscriptionInstallPlanFailed SubscriptionConditionType = "InstallPlanFailed" +) + +const ( + // NoCatalogSourcesFound is a reason string for Subscriptions with unhealthy CatalogSources due to none being available. + NoCatalogSourcesFound = "NoCatalogSourcesFound" + + // AllCatalogSourcesHealthy is a reason string for Subscriptions that transitioned due to all CatalogSources being healthy. + AllCatalogSourcesHealthy = "AllCatalogSourcesHealthy" + + // CatalogSourcesAdded is a reason string for Subscriptions that transitioned due to CatalogSources being added. + CatalogSourcesAdded = "CatalogSourcesAdded" + + // CatalogSourcesUpdated is a reason string for Subscriptions that transitioned due to CatalogSource being updated. + CatalogSourcesUpdated = "CatalogSourcesUpdated" + + // CatalogSourcesDeleted is a reason string for Subscriptions that transitioned due to CatalogSources being removed. + CatalogSourcesDeleted = "CatalogSourcesDeleted" + + // UnhealthyCatalogSourceFound is a reason string for Subscriptions that transitioned because an unhealthy CatalogSource was found. + UnhealthyCatalogSourceFound = "UnhealthyCatalogSourceFound" + + // ReferencedInstallPlanNotFound is a reason string for Subscriptions that transitioned due to a referenced InstallPlan not being found. + ReferencedInstallPlanNotFound = "ReferencedInstallPlanNotFound" + + // InstallPlanNotYetReconciled is a reason string for Subscriptions that transitioned due to a referenced InstallPlan not being reconciled yet. + InstallPlanNotYetReconciled = "InstallPlanNotYetReconciled" + + // InstallPlanFailed is a reason string for Subscriptions that transitioned due to a referenced InstallPlan failing without setting an explicit failure condition. + InstallPlanFailed = "InstallPlanFailed" +) + +// SubscriptionCondition represents the latest available observations of a Subscription's state. +type SubscriptionCondition struct { + // Type is the type of Subscription condition. + Type SubscriptionConditionType + + // Status is the status of the condition, one of True, False, Unknown. + Status corev1.ConditionStatus + + // Reason is a one-word CamelCase reason for the condition's last transition. + // +optional + Reason string + + // Message is a human-readable message indicating details about last transition. + // +optional + Message string + + // LastHeartbeatTime is the last time we got an update on a given condition + // +optional + LastHeartbeatTime *metav1.Time + + // LastTransitionTime is the last time the condition transit from one status to another + // +optional + LastTransitionTime *metav1.Time +} + +// Equals returns true if a SubscriptionCondition equals the one given, false otherwise. +// Equality is determined by the equality of the type, status, reason, and message fields ONLY. +func (s SubscriptionCondition) Equals(condition SubscriptionCondition) bool { + return s.Type == condition.Type && s.Status == condition.Status && s.Reason == condition.Reason && s.Message == condition.Message +} + +type SubscriptionStatus struct { + // CurrentCSV is the CSV the Subscription is progressing to. + // +optional + CurrentCSV string + + // InstalledCSV is the CSV currently installed by the Subscription. + // +optional + InstalledCSV string + + // Install is a reference to the latest InstallPlan generated for the Subscription. + // DEPRECATED: InstallPlanRef + // +optional + Install *InstallPlanReference + + // State represents the current state of the Subscription + // +optional + State SubscriptionState + + // Reason is the reason the Subscription was transitioned to its current state. + // +optional + Reason ConditionReason + + // InstallPlanRef is a reference to the latest InstallPlan that contains the Subscription's current CSV. + // +optional + InstallPlanRef *corev1.ObjectReference + + // CatalogHealth contains the Subscription's view of its relevant CatalogSources' status. + // It is used to determine SubscriptionStatusConditions related to CatalogSources. + // +optional + CatalogHealth []SubscriptionCatalogHealth + + // Conditions is a list of the latest available observations about a Subscription's current state. + // +optional + Conditions []SubscriptionCondition `hash:"set"` + + // LastUpdated represents the last time that the Subscription status was updated. + LastUpdated metav1.Time +} + +// GetCondition returns the SubscriptionCondition of the given type if it exists in the SubscriptionStatus' Conditions. +// Returns a condition of the given type with a ConditionStatus of "Unknown" if not found. +func (s SubscriptionStatus) GetCondition(conditionType SubscriptionConditionType) SubscriptionCondition { + for _, cond := range s.Conditions { + if cond.Type == conditionType { + return cond + } + } + + return SubscriptionCondition{ + Type: conditionType, + Status: corev1.ConditionUnknown, + } +} + +// SetCondition sets the given SubscriptionCondition in the SubscriptionStatus' Conditions. +func (s *SubscriptionStatus) SetCondition(condition SubscriptionCondition) { + for i, cond := range s.Conditions { + if cond.Type == condition.Type { + s.Conditions[i] = condition + return + } + } + + s.Conditions = append(s.Conditions, condition) +} + +// RemoveConditions removes any conditions of the given types from the SubscriptionStatus' Conditions. +func (s *SubscriptionStatus) RemoveConditions(remove ...SubscriptionConditionType) { + exclusions := map[SubscriptionConditionType]struct{}{} + for _, r := range remove { + exclusions[r] = struct{}{} + } + + var filtered []SubscriptionCondition + for _, cond := range s.Conditions { + if _, ok := exclusions[cond.Type]; ok { + // Skip excluded condition types + continue + } + filtered = append(filtered, cond) + } + + s.Conditions = filtered +} + +type InstallPlanReference struct { + APIVersion string + Kind string + Name string + UID types.UID +} + +// SubscriptionCatalogHealth describes the health of a CatalogSource the Subscription knows about. +type SubscriptionCatalogHealth struct { + // CatalogSourceRef is a reference to a CatalogSource. + CatalogSourceRef *corev1.ObjectReference + + // LastUpdated represents the last time that the CatalogSourceHealth changed + LastUpdated *metav1.Time + + // Healthy is true if the CatalogSource is healthy; false otherwise. + Healthy bool +} + +// Equals returns true if a SubscriptionCatalogHealth equals the one given, false otherwise. +// Equality is based SOLEY on health and UID. +func (s SubscriptionCatalogHealth) Equals(health SubscriptionCatalogHealth) bool { + return s.Healthy == health.Healthy && s.CatalogSourceRef.UID == health.CatalogSourceRef.UID +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// Subscription keeps operators up to date by tracking changes to Catalogs. +type Subscription struct { + metav1.TypeMeta + metav1.ObjectMeta + + Spec *SubscriptionSpec + Status SubscriptionStatus +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// SubscriptionList is a list of Subscription resources. +type SubscriptionList struct { + metav1.TypeMeta + metav1.ListMeta + + Items []Subscription +} + +// GetInstallPlanApproval gets the configured install plan approval or the default +func (s *Subscription) GetInstallPlanApproval() Approval { + if s.Spec.InstallPlanApproval == ApprovalManual { + return ApprovalManual + } + return ApprovalAutomatic +} + +// NewInstallPlanReference returns an InstallPlanReference for the given ObjectReference. +func NewInstallPlanReference(ref *corev1.ObjectReference) *InstallPlanReference { + return &InstallPlanReference{ + APIVersion: ref.APIVersion, + Kind: ref.Kind, + Name: ref.Name, + UID: ref.UID, + } +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1/doc.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1/doc.go new file mode 100644 index 0000000000..9dcbd4d16a --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1/doc.go @@ -0,0 +1,6 @@ +// +k8s:deepcopy-gen=package +// +k8s:conversion-gen=github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators +// +groupName=operators.coreos.com + +// Package v1 contains resources types for version v1 of the operators.coreos.com API group. +package v1 diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1/operatorgroup_types.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1/operatorgroup_types.go new file mode 100644 index 0000000000..bc1abfab0c --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1/operatorgroup_types.go @@ -0,0 +1,74 @@ +package v1 + +import ( + "sort" + "strings" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + OperatorGroupAnnotationKey = "olm.operatorGroup" + OperatorGroupNamespaceAnnotationKey = "olm.operatorNamespace" + OperatorGroupTargetsAnnotationKey = "olm.targetNamespaces" + OperatorGroupProvidedAPIsAnnotationKey = "olm.providedAPIs" + + OperatorGroupKind = "OperatorGroup" +) + +// OperatorGroupSpec is the spec for an OperatorGroup resource. +type OperatorGroupSpec struct { + // Selector selects the OperatorGroup's target namespaces. + // +optional + Selector *metav1.LabelSelector `json:"selector,omitempty"` + + // TargetNamespaces is an explicit set of namespaces to target. + // If it is set, Selector is ignored. + // +optional + TargetNamespaces []string `json:"targetNamespaces,omitempty"` + + // ServiceAccount to bind OperatorGroup roles to. + ServiceAccount corev1.ServiceAccount `json:"serviceAccount,omitempty"` + + // Static tells OLM not to update the OperatorGroup's providedAPIs annotation + // +optional + StaticProvidedAPIs bool `json:"staticProvidedAPIs,omitempty"` +} + +// OperatorGroupStatus is the status for an OperatorGroupResource. +type OperatorGroupStatus struct { + // Namespaces is the set of target namespaces for the OperatorGroup. + Namespaces []string `json:"namespaces,omitempty"` + + // LastUpdated is a timestamp of the last time the OperatorGroup's status was Updated. + LastUpdated metav1.Time `json:"lastUpdated"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// OperatorGroup is the unit of multitenancy for OLM managed operators. +// It constrains the installation of operators in its namespace to a specified set of target namespaces. +type OperatorGroup struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + + Spec OperatorGroupSpec `json:"spec"` + Status OperatorGroupStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// OperatorGroupList is a list of OperatorGroup resources. +type OperatorGroupList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []OperatorGroup `json:"items"` +} + +func (o *OperatorGroup) BuildTargetNamespaces() string { + sort.Strings(o.Status.Namespaces) + return strings.Join(o.Status.Namespaces, ",") +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1/register.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1/register.go new file mode 100644 index 0000000000..a2dc95cd98 --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1/register.go @@ -0,0 +1,49 @@ +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + + "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators" +) + +const ( + // GroupName is the group name used in this package. + GroupName = operators.GroupName + // GroupVersion is the group version used in this package. + GroupVersion = "v1" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: GroupVersion} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder initializes a scheme builder + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + // AddToScheme is a global function that registers this API group & version to a scheme + AddToScheme = SchemeBuilder.AddToScheme + + // localSchemeBuilder is expected by generated conversion functions + localSchemeBuilder = &SchemeBuilder +) + +// addKnownTypes adds the list of known types to Scheme +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &OperatorGroup{}, + &OperatorGroupList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1/zz_generated.conversion.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1/zz_generated.conversion.go new file mode 100644 index 0000000000..64c4b9e21d --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1/zz_generated.conversion.go @@ -0,0 +1,182 @@ +// +build !ignore_autogenerated + +/* +Copyright 2019 Red Hat, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by conversion-gen. DO NOT EDIT. + +package v1 + +import ( + unsafe "unsafe" + + operators "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + conversion "k8s.io/apimachinery/pkg/conversion" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +func init() { + localSchemeBuilder.Register(RegisterConversions) +} + +// RegisterConversions adds conversion functions to the given scheme. +// Public to allow building arbitrary schemes. +func RegisterConversions(s *runtime.Scheme) error { + if err := s.AddGeneratedConversionFunc((*OperatorGroup)(nil), (*operators.OperatorGroup)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_OperatorGroup_To_operators_OperatorGroup(a.(*OperatorGroup), b.(*operators.OperatorGroup), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.OperatorGroup)(nil), (*OperatorGroup)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_OperatorGroup_To_v1_OperatorGroup(a.(*operators.OperatorGroup), b.(*OperatorGroup), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*OperatorGroupList)(nil), (*operators.OperatorGroupList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_OperatorGroupList_To_operators_OperatorGroupList(a.(*OperatorGroupList), b.(*operators.OperatorGroupList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.OperatorGroupList)(nil), (*OperatorGroupList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_OperatorGroupList_To_v1_OperatorGroupList(a.(*operators.OperatorGroupList), b.(*OperatorGroupList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*OperatorGroupSpec)(nil), (*operators.OperatorGroupSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_OperatorGroupSpec_To_operators_OperatorGroupSpec(a.(*OperatorGroupSpec), b.(*operators.OperatorGroupSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.OperatorGroupSpec)(nil), (*OperatorGroupSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_OperatorGroupSpec_To_v1_OperatorGroupSpec(a.(*operators.OperatorGroupSpec), b.(*OperatorGroupSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*OperatorGroupStatus)(nil), (*operators.OperatorGroupStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_OperatorGroupStatus_To_operators_OperatorGroupStatus(a.(*OperatorGroupStatus), b.(*operators.OperatorGroupStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.OperatorGroupStatus)(nil), (*OperatorGroupStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_OperatorGroupStatus_To_v1_OperatorGroupStatus(a.(*operators.OperatorGroupStatus), b.(*OperatorGroupStatus), scope) + }); err != nil { + return err + } + return nil +} + +func autoConvert_v1_OperatorGroup_To_operators_OperatorGroup(in *OperatorGroup, out *operators.OperatorGroup, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1_OperatorGroupSpec_To_operators_OperatorGroupSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1_OperatorGroupStatus_To_operators_OperatorGroupStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1_OperatorGroup_To_operators_OperatorGroup is an autogenerated conversion function. +func Convert_v1_OperatorGroup_To_operators_OperatorGroup(in *OperatorGroup, out *operators.OperatorGroup, s conversion.Scope) error { + return autoConvert_v1_OperatorGroup_To_operators_OperatorGroup(in, out, s) +} + +func autoConvert_operators_OperatorGroup_To_v1_OperatorGroup(in *operators.OperatorGroup, out *OperatorGroup, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_operators_OperatorGroupSpec_To_v1_OperatorGroupSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_operators_OperatorGroupStatus_To_v1_OperatorGroupStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_operators_OperatorGroup_To_v1_OperatorGroup is an autogenerated conversion function. +func Convert_operators_OperatorGroup_To_v1_OperatorGroup(in *operators.OperatorGroup, out *OperatorGroup, s conversion.Scope) error { + return autoConvert_operators_OperatorGroup_To_v1_OperatorGroup(in, out, s) +} + +func autoConvert_v1_OperatorGroupList_To_operators_OperatorGroupList(in *OperatorGroupList, out *operators.OperatorGroupList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]operators.OperatorGroup)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1_OperatorGroupList_To_operators_OperatorGroupList is an autogenerated conversion function. +func Convert_v1_OperatorGroupList_To_operators_OperatorGroupList(in *OperatorGroupList, out *operators.OperatorGroupList, s conversion.Scope) error { + return autoConvert_v1_OperatorGroupList_To_operators_OperatorGroupList(in, out, s) +} + +func autoConvert_operators_OperatorGroupList_To_v1_OperatorGroupList(in *operators.OperatorGroupList, out *OperatorGroupList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]OperatorGroup)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_operators_OperatorGroupList_To_v1_OperatorGroupList is an autogenerated conversion function. +func Convert_operators_OperatorGroupList_To_v1_OperatorGroupList(in *operators.OperatorGroupList, out *OperatorGroupList, s conversion.Scope) error { + return autoConvert_operators_OperatorGroupList_To_v1_OperatorGroupList(in, out, s) +} + +func autoConvert_v1_OperatorGroupSpec_To_operators_OperatorGroupSpec(in *OperatorGroupSpec, out *operators.OperatorGroupSpec, s conversion.Scope) error { + out.Selector = (*metav1.LabelSelector)(unsafe.Pointer(in.Selector)) + out.TargetNamespaces = *(*[]string)(unsafe.Pointer(&in.TargetNamespaces)) + out.ServiceAccount = in.ServiceAccount + out.StaticProvidedAPIs = in.StaticProvidedAPIs + return nil +} + +// Convert_v1_OperatorGroupSpec_To_operators_OperatorGroupSpec is an autogenerated conversion function. +func Convert_v1_OperatorGroupSpec_To_operators_OperatorGroupSpec(in *OperatorGroupSpec, out *operators.OperatorGroupSpec, s conversion.Scope) error { + return autoConvert_v1_OperatorGroupSpec_To_operators_OperatorGroupSpec(in, out, s) +} + +func autoConvert_operators_OperatorGroupSpec_To_v1_OperatorGroupSpec(in *operators.OperatorGroupSpec, out *OperatorGroupSpec, s conversion.Scope) error { + out.Selector = (*metav1.LabelSelector)(unsafe.Pointer(in.Selector)) + out.TargetNamespaces = *(*[]string)(unsafe.Pointer(&in.TargetNamespaces)) + out.ServiceAccount = in.ServiceAccount + out.StaticProvidedAPIs = in.StaticProvidedAPIs + return nil +} + +// Convert_operators_OperatorGroupSpec_To_v1_OperatorGroupSpec is an autogenerated conversion function. +func Convert_operators_OperatorGroupSpec_To_v1_OperatorGroupSpec(in *operators.OperatorGroupSpec, out *OperatorGroupSpec, s conversion.Scope) error { + return autoConvert_operators_OperatorGroupSpec_To_v1_OperatorGroupSpec(in, out, s) +} + +func autoConvert_v1_OperatorGroupStatus_To_operators_OperatorGroupStatus(in *OperatorGroupStatus, out *operators.OperatorGroupStatus, s conversion.Scope) error { + out.Namespaces = *(*[]string)(unsafe.Pointer(&in.Namespaces)) + out.LastUpdated = in.LastUpdated + return nil +} + +// Convert_v1_OperatorGroupStatus_To_operators_OperatorGroupStatus is an autogenerated conversion function. +func Convert_v1_OperatorGroupStatus_To_operators_OperatorGroupStatus(in *OperatorGroupStatus, out *operators.OperatorGroupStatus, s conversion.Scope) error { + return autoConvert_v1_OperatorGroupStatus_To_operators_OperatorGroupStatus(in, out, s) +} + +func autoConvert_operators_OperatorGroupStatus_To_v1_OperatorGroupStatus(in *operators.OperatorGroupStatus, out *OperatorGroupStatus, s conversion.Scope) error { + out.Namespaces = *(*[]string)(unsafe.Pointer(&in.Namespaces)) + out.LastUpdated = in.LastUpdated + return nil +} + +// Convert_operators_OperatorGroupStatus_To_v1_OperatorGroupStatus is an autogenerated conversion function. +func Convert_operators_OperatorGroupStatus_To_v1_OperatorGroupStatus(in *operators.OperatorGroupStatus, out *OperatorGroupStatus, s conversion.Scope) error { + return autoConvert_operators_OperatorGroupStatus_To_v1_OperatorGroupStatus(in, out, s) +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1/zz_generated.deepcopy.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..7097508a6b --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1/zz_generated.deepcopy.go @@ -0,0 +1,136 @@ +// +build !ignore_autogenerated + +/* +Copyright 2019 Red Hat, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorGroup) DeepCopyInto(out *OperatorGroup) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorGroup. +func (in *OperatorGroup) DeepCopy() *OperatorGroup { + if in == nil { + return nil + } + out := new(OperatorGroup) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OperatorGroup) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorGroupList) DeepCopyInto(out *OperatorGroupList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OperatorGroup, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorGroupList. +func (in *OperatorGroupList) DeepCopy() *OperatorGroupList { + if in == nil { + return nil + } + out := new(OperatorGroupList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OperatorGroupList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorGroupSpec) DeepCopyInto(out *OperatorGroupSpec) { + *out = *in + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.TargetNamespaces != nil { + in, out := &in.TargetNamespaces, &out.TargetNamespaces + *out = make([]string, len(*in)) + copy(*out, *in) + } + in.ServiceAccount.DeepCopyInto(&out.ServiceAccount) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorGroupSpec. +func (in *OperatorGroupSpec) DeepCopy() *OperatorGroupSpec { + if in == nil { + return nil + } + out := new(OperatorGroupSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorGroupStatus) DeepCopyInto(out *OperatorGroupStatus) { + *out = *in + if in.Namespaces != nil { + in, out := &in.Namespaces, &out.Namespaces + *out = make([]string, len(*in)) + copy(*out, *in) + } + in.LastUpdated.DeepCopyInto(&out.LastUpdated) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorGroupStatus. +func (in *OperatorGroupStatus) DeepCopy() *OperatorGroupStatus { + if in == nil { + return nil + } + out := new(OperatorGroupStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/catalogsource_types.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/catalogsource_types.go new file mode 100644 index 0000000000..893249a97f --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/catalogsource_types.go @@ -0,0 +1,117 @@ +package v1alpha1 + +import ( + "fmt" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +) + +const ( + CatalogSourceCRDAPIVersion = GroupName + "/" + GroupVersion + CatalogSourceKind = "CatalogSource" +) + +// SourceType indicates the type of backing store for a CatalogSource +type SourceType string + +const ( + // SourceTypeInternal (deprecated) specifies a CatalogSource of type SourceTypeConfigmap + SourceTypeInternal SourceType = "internal" + + // SourceTypeConfigmap specifies a CatalogSource that generates a configmap-server registry + SourceTypeConfigmap SourceType = "configmap" + + // SourceTypeGrpc specifies a CatalogSource that can use an operator registry image to generate a + // registry-server or connect to a pre-existing registry at an address. + SourceTypeGrpc SourceType = "grpc" +) + +type CatalogSourceSpec struct { + // SourceType is the type of source + SourceType SourceType `json:"sourceType"` + + // ConfigMap is the name of the ConfigMap to be used to back a configmap-server registry. + // Only used when SourceType = SourceTypeConfigmap or SourceTypeInternal. + // +Optional + ConfigMap string `json:"configMap,omitempty"` + + // Address is a host that OLM can use to connect to a pre-existing registry. + // Format: : + // Only used when SourceType = SourceTypeGrpc. + // Ignored when the Image field is set. + // +Optional + Address string `json:"address,omitempty"` + + // Image is an operator-registry container image to instantiate a registry-server with. + // Only used when SourceType = SourceTypeGrpc. + // If present, the address field is ignored. + // +Optional + Image string `json:"image,omitempty"` + + // Secrets represent set of secrets that can be used to access the contents of the catalog. + // It is best to keep this list small, since each will need to be tried for every catalog entry. + // +Optional + Secrets []string `json:"secrets,omitempty"` + + // Metadata + DisplayName string `json:"displayName,omitempty"` + Description string `json:"description,omitempty"` + Publisher string `json:"publisher,omitempty"` + Icon Icon `json:"icon,omitempty"` +} + +type RegistryServiceStatus struct { + Protocol string `json:"protocol,omitempty"` + ServiceName string `json:"serviceName,omitempty"` + ServiceNamespace string `json:"serviceNamespace,omitempty"` + Port string `json:"port,omitempty"` + CreatedAt metav1.Time `json:"createdAt,omitempty"` +} + +func (s *RegistryServiceStatus) Address() string { + return fmt.Sprintf("%s.%s.svc.cluster.local:%s", s.ServiceName, s.ServiceNamespace, s.Port) +} + +type CatalogSourceStatus struct { + ConfigMapResource *ConfigMapResourceReference `json:"configMapReference,omitempty"` + RegistryServiceStatus *RegistryServiceStatus `json:"registryService,omitempty"` + LastSync metav1.Time `json:"lastSync,omitempty"` +} + +type ConfigMapResourceReference struct { + Name string `json:"name"` + Namespace string `json:"namespace"` + + UID types.UID `json:"uid,omitempty"` + ResourceVersion string `json:"resourceVersion,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// CatalogSource is a repository of CSVs, CRDs, and operator packages. +type CatalogSource struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + + Spec CatalogSourceSpec `json:"spec"` + Status CatalogSourceStatus `json:"status"` +} + +func (c *CatalogSource) Address() string { + if c.Spec.Address != "" { + return c.Spec.Address + } + return c.Status.RegistryServiceStatus.Address() +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// CatalogSourceList is a repository of CSVs, CRDs, and operator packages. +type CatalogSourceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []CatalogSource `json:"items"` +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/clusterserviceversion.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/clusterserviceversion.go new file mode 100644 index 0000000000..9dd6f56f8d --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/clusterserviceversion.go @@ -0,0 +1,208 @@ +package v1alpha1 + +import ( + "fmt" + + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/tools/record" +) + +const ( + CopiedLabelKey = "olm.copiedFrom" + + // ConditionsLengthLimit is the maximum length of Status.Conditions of a + // given ClusterServiceVersion object. The oldest condition(s) are removed + // from the list as it grows over time to keep it at limit. + ConditionsLengthLimit = 20 +) + +// obsoleteReasons are the set of reasons that mean a CSV should no longer be processed as active +var obsoleteReasons = map[ConditionReason]struct{}{ + CSVReasonReplaced: {}, + CSVReasonBeingReplaced: {}, +} + +// uncopiableReasons are the set of reasons that should prevent a CSV from being copied to target namespaces +var uncopiableReasons = map[ConditionReason]struct{}{ + CSVReasonCopied: {}, + CSVReasonInvalidInstallModes: {}, + CSVReasonNoTargetNamespaces: {}, + CSVReasonUnsupportedOperatorGroup: {}, + CSVReasonNoOperatorGroup: {}, + CSVReasonTooManyOperatorGroups: {}, + CSVReasonInterOperatorGroupOwnerConflict: {}, + CSVReasonCannotModifyStaticOperatorGroupProvidedAPIs: {}, +} + +// safeToAnnotateOperatorGroupReasons are the set of reasons that it's safe to attempt to update the operatorgroup +// annotations +var safeToAnnotateOperatorGroupReasons = map[ConditionReason]struct{}{ + CSVReasonOwnerConflict: {}, + CSVReasonInstallSuccessful: {}, + CSVReasonInvalidInstallModes: {}, + CSVReasonNoTargetNamespaces: {}, + CSVReasonUnsupportedOperatorGroup: {}, + CSVReasonNoOperatorGroup: {}, + CSVReasonTooManyOperatorGroups: {}, + CSVReasonInterOperatorGroupOwnerConflict: {}, + CSVReasonCannotModifyStaticOperatorGroupProvidedAPIs: {}, +} + +// SetPhaseWithEventIfChanged emits a Kubernetes event with details of a phase change and sets the current phase if phase, reason, or message would changed +func (c *ClusterServiceVersion) SetPhaseWithEventIfChanged(phase ClusterServiceVersionPhase, reason ConditionReason, message string, now metav1.Time, recorder record.EventRecorder) { + if c.Status.Phase == phase && c.Status.Reason == reason && c.Status.Message == message { + return + } + + c.SetPhaseWithEvent(phase, reason, message, now, recorder) +} + +// SetPhaseWithEvent generates a Kubernetes event with details about the phase change and sets the current phase +func (c *ClusterServiceVersion) SetPhaseWithEvent(phase ClusterServiceVersionPhase, reason ConditionReason, message string, now metav1.Time, recorder record.EventRecorder) { + var eventtype string + if phase == CSVPhaseFailed { + eventtype = v1.EventTypeWarning + } else { + eventtype = v1.EventTypeNormal + } + go recorder.Event(c, eventtype, string(reason), message) + c.SetPhase(phase, reason, message, now) +} + +// SetPhase sets the current phase and adds a condition if necessary +func (c *ClusterServiceVersion) SetPhase(phase ClusterServiceVersionPhase, reason ConditionReason, message string, now metav1.Time) { + newCondition := func() ClusterServiceVersionCondition { + return ClusterServiceVersionCondition{ + Phase: c.Status.Phase, + LastTransitionTime: c.Status.LastTransitionTime, + LastUpdateTime: c.Status.LastUpdateTime, + Message: message, + Reason: reason, + } + } + + defer c.TrimConditionsIfLimitExceeded() + + c.Status.LastUpdateTime = now + if c.Status.Phase != phase { + c.Status.Phase = phase + c.Status.LastTransitionTime = now + } + c.Status.Message = message + c.Status.Reason = reason + if len(c.Status.Conditions) == 0 { + c.Status.Conditions = append(c.Status.Conditions, newCondition()) + return + } + + previousCondition := c.Status.Conditions[len(c.Status.Conditions)-1] + if previousCondition.Phase != c.Status.Phase || previousCondition.Reason != c.Status.Reason { + c.Status.Conditions = append(c.Status.Conditions, newCondition()) + } +} + +// SetRequirementStatus adds the status of all requirements to the CSV status +func (c *ClusterServiceVersion) SetRequirementStatus(statuses []RequirementStatus) { + c.Status.RequirementStatus = statuses +} + +// IsObsolete returns if this CSV is being replaced or is marked for deletion +func (c *ClusterServiceVersion) IsObsolete() bool { + for _, condition := range c.Status.Conditions { + _, ok := obsoleteReasons[condition.Reason] + if ok { + return true + } + } + return false +} + +// IsCopied returns true if the CSV has been copied and false otherwise. +func (c *ClusterServiceVersion) IsCopied() bool { + operatorNamespace, ok := c.GetAnnotations()[OperatorGroupNamespaceAnnotationKey] + if c.Status.Reason == CSVReasonCopied || ok && c.GetNamespace() != operatorNamespace { + return true + } + + if labels := c.GetLabels(); labels != nil { + if _, ok := labels[CopiedLabelKey]; ok { + return true + } + } + return false +} + +func (c *ClusterServiceVersion) IsUncopiable() bool { + if c.Status.Phase == CSVPhaseNone { + return true + } + _, ok := uncopiableReasons[c.Status.Reason] + return ok +} + +func (c *ClusterServiceVersion) IsSafeToUpdateOperatorGroupAnnotations() bool { + _, ok := safeToAnnotateOperatorGroupReasons[c.Status.Reason] + return ok +} + +// NewInstallModeSet returns an InstallModeSet instantiated from the given list of InstallModes. +// If the given list is not a set, an error is returned. +func NewInstallModeSet(modes []InstallMode) (InstallModeSet, error) { + set := InstallModeSet{} + for _, mode := range modes { + if _, exists := set[mode.Type]; exists { + return nil, fmt.Errorf("InstallMode list contains duplicates, cannot make set: %v", modes) + } + set[mode.Type] = mode.Supported + } + + return set, nil +} + +// Supports returns an error if the InstallModeSet does not support configuration for +// the given operatorNamespace and list of target namespaces. +func (set InstallModeSet) Supports(operatorNamespace string, namespaces []string) error { + numNamespaces := len(namespaces) + switch { + case numNamespaces == 0: + return fmt.Errorf("operatorgroup has invalid selected namespaces, cannot configure to watch zero namespaces") + case numNamespaces == 1: + switch namespaces[0] { + case operatorNamespace: + if !set[InstallModeTypeOwnNamespace] { + return fmt.Errorf("%s InstallModeType not supported, cannot configure to watch own namespace", InstallModeTypeOwnNamespace) + } + case v1.NamespaceAll: + if !set[InstallModeTypeAllNamespaces] { + return fmt.Errorf("%s InstallModeType not supported, cannot configure to watch all namespaces", InstallModeTypeAllNamespaces) + } + default: + if !set[InstallModeTypeSingleNamespace] { + return fmt.Errorf("%s InstallModeType not supported, cannot configure to watch one namespace", InstallModeTypeSingleNamespace) + } + } + case numNamespaces > 1 && !set[InstallModeTypeMultiNamespace]: + return fmt.Errorf("%s InstallModeType not supported, cannot configure to watch %d namespaces", InstallModeTypeMultiNamespace, numNamespaces) + case numNamespaces > 1: + for _, namespace := range namespaces { + if namespace == operatorNamespace && !set[InstallModeTypeOwnNamespace] { + return fmt.Errorf("%s InstallModeType not supported, cannot configure to watch own namespace", InstallModeTypeOwnNamespace) + } + if namespace == v1.NamespaceAll { + return fmt.Errorf("operatorgroup has invalid selected namespaces, NamespaceAll found when |selected namespaces| > 1") + } + } + } + + return nil +} + +func (c *ClusterServiceVersion) TrimConditionsIfLimitExceeded() { + if len(c.Status.Conditions) <= ConditionsLengthLimit { + return + } + + firstIndex := len(c.Status.Conditions) - ConditionsLengthLimit + c.Status.Conditions = c.Status.Conditions[firstIndex:len(c.Status.Conditions)] +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/clusterserviceversion_test.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/clusterserviceversion_test.go new file mode 100644 index 0000000000..3561a6d06c --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/clusterserviceversion_test.go @@ -0,0 +1,376 @@ +package v1alpha1 + +import ( + "fmt" + "testing" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + corev1 "k8s.io/api/core/v1" +) + +func TestSetRequirementStatus(t *testing.T) { + csv := ClusterServiceVersion{} + status := []RequirementStatus{{Group: "test", Version: "test", Kind: "Test", Name: "test", Status: "test", UUID: "test"}} + csv.SetRequirementStatus(status) + require.Equal(t, csv.Status.RequirementStatus, status) +} + +func TestSetPhase(t *testing.T) { + tests := []struct { + currentPhase ClusterServiceVersionPhase + currentConditions []ClusterServiceVersionCondition + inPhase ClusterServiceVersionPhase + outPhase ClusterServiceVersionPhase + description string + }{ + { + currentPhase: "", + currentConditions: []ClusterServiceVersionCondition{}, + inPhase: CSVPhasePending, + outPhase: CSVPhasePending, + description: "NoPhase", + }, + { + currentPhase: CSVPhasePending, + currentConditions: []ClusterServiceVersionCondition{{Phase: CSVPhasePending}}, + inPhase: CSVPhasePending, + outPhase: CSVPhasePending, + description: "SamePhase", + }, + { + currentPhase: CSVPhasePending, + currentConditions: []ClusterServiceVersionCondition{{Phase: CSVPhasePending}}, + inPhase: CSVPhaseInstalling, + outPhase: CSVPhaseInstalling, + description: "DifferentPhase", + }, + } + for _, tt := range tests { + t.Run(tt.description, func(t *testing.T) { + csv := ClusterServiceVersion{ + Status: ClusterServiceVersionStatus{ + Phase: tt.currentPhase, + Conditions: tt.currentConditions, + }, + } + csv.SetPhase(tt.inPhase, "test", "test", metav1.Now()) + require.EqualValues(t, tt.outPhase, csv.Status.Phase) + }) + } +} + +func TestIsObsolete(t *testing.T) { + tests := []struct { + currentPhase ClusterServiceVersionPhase + currentConditions []ClusterServiceVersionCondition + out bool + description string + }{ + { + currentPhase: "", + currentConditions: []ClusterServiceVersionCondition{}, + out: false, + description: "NoPhase", + }, + { + currentPhase: CSVPhasePending, + currentConditions: []ClusterServiceVersionCondition{{Phase: CSVPhasePending}}, + out: false, + description: "Pending", + }, + { + currentPhase: CSVPhaseReplacing, + currentConditions: []ClusterServiceVersionCondition{{Phase: CSVPhaseReplacing, Reason: CSVReasonBeingReplaced}}, + out: true, + description: "Replacing", + }, + { + currentPhase: CSVPhaseDeleting, + currentConditions: []ClusterServiceVersionCondition{{Phase: CSVPhaseDeleting, Reason: CSVReasonReplaced}}, + out: true, + description: "CSVPhaseDeleting", + }, + } + for _, tt := range tests { + t.Run(tt.description, func(t *testing.T) { + csv := ClusterServiceVersion{ + Status: ClusterServiceVersionStatus{ + Phase: tt.currentPhase, + Conditions: tt.currentConditions, + }, + } + require.Equal(t, csv.IsObsolete(), tt.out) + }) + } +} + +func TestSupports(t *testing.T) { + tests := []struct { + description string + installModeSet InstallModeSet + operatorNamespace string + namespaces []string + expectedErr error + }{ + { + description: "NoNamespaces", + installModeSet: InstallModeSet{ + InstallModeTypeOwnNamespace: true, + InstallModeTypeSingleNamespace: true, + InstallModeTypeMultiNamespace: true, + InstallModeTypeAllNamespaces: true, + }, + operatorNamespace: "operators", + namespaces: []string{}, + expectedErr: fmt.Errorf("operatorgroup has invalid selected namespaces, cannot configure to watch zero namespaces"), + }, + { + description: "OwnNamespace/OperatorNamespace/Supported", + installModeSet: InstallModeSet{ + InstallModeTypeOwnNamespace: true, + InstallModeTypeSingleNamespace: false, + InstallModeTypeMultiNamespace: false, + InstallModeTypeAllNamespaces: false, + }, + operatorNamespace: "operators", + namespaces: []string{"operators"}, + expectedErr: nil, + }, + { + description: "SingleNamespace/OtherNamespace/Supported", + installModeSet: InstallModeSet{ + InstallModeTypeOwnNamespace: false, + InstallModeTypeSingleNamespace: true, + InstallModeTypeMultiNamespace: false, + InstallModeTypeAllNamespaces: false, + }, + operatorNamespace: "operators", + namespaces: []string{"ns-0"}, + expectedErr: nil, + }, + { + description: "MultiNamespace/OtherNamespaces/Supported", + installModeSet: InstallModeSet{ + InstallModeTypeOwnNamespace: false, + InstallModeTypeSingleNamespace: false, + InstallModeTypeMultiNamespace: true, + InstallModeTypeAllNamespaces: false, + }, + operatorNamespace: "operators", + namespaces: []string{"ns-0", "ns-2"}, + expectedErr: nil, + }, + { + description: "AllNamespaces/NamespaceAll/Supported", + installModeSet: InstallModeSet{ + InstallModeTypeOwnNamespace: false, + InstallModeTypeSingleNamespace: false, + InstallModeTypeMultiNamespace: false, + InstallModeTypeAllNamespaces: true, + }, + operatorNamespace: "operators", + namespaces: []string{""}, + expectedErr: nil, + }, + { + description: "OwnNamespace/OperatorNamespace/Unsupported", + installModeSet: InstallModeSet{ + InstallModeTypeOwnNamespace: false, + InstallModeTypeSingleNamespace: true, + InstallModeTypeMultiNamespace: true, + InstallModeTypeAllNamespaces: true, + }, + operatorNamespace: "operators", + namespaces: []string{"operators"}, + expectedErr: fmt.Errorf("%s InstallModeType not supported, cannot configure to watch own namespace", InstallModeTypeOwnNamespace), + }, + { + description: "OwnNamespace/IncludesOperatorNamespace/Unsupported", + installModeSet: InstallModeSet{ + InstallModeTypeOwnNamespace: false, + InstallModeTypeSingleNamespace: true, + InstallModeTypeMultiNamespace: true, + InstallModeTypeAllNamespaces: true, + }, + operatorNamespace: "operators", + namespaces: []string{"ns-0", "operators"}, + expectedErr: fmt.Errorf("%s InstallModeType not supported, cannot configure to watch own namespace", InstallModeTypeOwnNamespace), + }, + { + description: "MultiNamespace/OtherNamespaces/Unsupported", + installModeSet: InstallModeSet{ + InstallModeTypeOwnNamespace: true, + InstallModeTypeSingleNamespace: true, + InstallModeTypeMultiNamespace: false, + InstallModeTypeAllNamespaces: true, + }, + operatorNamespace: "operators", + namespaces: []string{"ns-0", "ns-1"}, + expectedErr: fmt.Errorf("%s InstallModeType not supported, cannot configure to watch 2 namespaces", InstallModeTypeMultiNamespace), + }, + { + description: "SingleNamespace/OtherNamespace/Unsupported", + installModeSet: InstallModeSet{ + InstallModeTypeOwnNamespace: true, + InstallModeTypeSingleNamespace: false, + InstallModeTypeMultiNamespace: true, + InstallModeTypeAllNamespaces: true, + }, + operatorNamespace: "operators", + namespaces: []string{"ns-0"}, + expectedErr: fmt.Errorf("%s InstallModeType not supported, cannot configure to watch one namespace", InstallModeTypeSingleNamespace), + }, + { + description: "AllNamespaces/NamespaceAll/Unsupported", + installModeSet: InstallModeSet{ + InstallModeTypeOwnNamespace: true, + InstallModeTypeSingleNamespace: true, + InstallModeTypeMultiNamespace: true, + InstallModeTypeAllNamespaces: false, + }, + operatorNamespace: "operators", + namespaces: []string{""}, + expectedErr: fmt.Errorf("%s InstallModeType not supported, cannot configure to watch all namespaces", InstallModeTypeAllNamespaces), + }, + { + description: "AllNamespaces/IncludingNamespaceAll/Unsupported", + installModeSet: InstallModeSet{ + InstallModeTypeOwnNamespace: true, + InstallModeTypeSingleNamespace: true, + InstallModeTypeMultiNamespace: true, + InstallModeTypeAllNamespaces: true, + }, + operatorNamespace: "operators", + namespaces: []string{"", "ns-0"}, + expectedErr: fmt.Errorf("operatorgroup has invalid selected namespaces, NamespaceAll found when |selected namespaces| > 1"), + }, + { + description: "NoNamespaces/EmptyInstallModeSet/Unsupported", + installModeSet: InstallModeSet{}, + operatorNamespace: "", + namespaces: []string{}, + expectedErr: fmt.Errorf("operatorgroup has invalid selected namespaces, cannot configure to watch zero namespaces"), + }, + { + description: "MultiNamespace/OtherNamespaces/EmptyInstallModeSet/Unsupported", + installModeSet: InstallModeSet{}, + operatorNamespace: "operators", + namespaces: []string{"ns-0", "ns-1"}, + expectedErr: fmt.Errorf("%s InstallModeType not supported, cannot configure to watch 2 namespaces", InstallModeTypeMultiNamespace), + }, + { + description: "SingleNamespace/OtherNamespace/EmptyInstallModeSet/Unsupported", + installModeSet: InstallModeSet{}, + operatorNamespace: "operators", + namespaces: []string{"ns-0"}, + expectedErr: fmt.Errorf("%s InstallModeType not supported, cannot configure to watch one namespace", InstallModeTypeSingleNamespace), + }, + { + description: "AllNamespaces/NamespaceAll/EmptyInstallModeSet/Unsupported", + installModeSet: InstallModeSet{}, + operatorNamespace: "operators", + namespaces: []string{corev1.NamespaceAll}, + expectedErr: fmt.Errorf("%s InstallModeType not supported, cannot configure to watch all namespaces", InstallModeTypeAllNamespaces), + }, + } + + for _, tt := range tests { + t.Run(tt.description, func(t *testing.T) { + err := tt.installModeSet.Supports(tt.operatorNamespace, tt.namespaces) + require.Equal(t, tt.expectedErr, err) + }) + } +} + +func TestSetPhaseWithConditions(t *testing.T) { + tests := []struct { + description string + limit int + currentLength int + startIndex int + }{ + { + // The original list is already at limit (length == limit). + // We expect the oldest element ( item at 0 index) to be removed. + description: "TestSetPhaseWithConditionsLengthAtLimit", + limit: ConditionsLengthLimit, + currentLength: ConditionsLengthLimit, + + // The first element from the original list should be dropped from + // the new list. + startIndex: 1, + }, + { + // The original list is 1 length away from limit. + // We don't expect the list to be trimmed. + description: "TestSetPhaseWithConditionsLengthBelowLimit", + limit: ConditionsLengthLimit, + currentLength: ConditionsLengthLimit - 1, + + // Everything in the original list should be preserved. + startIndex: 0, + }, + { + // The original list has N more element(s) than allowed limit. + // We expect (N + 1) oldest elements to be deleted to keep the list + // at limit. + description: "TestSetPhaseWithConditionsLimitExceeded", + limit: ConditionsLengthLimit, + currentLength: ConditionsLengthLimit + 10, + + // The first 11 (N=10 plus 1 to make room for the newly added + // condition) elements from the original list should be dropped. + startIndex: 11, + }, + } + + for _, tt := range tests { + t.Run(tt.description, func(t *testing.T) { + csv := ClusterServiceVersion{} + csv.Status.Conditions = helperNewConditions(tt.currentLength) + + now := metav1.Now() + + oldConditionsWant := csv.Status.Conditions[tt.startIndex:] + lastAddedConditionWant := ClusterServiceVersionCondition{ + Phase: ClusterServiceVersionPhase("Pending"), + LastTransitionTime: now, + LastUpdateTime: now, + Message: "message", + Reason: ConditionReason("reason"), + } + + csv.SetPhase("Pending", "reason", "message", now) + + conditionsGot := csv.Status.Conditions + assert.Equal(t, tt.limit, len(conditionsGot)) + + oldConditionsGot := conditionsGot[0 : len(conditionsGot)-1] + assert.EqualValues(t, oldConditionsWant, oldConditionsGot) + + lastAddedConditionGot := conditionsGot[len(conditionsGot)-1] + assert.Equal(t, lastAddedConditionWant, lastAddedConditionGot) + }) + } +} + +func helperNewConditions(count int) []ClusterServiceVersionCondition { + conditions := make([]ClusterServiceVersionCondition, 0) + + for i := 1; i <= count; i++ { + now := metav1.Now() + condition := ClusterServiceVersionCondition{ + Phase: ClusterServiceVersionPhase(fmt.Sprintf("phase-%d", i)), + LastTransitionTime: now, + LastUpdateTime: now, + Message: fmt.Sprintf("message-%d", i), + Reason: ConditionReason(fmt.Sprintf("reason-%d", i)), + } + conditions = append(conditions, condition) + } + + return conditions +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/clusterserviceversion_types.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/clusterserviceversion_types.go new file mode 100644 index 0000000000..c55b6af800 --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/clusterserviceversion_types.go @@ -0,0 +1,500 @@ +package v1alpha1 + +import ( + "encoding/json" + "fmt" + "sort" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/version" +) + +const ( + ClusterServiceVersionAPIVersion = GroupName + "/" + GroupVersion + ClusterServiceVersionKind = "ClusterServiceVersion" + OperatorGroupNamespaceAnnotationKey = "olm.operatorNamespace" +) + +// InstallModeType is a supported type of install mode for CSV installation +type InstallModeType string + +const ( + // InstallModeTypeOwnNamespace indicates that the operator can be a member of an `OperatorGroup` that selects its own namespace. + InstallModeTypeOwnNamespace InstallModeType = "OwnNamespace" + // InstallModeTypeSingleNamespace indicates that the operator can be a member of an `OperatorGroup` that selects one namespace. + InstallModeTypeSingleNamespace InstallModeType = "SingleNamespace" + // InstallModeTypeMultiNamespace indicates that the operator can be a member of an `OperatorGroup` that selects more than one namespace. + InstallModeTypeMultiNamespace InstallModeType = "MultiNamespace" + // InstallModeTypeAllNamespaces indicates that the operator can be a member of an `OperatorGroup` that selects all namespaces (target namespace set is the empty string ""). + InstallModeTypeAllNamespaces InstallModeType = "AllNamespaces" +) + +// InstallMode associates an InstallModeType with a flag representing if the CSV supports it +// +k8s:openapi-gen=true +type InstallMode struct { + Type InstallModeType `json:"type"` + Supported bool `json:"supported"` +} + +// InstallModeSet is a mapping of unique InstallModeTypes to whether they are supported. +type InstallModeSet map[InstallModeType]bool + +// NamedInstallStrategy represents the block of an ClusterServiceVersion resource +// where the install strategy is specified. +type NamedInstallStrategy struct { + StrategyName string `json:"strategy"` + StrategySpecRaw json.RawMessage `json:"spec,omitempty"` +} + +// StatusDescriptor describes a field in a status block of a CRD so that OLM can consume it +// +k8s:openapi-gen=true +type StatusDescriptor struct { + Path string `json:"path"` + DisplayName string `json:"displayName,omitempty"` + Description string `json:"description,omitempty"` + XDescriptors []string `json:"x-descriptors,omitempty"` + Value *json.RawMessage `json:"value,omitempty"` +} + +// SpecDescriptor describes a field in a spec block of a CRD so that OLM can consume it +// +k8s:openapi-gen=true +type SpecDescriptor struct { + Path string `json:"path"` + DisplayName string `json:"displayName,omitempty"` + Description string `json:"description,omitempty"` + XDescriptors []string `json:"x-descriptors,omitempty"` + Value *json.RawMessage `json:"value,omitempty"` +} + +// ActionDescriptor describes a declarative action that can be performed on a custom resource instance +// +k8s:openapi-gen=true +type ActionDescriptor struct { + Path string `json:"path"` + DisplayName string `json:"displayName,omitempty"` + Description string `json:"description,omitempty"` + XDescriptors []string `json:"x-descriptors,omitempty"` + Value *json.RawMessage `json:"value,omitempty"` +} + +// CRDDescription provides details to OLM about the CRDs +// +k8s:openapi-gen=true +type CRDDescription struct { + Name string `json:"name"` + Version string `json:"version"` + Kind string `json:"kind"` + DisplayName string `json:"displayName,omitempty"` + Description string `json:"description,omitempty"` + Resources []APIResourceReference `json:"resources,omitempty"` + StatusDescriptors []StatusDescriptor `json:"statusDescriptors,omitempty"` + SpecDescriptors []SpecDescriptor `json:"specDescriptors,omitempty"` + ActionDescriptor []ActionDescriptor `json:"actionDescriptors,omitempty"` +} + +// APIServiceDescription provides details to OLM about apis provided via aggregation +// +k8s:openapi-gen=true +type APIServiceDescription struct { + Name string `json:"name"` + Group string `json:"group"` + Version string `json:"version"` + Kind string `json:"kind"` + DeploymentName string `json:"deploymentName,omitempty"` + ContainerPort int32 `json:"containerPort,omitempty"` + DisplayName string `json:"displayName,omitempty"` + Description string `json:"description,omitempty"` + Resources []APIResourceReference `json:"resources,omitempty"` + StatusDescriptors []StatusDescriptor `json:"statusDescriptors,omitempty"` + SpecDescriptors []SpecDescriptor `json:"specDescriptors,omitempty"` + ActionDescriptor []ActionDescriptor `json:"actionDescriptors,omitempty"` +} + +// APIResourceReference is a Kubernetes resource type used by a custom resource +// +k8s:openapi-gen=true +type APIResourceReference struct { + Name string `json:"name"` + Kind string `json:"kind"` + Version string `json:"version"` +} + +// GetName returns the name of an APIService as derived from its group and version. +func (d APIServiceDescription) GetName() string { + return fmt.Sprintf("%s.%s", d.Version, d.Group) +} + +// CustomResourceDefinitions declares all of the CRDs managed or required by +// an operator being ran by ClusterServiceVersion. +// +// If the CRD is present in the Owned list, it is implicitly required. +// +k8s:openapi-gen=true +type CustomResourceDefinitions struct { + Owned []CRDDescription `json:"owned,omitempty"` + Required []CRDDescription `json:"required,omitempty"` +} + +// APIServiceDefinitions declares all of the extension apis managed or required by +// an operator being ran by ClusterServiceVersion. +// +k8s:openapi-gen=true +type APIServiceDefinitions struct { + Owned []APIServiceDescription `json:"owned,omitempty"` + Required []APIServiceDescription `json:"required,omitempty"` +} + +// ClusterServiceVersionSpec declarations tell OLM how to install an operator +// that can manage apps for a given version. +type ClusterServiceVersionSpec struct { + InstallStrategy NamedInstallStrategy `json:"install"` + Version version.OperatorVersion `json:"version,omitempty"` + Maturity string `json:"maturity,omitempty"` + CustomResourceDefinitions CustomResourceDefinitions `json:"customresourcedefinitions,omitempty"` + APIServiceDefinitions APIServiceDefinitions `json:"apiservicedefinitions,omitempty"` + NativeAPIs []metav1.GroupVersionKind `json:"nativeAPIs,omitempty"` + MinKubeVersion string `json:"minKubeVersion,omitempty"` + DisplayName string `json:"displayName"` + Description string `json:"description,omitempty"` + Keywords []string `json:"keywords,omitempty"` + Maintainers []Maintainer `json:"maintainers,omitempty"` + Provider AppLink `json:"provider,omitempty"` + Links []AppLink `json:"links,omitempty"` + Icon []Icon `json:"icon,omitempty"` + + // InstallModes specify supported installation types + // +optional + InstallModes []InstallMode `json:"installModes,omitempty"` + + // The name of a CSV this one replaces. Should match the `metadata.Name` field of the old CSV. + // +optional + Replaces string `json:"replaces,omitempty"` + + // Map of string keys and values that can be used to organize and categorize + // (scope and select) objects. + // +optional + Labels map[string]string `json:"labels,omitempty" protobuf:"bytes,11,rep,name=labels"` + + // Annotations is an unstructured key value map stored with a resource that may be + // set by external tools to store and retrieve arbitrary metadata. + // +optional + Annotations map[string]string `json:"annotations,omitempty" protobuf:"bytes,12,rep,name=annotations"` + + // Label selector for related resources. + // +optional + Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,2,opt,name=selector"` +} + +type Maintainer struct { + Name string `json:"name,omitempty"` + Email string `json:"email,omitempty"` +} + +type AppLink struct { + Name string `json:"name,omitempty"` + URL string `json:"url,omitempty"` +} + +type Icon struct { + Data string `json:"base64data"` + MediaType string `json:"mediatype"` +} + +// ClusterServiceVersionPhase is a label for the condition of a ClusterServiceVersion at the current time. +type ClusterServiceVersionPhase string + +// These are the valid phases of ClusterServiceVersion +const ( + CSVPhaseNone = "" + // CSVPhasePending means the csv has been accepted by the system, but the install strategy has not been attempted. + // This is likely because there are unmet requirements. + CSVPhasePending ClusterServiceVersionPhase = "Pending" + // CSVPhaseInstallReady means that the requirements are met but the install strategy has not been run. + CSVPhaseInstallReady ClusterServiceVersionPhase = "InstallReady" + // CSVPhaseInstalling means that the install strategy has been initiated but not completed. + CSVPhaseInstalling ClusterServiceVersionPhase = "Installing" + // CSVPhaseSucceeded means that the resources in the CSV were created successfully. + CSVPhaseSucceeded ClusterServiceVersionPhase = "Succeeded" + // CSVPhaseFailed means that the install strategy could not be successfully completed. + CSVPhaseFailed ClusterServiceVersionPhase = "Failed" + // CSVPhaseUnknown means that for some reason the state of the csv could not be obtained. + CSVPhaseUnknown ClusterServiceVersionPhase = "Unknown" + // CSVPhaseReplacing means that a newer CSV has been created and the csv's resources will be transitioned to a new owner. + CSVPhaseReplacing ClusterServiceVersionPhase = "Replacing" + // CSVPhaseDeleting means that a CSV has been replaced by a new one and will be checked for safety before being deleted + CSVPhaseDeleting ClusterServiceVersionPhase = "Deleting" + // CSVPhaseAny matches all other phases in CSV queries + CSVPhaseAny ClusterServiceVersionPhase = "" +) + +// ConditionReason is a camelcased reason for the state transition +type ConditionReason string + +const ( + CSVReasonRequirementsUnknown ConditionReason = "RequirementsUnknown" + CSVReasonRequirementsNotMet ConditionReason = "RequirementsNotMet" + CSVReasonRequirementsMet ConditionReason = "AllRequirementsMet" + CSVReasonOwnerConflict ConditionReason = "OwnerConflict" + CSVReasonComponentFailed ConditionReason = "InstallComponentFailed" + CSVReasonInvalidStrategy ConditionReason = "InvalidInstallStrategy" + CSVReasonWaiting ConditionReason = "InstallWaiting" + CSVReasonInstallSuccessful ConditionReason = "InstallSucceeded" + CSVReasonInstallCheckFailed ConditionReason = "InstallCheckFailed" + CSVReasonComponentUnhealthy ConditionReason = "ComponentUnhealthy" + CSVReasonBeingReplaced ConditionReason = "BeingReplaced" + CSVReasonReplaced ConditionReason = "Replaced" + CSVReasonNeedsReinstall ConditionReason = "NeedsReinstall" + CSVReasonNeedsCertRotation ConditionReason = "NeedsCertRotation" + CSVReasonAPIServiceResourceIssue ConditionReason = "APIServiceResourceIssue" + CSVReasonAPIServiceResourcesNeedReinstall ConditionReason = "APIServiceResourcesNeedReinstall" + CSVReasonAPIServiceInstallFailed ConditionReason = "APIServiceInstallFailed" + CSVReasonCopied ConditionReason = "Copied" + CSVReasonInvalidInstallModes ConditionReason = "InvalidInstallModes" + CSVReasonNoTargetNamespaces ConditionReason = "NoTargetNamespaces" + CSVReasonUnsupportedOperatorGroup ConditionReason = "UnsupportedOperatorGroup" + CSVReasonNoOperatorGroup ConditionReason = "NoOperatorGroup" + CSVReasonTooManyOperatorGroups ConditionReason = "TooManyOperatorGroups" + CSVReasonInterOperatorGroupOwnerConflict ConditionReason = "InterOperatorGroupOwnerConflict" + CSVReasonCannotModifyStaticOperatorGroupProvidedAPIs ConditionReason = "CannotModifyStaticOperatorGroupProvidedAPIs" +) + +// Conditions appear in the status as a record of state transitions on the ClusterServiceVersion +type ClusterServiceVersionCondition struct { + // Condition of the ClusterServiceVersion + Phase ClusterServiceVersionPhase `json:"phase,omitempty"` + // A human readable message indicating details about why the ClusterServiceVersion is in this condition. + // +optional + Message string `json:"message,omitempty"` + // A brief CamelCase message indicating details about why the ClusterServiceVersion is in this state. + // e.g. 'RequirementsNotMet' + // +optional + Reason ConditionReason `json:"reason,omitempty"` + // Last time we updated the status + // +optional + LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"` + // Last time the status transitioned from one status to another. + // +optional + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` +} + +// OwnsCRD determines whether the current CSV owns a paritcular CRD. +func (csv ClusterServiceVersion) OwnsCRD(name string) bool { + for _, desc := range csv.Spec.CustomResourceDefinitions.Owned { + if desc.Name == name { + return true + } + } + + return false +} + +// OwnsAPIService determines whether the current CSV owns a paritcular APIService. +func (csv ClusterServiceVersion) OwnsAPIService(name string) bool { + for _, desc := range csv.Spec.APIServiceDefinitions.Owned { + apiServiceName := fmt.Sprintf("%s.%s", desc.Version, desc.Group) + if apiServiceName == name { + return true + } + } + + return false +} + +// StatusReason is a camelcased reason for the status of a RequirementStatus or DependentStatus +type StatusReason string + +const ( + RequirementStatusReasonPresent StatusReason = "Present" + RequirementStatusReasonNotPresent StatusReason = "NotPresent" + RequirementStatusReasonPresentNotSatisfied StatusReason = "PresentNotSatisfied" + // The CRD is present but the Established condition is False (not available) + RequirementStatusReasonNotAvailable StatusReason = "PresentNotAvailable" + DependentStatusReasonSatisfied StatusReason = "Satisfied" + DependentStatusReasonNotSatisfied StatusReason = "NotSatisfied" +) + +// DependentStatus is the status for a dependent requirement (to prevent infinite nesting) +type DependentStatus struct { + Group string `json:"group"` + Version string `json:"version"` + Kind string `json:"kind"` + Status StatusReason `json:"status"` + UUID string `json:"uuid,omitempty"` + Message string `json:"message,omitempty"` +} + +type RequirementStatus struct { + Group string `json:"group"` + Version string `json:"version"` + Kind string `json:"kind"` + Name string `json:"name"` + Status StatusReason `json:"status"` + Message string `json:"message"` + UUID string `json:"uuid,omitempty"` + Dependents []DependentStatus `json:"dependents,omitempty"` +} + +// ClusterServiceVersionStatus represents information about the status of a pod. Status may trail the actual +// state of a system. +type ClusterServiceVersionStatus struct { + // Current condition of the ClusterServiceVersion + Phase ClusterServiceVersionPhase `json:"phase,omitempty"` + // A human readable message indicating details about why the ClusterServiceVersion is in this condition. + // +optional + Message string `json:"message,omitempty"` + // A brief CamelCase message indicating details about why the ClusterServiceVersion is in this state. + // e.g. 'RequirementsNotMet' + // +optional + Reason ConditionReason `json:"reason,omitempty"` + // Last time we updated the status + // +optional + LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"` + // Last time the status transitioned from one status to another. + // +optional + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` + // List of conditions, a history of state transitions + Conditions []ClusterServiceVersionCondition `json:"conditions,omitempty"` + // The status of each requirement for this CSV + RequirementStatus []RequirementStatus `json:"requirementStatus,omitempty"` + // Last time the owned APIService certs were updated + // +optional + CertsLastUpdated metav1.Time `json:"certsLastUpdated,omitempty"` + // Time the owned APIService certs will rotate next + // +optional + CertsRotateAt metav1.Time `json:"certsRotateAt,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// ClusterServiceVersion is a Custom Resource of type `ClusterServiceVersionSpec`. +type ClusterServiceVersion struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + + Spec ClusterServiceVersionSpec `json:"spec"` + Status ClusterServiceVersionStatus `json:"status"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ClusterServiceVersionList represents a list of ClusterServiceVersions. +type ClusterServiceVersionList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []ClusterServiceVersion `json:"items"` +} + +// GetAllCRDDescriptions returns a deduplicated set of CRDDescriptions that is +// the union of the owned and required CRDDescriptions. +// +// Descriptions with the same name prefer the value in Owned. +// Descriptions are returned in alphabetical order. +func (csv ClusterServiceVersion) GetAllCRDDescriptions() []CRDDescription { + set := make(map[string]CRDDescription) + for _, required := range csv.Spec.CustomResourceDefinitions.Required { + set[required.Name] = required + } + + for _, owned := range csv.Spec.CustomResourceDefinitions.Owned { + set[owned.Name] = owned + } + + keys := make([]string, 0) + for key := range set { + keys = append(keys, key) + } + sort.StringSlice(keys).Sort() + + descs := make([]CRDDescription, 0) + for _, key := range keys { + descs = append(descs, set[key]) + } + + return descs +} + +// GetAllAPIServiceDescriptions returns a deduplicated set of APIServiceDescriptions that is +// the union of the owned and required APIServiceDescriptions. +// +// Descriptions with the same name prefer the value in Owned. +// Descriptions are returned in alphabetical order. +func (csv ClusterServiceVersion) GetAllAPIServiceDescriptions() []APIServiceDescription { + set := make(map[string]APIServiceDescription) + for _, required := range csv.Spec.APIServiceDefinitions.Required { + name := fmt.Sprintf("%s.%s", required.Version, required.Group) + set[name] = required + } + + for _, owned := range csv.Spec.APIServiceDefinitions.Owned { + name := fmt.Sprintf("%s.%s", owned.Version, owned.Group) + set[name] = owned + } + + keys := make([]string, 0) + for key := range set { + keys = append(keys, key) + } + sort.StringSlice(keys).Sort() + + descs := make([]APIServiceDescription, 0) + for _, key := range keys { + descs = append(descs, set[key]) + } + + return descs +} + +// GetRequiredAPIServiceDescriptions returns a deduplicated set of required APIServiceDescriptions +// with the intersection of required and owned removed +// Equivalent to the set subtraction required - owned +// +// Descriptions are returned in alphabetical order. +func (csv ClusterServiceVersion) GetRequiredAPIServiceDescriptions() []APIServiceDescription { + set := make(map[string]APIServiceDescription) + for _, required := range csv.Spec.APIServiceDefinitions.Required { + name := fmt.Sprintf("%s.%s", required.Version, required.Group) + set[name] = required + } + + // Remove any shared owned from the set + for _, owned := range csv.Spec.APIServiceDefinitions.Owned { + name := fmt.Sprintf("%s.%s", owned.Version, owned.Group) + if _, ok := set[name]; ok { + delete(set, name) + } + } + + keys := make([]string, 0) + for key := range set { + keys = append(keys, key) + } + sort.StringSlice(keys).Sort() + + descs := make([]APIServiceDescription, 0) + for _, key := range keys { + descs = append(descs, set[key]) + } + + return descs +} + +// GetOwnedAPIServiceDescriptions returns a deduplicated set of owned APIServiceDescriptions +// +// Descriptions are returned in alphabetical order. +func (csv ClusterServiceVersion) GetOwnedAPIServiceDescriptions() []APIServiceDescription { + set := make(map[string]APIServiceDescription) + for _, owned := range csv.Spec.APIServiceDefinitions.Owned { + name := owned.GetName() + set[name] = owned + } + + keys := make([]string, 0) + for key := range set { + keys = append(keys, key) + } + sort.StringSlice(keys).Sort() + + descs := make([]APIServiceDescription, 0) + for _, key := range keys { + descs = append(descs, set[key]) + } + + return descs +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/doc.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/doc.go new file mode 100644 index 0000000000..3938a475ee --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/doc.go @@ -0,0 +1,6 @@ +// +k8s:deepcopy-gen=package +// +k8s:conversion-gen=github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators +// +groupName=operators.coreos.com + +// Package v1alpha1 contains resources types for version v1alpha1 of the operators.coreos.com API group. +package v1alpha1 diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/installplan_types.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/installplan_types.go new file mode 100644 index 0000000000..8bbe7eb3d8 --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/installplan_types.go @@ -0,0 +1,251 @@ +package v1alpha1 + +import ( + "errors" + "fmt" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + InstallPlanKind = "InstallPlan" + InstallPlanAPIVersion = GroupName + "/" + GroupVersion +) + +// Approval is the user approval policy for an InstallPlan. +type Approval string + +const ( + ApprovalAutomatic Approval = "Automatic" + ApprovalManual Approval = "Manual" +) + +// InstallPlanSpec defines a set of Application resources to be installed +type InstallPlanSpec struct { + CatalogSource string `json:"source"` + CatalogSourceNamespace string `json:"sourceNamespace"` + ClusterServiceVersionNames []string `json:"clusterServiceVersionNames"` + Approval Approval `json:"approval"` + Approved bool `json:"approved"` +} + +// InstallPlanPhase is the current status of a InstallPlan as a whole. +type InstallPlanPhase string + +const ( + InstallPlanPhaseNone InstallPlanPhase = "" + InstallPlanPhasePlanning InstallPlanPhase = "Planning" + InstallPlanPhaseRequiresApproval InstallPlanPhase = "RequiresApproval" + InstallPlanPhaseInstalling InstallPlanPhase = "Installing" + InstallPlanPhaseComplete InstallPlanPhase = "Complete" + InstallPlanPhaseFailed InstallPlanPhase = "Failed" +) + +// InstallPlanConditionType describes the state of an InstallPlan at a certain point as a whole. +type InstallPlanConditionType string + +const ( + InstallPlanResolved InstallPlanConditionType = "Resolved" + InstallPlanInstalled InstallPlanConditionType = "Installed" +) + +// ConditionReason is a camelcased reason for the state transition. +type InstallPlanConditionReason string + +const ( + InstallPlanReasonPlanUnknown InstallPlanConditionReason = "PlanUnknown" + InstallPlanReasonInstallCheckFailed InstallPlanConditionReason = "InstallCheckFailed" + InstallPlanReasonDependencyConflict InstallPlanConditionReason = "DependenciesConflict" + InstallPlanReasonComponentFailed InstallPlanConditionReason = "InstallComponentFailed" +) + +// StepStatus is the current status of a particular resource an in +// InstallPlan +type StepStatus string + +const ( + StepStatusUnknown StepStatus = "Unknown" + StepStatusNotPresent StepStatus = "NotPresent" + StepStatusPresent StepStatus = "Present" + StepStatusCreated StepStatus = "Created" +) + +// ErrInvalidInstallPlan is the error returned by functions that operate on +// InstallPlans when the InstallPlan does not contain totally valid data. +var ErrInvalidInstallPlan = errors.New("the InstallPlan contains invalid data") + +// InstallPlanStatus represents the information about the status of +// steps required to complete installation. +// +// Status may trail the actual state of a system. +type InstallPlanStatus struct { + Phase InstallPlanPhase `json:"phase"` + Conditions []InstallPlanCondition `json:"conditions,omitempty"` + CatalogSources []string `json:"catalogSources"` + Plan []*Step `json:"plan,omitempty"` +} + +// InstallPlanCondition represents the overall status of the execution of +// an InstallPlan. +type InstallPlanCondition struct { + Type InstallPlanConditionType `json:"type,omitempty"` + Status corev1.ConditionStatus `json:"status,omitempty"` // True, False, or Unknown + LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"` + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` + Reason InstallPlanConditionReason `json:"reason,omitempty"` + Message string `json:"message,omitempty"` +} + +// allow overwriting `now` function for deterministic tests +var now = metav1.Now + +// GetCondition returns the InstallPlanCondition of the given type if it exists in the InstallPlanStatus' Conditions. +// Returns a condition of the given type with a ConditionStatus of "Unknown" if not found. +func (s InstallPlanStatus) GetCondition(conditionType InstallPlanConditionType) InstallPlanCondition { + for _, cond := range s.Conditions { + if cond.Type == conditionType { + return cond + } + } + + return InstallPlanCondition{ + Type: conditionType, + Status: corev1.ConditionUnknown, + } +} + +// SetCondition adds or updates a condition, using `Type` as merge key. +func (s *InstallPlanStatus) SetCondition(cond InstallPlanCondition) InstallPlanCondition { + for i, existing := range s.Conditions { + if existing.Type != cond.Type { + continue + } + if existing.Status == cond.Status { + cond.LastTransitionTime = existing.LastTransitionTime + } + s.Conditions[i] = cond + return cond + } + s.Conditions = append(s.Conditions, cond) + return cond +} + + +func ConditionFailed(cond InstallPlanConditionType, reason InstallPlanConditionReason, message string, now *metav1.Time) InstallPlanCondition { + return InstallPlanCondition{ + Type: cond, + Status: corev1.ConditionFalse, + Reason: reason, + Message: message, + LastUpdateTime: *now, + LastTransitionTime: *now, + } +} + +func ConditionMet(cond InstallPlanConditionType, now *metav1.Time) InstallPlanCondition { + return InstallPlanCondition{ + Type: cond, + Status: corev1.ConditionTrue, + LastUpdateTime: *now, + LastTransitionTime: *now, + } +} + +// Step represents the status of an individual step in an InstallPlan. +type Step struct { + Resolving string `json:"resolving"` + Resource StepResource `json:"resource"` + Status StepStatus `json:"status"` +} + +// ManifestsMatch returns true if the CSV manifests in the StepResources of the given list of steps +// matches those in the InstallPlanStatus. +func (s *InstallPlanStatus) CSVManifestsMatch(steps []*Step) bool { + if s.Plan == nil && steps == nil { + return true + } + if s.Plan == nil || steps == nil { + return false + } + + manifests := make(map[string]struct{}) + for _, step := range s.Plan { + resource := step.Resource + if resource.Kind != ClusterServiceVersionKind { + continue + } + manifests[resource.Manifest] = struct{}{} + } + + for _, step := range steps { + resource := step.Resource + if resource.Kind != ClusterServiceVersionKind { + continue + } + if _, ok := manifests[resource.Manifest]; !ok { + return false + } + delete(manifests, resource.Manifest) + } + + if len(manifests) == 0 { + return true + } + + return false +} + +func (s *Step) String() string { + return fmt.Sprintf("%s: %s (%s)", s.Resolving, s.Resource, s.Status) +} + +// StepResource represents the status of a resource to be tracked by an +// InstallPlan. +type StepResource struct { + CatalogSource string `json:"sourceName"` + CatalogSourceNamespace string `json:"sourceNamespace"` + Group string `json:"group"` + Version string `json:"version"` + Kind string `json:"kind"` + Name string `json:"name"` + Manifest string `json:"manifest,omitempty"` +} + +func (r StepResource) String() string { + return fmt.Sprintf("%s[%s/%s/%s (%s/%s)]", r.Name, r.Group, r.Version, r.Kind, r.CatalogSource, r.CatalogSourceNamespace) +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// InstallPlan defines the installation of a set of operators. +type InstallPlan struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + + Spec InstallPlanSpec `json:"spec"` + Status InstallPlanStatus `json:"status"` +} + +// EnsureCatalogSource ensures that a CatalogSource is present in the Status +// block of an InstallPlan. +func (p *InstallPlan) EnsureCatalogSource(sourceName string) { + for _, srcName := range p.Status.CatalogSources { + if srcName == sourceName { + return + } + } + + p.Status.CatalogSources = append(p.Status.CatalogSources, sourceName) +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// InstallPlanList is a list of InstallPlan resources. +type InstallPlanList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []InstallPlan `json:"items"` +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/register.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/register.go new file mode 100644 index 0000000000..fbd1ef6afd --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/register.go @@ -0,0 +1,55 @@ +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + + "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators" +) + +const ( + // GroupName is the group name used in this package. + GroupName = operators.GroupName + // GroupVersion is the group version used in this package. + GroupVersion = "v1alpha1" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: GroupVersion} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder initializes a scheme builder + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + // AddToScheme is a global function that registers this API group & version to a scheme + AddToScheme = SchemeBuilder.AddToScheme + + // localSchemeBuilder is expected by generated conversion functions + localSchemeBuilder = &SchemeBuilder +) + +// addKnownTypes adds the list of known types to Scheme +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &CatalogSource{}, + &CatalogSourceList{}, + &InstallPlan{}, + &InstallPlanList{}, + &Subscription{}, + &SubscriptionList{}, + &ClusterServiceVersion{}, + &ClusterServiceVersionList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/subscription_types.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/subscription_types.go new file mode 100644 index 0000000000..8d2a4809b5 --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/subscription_types.go @@ -0,0 +1,266 @@ +package v1alpha1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +) + +const ( + SubscriptionKind = "Subscription" + SubscriptionCRDAPIVersion = GroupName + "/" + GroupVersion +) + +// SubscriptionState tracks when updates are available, installing, or service is up to date +type SubscriptionState string + +const ( + SubscriptionStateNone = "" + SubscriptionStateFailed = "UpgradeFailed" + SubscriptionStateUpgradeAvailable = "UpgradeAvailable" + SubscriptionStateUpgradePending = "UpgradePending" + SubscriptionStateAtLatest = "AtLatestKnown" +) + +const ( + SubscriptionReasonInvalidCatalog ConditionReason = "InvalidCatalog" + SubscriptionReasonUpgradeSucceeded ConditionReason = "UpgradeSucceeded" +) + +// SubscriptionSpec defines an Application that can be installed +type SubscriptionSpec struct { + CatalogSource string `json:"source"` + CatalogSourceNamespace string `json:"sourceNamespace"` + Package string `json:"name"` + Channel string `json:"channel,omitempty"` + StartingCSV string `json:"startingCSV,omitempty"` + InstallPlanApproval Approval `json:"installPlanApproval,omitempty"` +} + +// SubscriptionConditionType indicates an explicit state condition about a Subscription in "abnormal-true" +// polarity form (see https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties). +type SubscriptionConditionType string + +const ( + // SubscriptionCatalogSourcesUnhealthy indicates that some or all of the CatalogSources to be used in resolution are unhealthy. + SubscriptionCatalogSourcesUnhealthy SubscriptionConditionType = "CatalogSourcesUnhealthy" + + // SubscriptionInstallPlanMissing indicates that a Subscription's InstallPlan is missing. + SubscriptionInstallPlanMissing SubscriptionConditionType = "InstallPlanMissing" + + // SubscriptionInstallPlanPending indicates that a Subscription's InstallPlan is pending installation. + SubscriptionInstallPlanPending SubscriptionConditionType = "InstallPlanPending" + + // SubscriptionInstallPlanFailed indicates that the installation of a Subscription's InstallPlan has failed. + SubscriptionInstallPlanFailed SubscriptionConditionType = "InstallPlanFailed" +) + +const ( + // NoCatalogSourcesFound is a reason string for Subscriptions with unhealthy CatalogSources due to none being available. + NoCatalogSourcesFound = "NoCatalogSourcesFound" + + // AllCatalogSourcesHealthy is a reason string for Subscriptions that transitioned due to all CatalogSources being healthy. + AllCatalogSourcesHealthy = "AllCatalogSourcesHealthy" + + // CatalogSourcesAdded is a reason string for Subscriptions that transitioned due to CatalogSources being added. + CatalogSourcesAdded = "CatalogSourcesAdded" + + // CatalogSourcesUpdated is a reason string for Subscriptions that transitioned due to CatalogSource being updated. + CatalogSourcesUpdated = "CatalogSourcesUpdated" + + // CatalogSourcesDeleted is a reason string for Subscriptions that transitioned due to CatalogSources being removed. + CatalogSourcesDeleted = "CatalogSourcesDeleted" + + // UnhealthyCatalogSourceFound is a reason string for Subscriptions that transitioned because an unhealthy CatalogSource was found. + UnhealthyCatalogSourceFound = "UnhealthyCatalogSourceFound" + + // ReferencedInstallPlanNotFound is a reason string for Subscriptions that transitioned due to a referenced InstallPlan not being found. + ReferencedInstallPlanNotFound = "ReferencedInstallPlanNotFound" + + // InstallPlanNotYetReconciled is a reason string for Subscriptions that transitioned due to a referenced InstallPlan not being reconciled yet. + InstallPlanNotYetReconciled = "InstallPlanNotYetReconciled" + + // InstallPlanFailed is a reason string for Subscriptions that transitioned due to a referenced InstallPlan failing without setting an explicit failure condition. + InstallPlanFailed = "InstallPlanFailed" +) + +// SubscriptionCondition represents the latest available observations of a Subscription's state. +type SubscriptionCondition struct { + // Type is the type of Subscription condition. + Type SubscriptionConditionType `json:"type" description:"type of Subscription condition"` + + // Status is the status of the condition, one of True, False, Unknown. + Status corev1.ConditionStatus `json:"status" description:"status of the condition, one of True, False, Unknown"` + + // Reason is a one-word CamelCase reason for the condition's last transition. + // +optional + Reason string `json:"reason,omitempty" description:"one-word CamelCase reason for the condition's last transition"` + + // Message is a human-readable message indicating details about last transition. + // +optional + Message string `json:"message,omitempty" description:"human-readable message indicating details about last transition"` + + // LastHeartbeatTime is the last time we got an update on a given condition + // +optional + LastHeartbeatTime *metav1.Time `json:"lastHeartbeatTime,omitempty" description:"last time we got an update on a given condition"` + + // LastTransitionTime is the last time the condition transit from one status to another + // +optional + LastTransitionTime *metav1.Time `json:"lastTransitionTime,omitempty" description:"last time the condition transit from one status to another" hash:"ignore"` +} + +// Equals returns true if a SubscriptionCondition equals the one given, false otherwise. +// Equality is determined by the equality of the type, status, reason, and message fields ONLY. +func (s SubscriptionCondition) Equals(condition SubscriptionCondition) bool { + return s.Type == condition.Type && s.Status == condition.Status && s.Reason == condition.Reason && s.Message == condition.Message +} + +type SubscriptionStatus struct { + // CurrentCSV is the CSV the Subscription is progressing to. + // +optional + CurrentCSV string `json:"currentCSV,omitempty"` + + // InstalledCSV is the CSV currently installed by the Subscription. + // +optional + InstalledCSV string `json:"installedCSV,omitempty"` + + // Install is a reference to the latest InstallPlan generated for the Subscription. + // DEPRECATED: InstallPlanRef + // +optional + Install *InstallPlanReference `json:"installplan,omitempty"` + + // State represents the current state of the Subscription + // +optional + State SubscriptionState `json:"state,omitempty"` + + // Reason is the reason the Subscription was transitioned to its current state. + // +optional + Reason ConditionReason `json:"reason,omitempty"` + + // InstallPlanRef is a reference to the latest InstallPlan that contains the Subscription's current CSV. + // +optional + InstallPlanRef *corev1.ObjectReference `json:"installPlanRef,omitempty"` + + // CatalogHealth contains the Subscription's view of its relevant CatalogSources' status. + // It is used to determine SubscriptionStatusConditions related to CatalogSources. + // +optional + CatalogHealth []SubscriptionCatalogHealth `json:"catalogHealth,omitempty"` + + // Conditions is a list of the latest available observations about a Subscription's current state. + // +optional + Conditions []SubscriptionCondition `json:"conditions,omitempty" hash:"set"` + + // LastUpdated represents the last time that the Subscription status was updated. + LastUpdated metav1.Time `json:"lastUpdated"` +} + +// GetCondition returns the SubscriptionCondition of the given type if it exists in the SubscriptionStatus' Conditions. +// Returns a condition of the given type with a ConditionStatus of "Unknown" if not found. +func (s SubscriptionStatus) GetCondition(conditionType SubscriptionConditionType) SubscriptionCondition { + for _, cond := range s.Conditions { + if cond.Type == conditionType { + return cond + } + } + + return SubscriptionCondition{ + Type: conditionType, + Status: corev1.ConditionUnknown, + } +} + +// SetCondition sets the given SubscriptionCondition in the SubscriptionStatus' Conditions. +func (s *SubscriptionStatus) SetCondition(condition SubscriptionCondition) { + for i, cond := range s.Conditions { + if cond.Type == condition.Type { + s.Conditions[i] = condition + return + } + } + + s.Conditions = append(s.Conditions, condition) +} + +// RemoveConditions removes any conditions of the given types from the SubscriptionStatus' Conditions. +func (s *SubscriptionStatus) RemoveConditions(remove ...SubscriptionConditionType) { + exclusions := map[SubscriptionConditionType]struct{}{} + for _, r := range remove { + exclusions[r] = struct{}{} + } + + var filtered []SubscriptionCondition + for _, cond := range s.Conditions { + if _, ok := exclusions[cond.Type]; ok { + // Skip excluded condition types + continue + } + filtered = append(filtered, cond) + } + + s.Conditions = filtered +} + +type InstallPlanReference struct { + APIVersion string `json:"apiVersion"` + Kind string `json:"kind"` + Name string `json:"name"` + UID types.UID `json:"uuid"` +} + +// SubscriptionCatalogHealth describes the health of a CatalogSource the Subscription knows about. +type SubscriptionCatalogHealth struct { + // CatalogSourceRef is a reference to a CatalogSource. + CatalogSourceRef *corev1.ObjectReference `json:"catalogSourceRef"` + + // LastUpdated represents the last time that the CatalogSourceHealth changed + LastUpdated *metav1.Time `json:"lastUpdated"` + + // Healthy is true if the CatalogSource is healthy; false otherwise. + Healthy bool `json:"healthy"` +} + +// Equals returns true if a SubscriptionCatalogHealth equals the one given, false otherwise. +// Equality is based SOLEY on health and UID. +func (s SubscriptionCatalogHealth) Equals(health SubscriptionCatalogHealth) bool { + return s.Healthy == health.Healthy && s.CatalogSourceRef.UID == health.CatalogSourceRef.UID +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// Subscription keeps operators up to date by tracking changes to Catalogs. +type Subscription struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + + Spec *SubscriptionSpec `json:"spec"` + Status SubscriptionStatus `json:"status"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// SubscriptionList is a list of Subscription resources. +type SubscriptionList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Subscription `json:"items"` +} + +// GetInstallPlanApproval gets the configured install plan approval or the default +func (s *Subscription) GetInstallPlanApproval() Approval { + if s.Spec.InstallPlanApproval == ApprovalManual { + return ApprovalManual + } + return ApprovalAutomatic +} + +// NewInstallPlanReference returns an InstallPlanReference for the given ObjectReference. +func NewInstallPlanReference(ref *corev1.ObjectReference) *InstallPlanReference { + return &InstallPlanReference{ + APIVersion: ref.APIVersion, + Kind: ref.Kind, + Name: ref.Name, + UID: ref.UID, + } +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/types_test.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/types_test.go new file mode 100644 index 0000000000..52fe622a5c --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/types_test.go @@ -0,0 +1,104 @@ +package v1alpha1 + +import ( + "sort" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestGetAllCRDDescriptions(t *testing.T) { + var table = []struct { + owned []string + required []string + expected []string + }{ + {nil, nil, nil}, + {[]string{}, []string{}, []string{}}, + {[]string{"owned"}, []string{}, []string{"owned"}}, + {[]string{}, []string{"required"}, []string{"required"}}, + {[]string{"owned"}, []string{"required"}, []string{"owned", "required"}}, + {[]string{"first", "second"}, []string{"first", "second"}, []string{"first", "second"}}, + {[]string{"first", "second", "third"}, []string{"second", "third", "fourth"}, []string{"first", "second", "third", "fourth"}}, + } + + for _, tt := range table { + // Build a list of owned CRDDescription used in the CSV. + ownedDescriptions := make([]CRDDescription, 0) + for _, crdName := range tt.owned { + ownedDescriptions = append(ownedDescriptions, CRDDescription{ + Name: crdName, + }) + } + + // Build a list of owned CRDDescription used in the CSV. + requiredDescriptions := make([]CRDDescription, 0) + for _, crdName := range tt.required { + requiredDescriptions = append(requiredDescriptions, CRDDescription{ + Name: crdName, + }) + } + + // Build a list of expected CRDDescriptions. + expectedDescriptions := make([]CRDDescription, 0) + sort.StringSlice(tt.expected).Sort() + for _, expectedName := range tt.expected { + expectedDescriptions = append(expectedDescriptions, CRDDescription{ + Name: expectedName, + }) + } + + // Create a blank CSV with the owned descriptions. + csv := ClusterServiceVersion{ + Spec: ClusterServiceVersionSpec{ + CustomResourceDefinitions: CustomResourceDefinitions{ + Owned: ownedDescriptions, + Required: requiredDescriptions, + }, + }, + } + + // Call GetAllCRDDescriptions and ensure the result is as expected. + require.Equal(t, expectedDescriptions, csv.GetAllCRDDescriptions()) + } +} + +func TestOwnsCRD(t *testing.T) { + var table = []struct { + ownedCRDNames []string + crdName string + expected bool + }{ + {nil, "", false}, + {nil, "querty", false}, + {[]string{}, "", false}, + {[]string{}, "querty", false}, + {[]string{"owned"}, "owned", true}, + {[]string{"owned"}, "notOwned", false}, + {[]string{"first", "second"}, "first", true}, + {[]string{"first", "second"}, "second", true}, + {[]string{"first", "second"}, "third", false}, + } + + for _, tt := range table { + // Build a list of CRDDescription used in the CSV. + var ownedDescriptions []CRDDescription + for _, crdName := range tt.ownedCRDNames { + ownedDescriptions = append(ownedDescriptions, CRDDescription{ + Name: crdName, + }) + } + + // Create a blank CSV with the owned descriptions. + csv := ClusterServiceVersion{ + Spec: ClusterServiceVersionSpec{ + CustomResourceDefinitions: CustomResourceDefinitions{ + Owned: ownedDescriptions, + }, + }, + } + + // Call OwnsCRD and ensure the result is as expected. + require.Equal(t, tt.expected, csv.OwnsCRD(tt.crdName)) + } +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/zz_generated.conversion.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/zz_generated.conversion.go new file mode 100644 index 0000000000..179cd4c99c --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/zz_generated.conversion.go @@ -0,0 +1,1603 @@ +// +build !ignore_autogenerated + +/* +Copyright 2019 Red Hat, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by conversion-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + json "encoding/json" + unsafe "unsafe" + + operators "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators" + corev1 "k8s.io/api/core/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + conversion "k8s.io/apimachinery/pkg/conversion" + runtime "k8s.io/apimachinery/pkg/runtime" + types "k8s.io/apimachinery/pkg/types" +) + +func init() { + localSchemeBuilder.Register(RegisterConversions) +} + +// RegisterConversions adds conversion functions to the given scheme. +// Public to allow building arbitrary schemes. +func RegisterConversions(s *runtime.Scheme) error { + if err := s.AddGeneratedConversionFunc((*APIResourceReference)(nil), (*operators.APIResourceReference)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_APIResourceReference_To_operators_APIResourceReference(a.(*APIResourceReference), b.(*operators.APIResourceReference), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.APIResourceReference)(nil), (*APIResourceReference)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_APIResourceReference_To_v1alpha1_APIResourceReference(a.(*operators.APIResourceReference), b.(*APIResourceReference), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*APIServiceDefinitions)(nil), (*operators.APIServiceDefinitions)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_APIServiceDefinitions_To_operators_APIServiceDefinitions(a.(*APIServiceDefinitions), b.(*operators.APIServiceDefinitions), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.APIServiceDefinitions)(nil), (*APIServiceDefinitions)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_APIServiceDefinitions_To_v1alpha1_APIServiceDefinitions(a.(*operators.APIServiceDefinitions), b.(*APIServiceDefinitions), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*APIServiceDescription)(nil), (*operators.APIServiceDescription)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_APIServiceDescription_To_operators_APIServiceDescription(a.(*APIServiceDescription), b.(*operators.APIServiceDescription), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.APIServiceDescription)(nil), (*APIServiceDescription)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_APIServiceDescription_To_v1alpha1_APIServiceDescription(a.(*operators.APIServiceDescription), b.(*APIServiceDescription), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*ActionDescriptor)(nil), (*operators.ActionDescriptor)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_ActionDescriptor_To_operators_ActionDescriptor(a.(*ActionDescriptor), b.(*operators.ActionDescriptor), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.ActionDescriptor)(nil), (*ActionDescriptor)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_ActionDescriptor_To_v1alpha1_ActionDescriptor(a.(*operators.ActionDescriptor), b.(*ActionDescriptor), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*AppLink)(nil), (*operators.AppLink)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_AppLink_To_operators_AppLink(a.(*AppLink), b.(*operators.AppLink), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.AppLink)(nil), (*AppLink)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_AppLink_To_v1alpha1_AppLink(a.(*operators.AppLink), b.(*AppLink), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*CRDDescription)(nil), (*operators.CRDDescription)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_CRDDescription_To_operators_CRDDescription(a.(*CRDDescription), b.(*operators.CRDDescription), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.CRDDescription)(nil), (*CRDDescription)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_CRDDescription_To_v1alpha1_CRDDescription(a.(*operators.CRDDescription), b.(*CRDDescription), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*CatalogSource)(nil), (*operators.CatalogSource)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_CatalogSource_To_operators_CatalogSource(a.(*CatalogSource), b.(*operators.CatalogSource), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.CatalogSource)(nil), (*CatalogSource)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_CatalogSource_To_v1alpha1_CatalogSource(a.(*operators.CatalogSource), b.(*CatalogSource), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*CatalogSourceList)(nil), (*operators.CatalogSourceList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_CatalogSourceList_To_operators_CatalogSourceList(a.(*CatalogSourceList), b.(*operators.CatalogSourceList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.CatalogSourceList)(nil), (*CatalogSourceList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_CatalogSourceList_To_v1alpha1_CatalogSourceList(a.(*operators.CatalogSourceList), b.(*CatalogSourceList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*CatalogSourceSpec)(nil), (*operators.CatalogSourceSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_CatalogSourceSpec_To_operators_CatalogSourceSpec(a.(*CatalogSourceSpec), b.(*operators.CatalogSourceSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.CatalogSourceSpec)(nil), (*CatalogSourceSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_CatalogSourceSpec_To_v1alpha1_CatalogSourceSpec(a.(*operators.CatalogSourceSpec), b.(*CatalogSourceSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*CatalogSourceStatus)(nil), (*operators.CatalogSourceStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_CatalogSourceStatus_To_operators_CatalogSourceStatus(a.(*CatalogSourceStatus), b.(*operators.CatalogSourceStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.CatalogSourceStatus)(nil), (*CatalogSourceStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_CatalogSourceStatus_To_v1alpha1_CatalogSourceStatus(a.(*operators.CatalogSourceStatus), b.(*CatalogSourceStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*ClusterServiceVersion)(nil), (*operators.ClusterServiceVersion)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_ClusterServiceVersion_To_operators_ClusterServiceVersion(a.(*ClusterServiceVersion), b.(*operators.ClusterServiceVersion), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.ClusterServiceVersion)(nil), (*ClusterServiceVersion)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_ClusterServiceVersion_To_v1alpha1_ClusterServiceVersion(a.(*operators.ClusterServiceVersion), b.(*ClusterServiceVersion), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*ClusterServiceVersionCondition)(nil), (*operators.ClusterServiceVersionCondition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_ClusterServiceVersionCondition_To_operators_ClusterServiceVersionCondition(a.(*ClusterServiceVersionCondition), b.(*operators.ClusterServiceVersionCondition), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.ClusterServiceVersionCondition)(nil), (*ClusterServiceVersionCondition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_ClusterServiceVersionCondition_To_v1alpha1_ClusterServiceVersionCondition(a.(*operators.ClusterServiceVersionCondition), b.(*ClusterServiceVersionCondition), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*ClusterServiceVersionList)(nil), (*operators.ClusterServiceVersionList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_ClusterServiceVersionList_To_operators_ClusterServiceVersionList(a.(*ClusterServiceVersionList), b.(*operators.ClusterServiceVersionList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.ClusterServiceVersionList)(nil), (*ClusterServiceVersionList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_ClusterServiceVersionList_To_v1alpha1_ClusterServiceVersionList(a.(*operators.ClusterServiceVersionList), b.(*ClusterServiceVersionList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*ClusterServiceVersionSpec)(nil), (*operators.ClusterServiceVersionSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_ClusterServiceVersionSpec_To_operators_ClusterServiceVersionSpec(a.(*ClusterServiceVersionSpec), b.(*operators.ClusterServiceVersionSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.ClusterServiceVersionSpec)(nil), (*ClusterServiceVersionSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_ClusterServiceVersionSpec_To_v1alpha1_ClusterServiceVersionSpec(a.(*operators.ClusterServiceVersionSpec), b.(*ClusterServiceVersionSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*ClusterServiceVersionStatus)(nil), (*operators.ClusterServiceVersionStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_ClusterServiceVersionStatus_To_operators_ClusterServiceVersionStatus(a.(*ClusterServiceVersionStatus), b.(*operators.ClusterServiceVersionStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.ClusterServiceVersionStatus)(nil), (*ClusterServiceVersionStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_ClusterServiceVersionStatus_To_v1alpha1_ClusterServiceVersionStatus(a.(*operators.ClusterServiceVersionStatus), b.(*ClusterServiceVersionStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*ConfigMapResourceReference)(nil), (*operators.ConfigMapResourceReference)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_ConfigMapResourceReference_To_operators_ConfigMapResourceReference(a.(*ConfigMapResourceReference), b.(*operators.ConfigMapResourceReference), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.ConfigMapResourceReference)(nil), (*ConfigMapResourceReference)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_ConfigMapResourceReference_To_v1alpha1_ConfigMapResourceReference(a.(*operators.ConfigMapResourceReference), b.(*ConfigMapResourceReference), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*CustomResourceDefinitions)(nil), (*operators.CustomResourceDefinitions)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_CustomResourceDefinitions_To_operators_CustomResourceDefinitions(a.(*CustomResourceDefinitions), b.(*operators.CustomResourceDefinitions), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.CustomResourceDefinitions)(nil), (*CustomResourceDefinitions)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_CustomResourceDefinitions_To_v1alpha1_CustomResourceDefinitions(a.(*operators.CustomResourceDefinitions), b.(*CustomResourceDefinitions), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*DependentStatus)(nil), (*operators.DependentStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_DependentStatus_To_operators_DependentStatus(a.(*DependentStatus), b.(*operators.DependentStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.DependentStatus)(nil), (*DependentStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_DependentStatus_To_v1alpha1_DependentStatus(a.(*operators.DependentStatus), b.(*DependentStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*Icon)(nil), (*operators.Icon)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_Icon_To_operators_Icon(a.(*Icon), b.(*operators.Icon), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.Icon)(nil), (*Icon)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_Icon_To_v1alpha1_Icon(a.(*operators.Icon), b.(*Icon), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*InstallMode)(nil), (*operators.InstallMode)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_InstallMode_To_operators_InstallMode(a.(*InstallMode), b.(*operators.InstallMode), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.InstallMode)(nil), (*InstallMode)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_InstallMode_To_v1alpha1_InstallMode(a.(*operators.InstallMode), b.(*InstallMode), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*InstallPlan)(nil), (*operators.InstallPlan)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_InstallPlan_To_operators_InstallPlan(a.(*InstallPlan), b.(*operators.InstallPlan), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.InstallPlan)(nil), (*InstallPlan)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_InstallPlan_To_v1alpha1_InstallPlan(a.(*operators.InstallPlan), b.(*InstallPlan), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*InstallPlanCondition)(nil), (*operators.InstallPlanCondition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_InstallPlanCondition_To_operators_InstallPlanCondition(a.(*InstallPlanCondition), b.(*operators.InstallPlanCondition), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.InstallPlanCondition)(nil), (*InstallPlanCondition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_InstallPlanCondition_To_v1alpha1_InstallPlanCondition(a.(*operators.InstallPlanCondition), b.(*InstallPlanCondition), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*InstallPlanList)(nil), (*operators.InstallPlanList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_InstallPlanList_To_operators_InstallPlanList(a.(*InstallPlanList), b.(*operators.InstallPlanList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.InstallPlanList)(nil), (*InstallPlanList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_InstallPlanList_To_v1alpha1_InstallPlanList(a.(*operators.InstallPlanList), b.(*InstallPlanList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*InstallPlanReference)(nil), (*operators.InstallPlanReference)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_InstallPlanReference_To_operators_InstallPlanReference(a.(*InstallPlanReference), b.(*operators.InstallPlanReference), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.InstallPlanReference)(nil), (*InstallPlanReference)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_InstallPlanReference_To_v1alpha1_InstallPlanReference(a.(*operators.InstallPlanReference), b.(*InstallPlanReference), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*InstallPlanSpec)(nil), (*operators.InstallPlanSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_InstallPlanSpec_To_operators_InstallPlanSpec(a.(*InstallPlanSpec), b.(*operators.InstallPlanSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.InstallPlanSpec)(nil), (*InstallPlanSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_InstallPlanSpec_To_v1alpha1_InstallPlanSpec(a.(*operators.InstallPlanSpec), b.(*InstallPlanSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*InstallPlanStatus)(nil), (*operators.InstallPlanStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_InstallPlanStatus_To_operators_InstallPlanStatus(a.(*InstallPlanStatus), b.(*operators.InstallPlanStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.InstallPlanStatus)(nil), (*InstallPlanStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_InstallPlanStatus_To_v1alpha1_InstallPlanStatus(a.(*operators.InstallPlanStatus), b.(*InstallPlanStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*Maintainer)(nil), (*operators.Maintainer)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_Maintainer_To_operators_Maintainer(a.(*Maintainer), b.(*operators.Maintainer), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.Maintainer)(nil), (*Maintainer)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_Maintainer_To_v1alpha1_Maintainer(a.(*operators.Maintainer), b.(*Maintainer), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*NamedInstallStrategy)(nil), (*operators.NamedInstallStrategy)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NamedInstallStrategy_To_operators_NamedInstallStrategy(a.(*NamedInstallStrategy), b.(*operators.NamedInstallStrategy), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.NamedInstallStrategy)(nil), (*NamedInstallStrategy)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_NamedInstallStrategy_To_v1alpha1_NamedInstallStrategy(a.(*operators.NamedInstallStrategy), b.(*NamedInstallStrategy), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*RegistryServiceStatus)(nil), (*operators.RegistryServiceStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_RegistryServiceStatus_To_operators_RegistryServiceStatus(a.(*RegistryServiceStatus), b.(*operators.RegistryServiceStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.RegistryServiceStatus)(nil), (*RegistryServiceStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_RegistryServiceStatus_To_v1alpha1_RegistryServiceStatus(a.(*operators.RegistryServiceStatus), b.(*RegistryServiceStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*RequirementStatus)(nil), (*operators.RequirementStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_RequirementStatus_To_operators_RequirementStatus(a.(*RequirementStatus), b.(*operators.RequirementStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.RequirementStatus)(nil), (*RequirementStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_RequirementStatus_To_v1alpha1_RequirementStatus(a.(*operators.RequirementStatus), b.(*RequirementStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*SpecDescriptor)(nil), (*operators.SpecDescriptor)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_SpecDescriptor_To_operators_SpecDescriptor(a.(*SpecDescriptor), b.(*operators.SpecDescriptor), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.SpecDescriptor)(nil), (*SpecDescriptor)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_SpecDescriptor_To_v1alpha1_SpecDescriptor(a.(*operators.SpecDescriptor), b.(*SpecDescriptor), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*StatusDescriptor)(nil), (*operators.StatusDescriptor)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_StatusDescriptor_To_operators_StatusDescriptor(a.(*StatusDescriptor), b.(*operators.StatusDescriptor), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.StatusDescriptor)(nil), (*StatusDescriptor)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_StatusDescriptor_To_v1alpha1_StatusDescriptor(a.(*operators.StatusDescriptor), b.(*StatusDescriptor), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*Step)(nil), (*operators.Step)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_Step_To_operators_Step(a.(*Step), b.(*operators.Step), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.Step)(nil), (*Step)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_Step_To_v1alpha1_Step(a.(*operators.Step), b.(*Step), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*StepResource)(nil), (*operators.StepResource)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_StepResource_To_operators_StepResource(a.(*StepResource), b.(*operators.StepResource), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.StepResource)(nil), (*StepResource)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_StepResource_To_v1alpha1_StepResource(a.(*operators.StepResource), b.(*StepResource), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*Subscription)(nil), (*operators.Subscription)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_Subscription_To_operators_Subscription(a.(*Subscription), b.(*operators.Subscription), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.Subscription)(nil), (*Subscription)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_Subscription_To_v1alpha1_Subscription(a.(*operators.Subscription), b.(*Subscription), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*SubscriptionCatalogHealth)(nil), (*operators.SubscriptionCatalogHealth)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_SubscriptionCatalogHealth_To_operators_SubscriptionCatalogHealth(a.(*SubscriptionCatalogHealth), b.(*operators.SubscriptionCatalogHealth), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.SubscriptionCatalogHealth)(nil), (*SubscriptionCatalogHealth)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_SubscriptionCatalogHealth_To_v1alpha1_SubscriptionCatalogHealth(a.(*operators.SubscriptionCatalogHealth), b.(*SubscriptionCatalogHealth), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*SubscriptionCondition)(nil), (*operators.SubscriptionCondition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_SubscriptionCondition_To_operators_SubscriptionCondition(a.(*SubscriptionCondition), b.(*operators.SubscriptionCondition), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.SubscriptionCondition)(nil), (*SubscriptionCondition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_SubscriptionCondition_To_v1alpha1_SubscriptionCondition(a.(*operators.SubscriptionCondition), b.(*SubscriptionCondition), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*SubscriptionList)(nil), (*operators.SubscriptionList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_SubscriptionList_To_operators_SubscriptionList(a.(*SubscriptionList), b.(*operators.SubscriptionList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.SubscriptionList)(nil), (*SubscriptionList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_SubscriptionList_To_v1alpha1_SubscriptionList(a.(*operators.SubscriptionList), b.(*SubscriptionList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*SubscriptionSpec)(nil), (*operators.SubscriptionSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_SubscriptionSpec_To_operators_SubscriptionSpec(a.(*SubscriptionSpec), b.(*operators.SubscriptionSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.SubscriptionSpec)(nil), (*SubscriptionSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_SubscriptionSpec_To_v1alpha1_SubscriptionSpec(a.(*operators.SubscriptionSpec), b.(*SubscriptionSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*SubscriptionStatus)(nil), (*operators.SubscriptionStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_SubscriptionStatus_To_operators_SubscriptionStatus(a.(*SubscriptionStatus), b.(*operators.SubscriptionStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.SubscriptionStatus)(nil), (*SubscriptionStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_SubscriptionStatus_To_v1alpha1_SubscriptionStatus(a.(*operators.SubscriptionStatus), b.(*SubscriptionStatus), scope) + }); err != nil { + return err + } + return nil +} + +func autoConvert_v1alpha1_APIResourceReference_To_operators_APIResourceReference(in *APIResourceReference, out *operators.APIResourceReference, s conversion.Scope) error { + out.Name = in.Name + out.Kind = in.Kind + out.Version = in.Version + return nil +} + +// Convert_v1alpha1_APIResourceReference_To_operators_APIResourceReference is an autogenerated conversion function. +func Convert_v1alpha1_APIResourceReference_To_operators_APIResourceReference(in *APIResourceReference, out *operators.APIResourceReference, s conversion.Scope) error { + return autoConvert_v1alpha1_APIResourceReference_To_operators_APIResourceReference(in, out, s) +} + +func autoConvert_operators_APIResourceReference_To_v1alpha1_APIResourceReference(in *operators.APIResourceReference, out *APIResourceReference, s conversion.Scope) error { + out.Name = in.Name + out.Kind = in.Kind + out.Version = in.Version + return nil +} + +// Convert_operators_APIResourceReference_To_v1alpha1_APIResourceReference is an autogenerated conversion function. +func Convert_operators_APIResourceReference_To_v1alpha1_APIResourceReference(in *operators.APIResourceReference, out *APIResourceReference, s conversion.Scope) error { + return autoConvert_operators_APIResourceReference_To_v1alpha1_APIResourceReference(in, out, s) +} + +func autoConvert_v1alpha1_APIServiceDefinitions_To_operators_APIServiceDefinitions(in *APIServiceDefinitions, out *operators.APIServiceDefinitions, s conversion.Scope) error { + out.Owned = *(*[]operators.APIServiceDescription)(unsafe.Pointer(&in.Owned)) + out.Required = *(*[]operators.APIServiceDescription)(unsafe.Pointer(&in.Required)) + return nil +} + +// Convert_v1alpha1_APIServiceDefinitions_To_operators_APIServiceDefinitions is an autogenerated conversion function. +func Convert_v1alpha1_APIServiceDefinitions_To_operators_APIServiceDefinitions(in *APIServiceDefinitions, out *operators.APIServiceDefinitions, s conversion.Scope) error { + return autoConvert_v1alpha1_APIServiceDefinitions_To_operators_APIServiceDefinitions(in, out, s) +} + +func autoConvert_operators_APIServiceDefinitions_To_v1alpha1_APIServiceDefinitions(in *operators.APIServiceDefinitions, out *APIServiceDefinitions, s conversion.Scope) error { + out.Owned = *(*[]APIServiceDescription)(unsafe.Pointer(&in.Owned)) + out.Required = *(*[]APIServiceDescription)(unsafe.Pointer(&in.Required)) + return nil +} + +// Convert_operators_APIServiceDefinitions_To_v1alpha1_APIServiceDefinitions is an autogenerated conversion function. +func Convert_operators_APIServiceDefinitions_To_v1alpha1_APIServiceDefinitions(in *operators.APIServiceDefinitions, out *APIServiceDefinitions, s conversion.Scope) error { + return autoConvert_operators_APIServiceDefinitions_To_v1alpha1_APIServiceDefinitions(in, out, s) +} + +func autoConvert_v1alpha1_APIServiceDescription_To_operators_APIServiceDescription(in *APIServiceDescription, out *operators.APIServiceDescription, s conversion.Scope) error { + out.Name = in.Name + out.Group = in.Group + out.Version = in.Version + out.Kind = in.Kind + out.DeploymentName = in.DeploymentName + out.ContainerPort = in.ContainerPort + out.DisplayName = in.DisplayName + out.Description = in.Description + out.Resources = *(*[]operators.APIResourceReference)(unsafe.Pointer(&in.Resources)) + out.StatusDescriptors = *(*[]operators.StatusDescriptor)(unsafe.Pointer(&in.StatusDescriptors)) + out.SpecDescriptors = *(*[]operators.SpecDescriptor)(unsafe.Pointer(&in.SpecDescriptors)) + out.ActionDescriptor = *(*[]operators.ActionDescriptor)(unsafe.Pointer(&in.ActionDescriptor)) + return nil +} + +// Convert_v1alpha1_APIServiceDescription_To_operators_APIServiceDescription is an autogenerated conversion function. +func Convert_v1alpha1_APIServiceDescription_To_operators_APIServiceDescription(in *APIServiceDescription, out *operators.APIServiceDescription, s conversion.Scope) error { + return autoConvert_v1alpha1_APIServiceDescription_To_operators_APIServiceDescription(in, out, s) +} + +func autoConvert_operators_APIServiceDescription_To_v1alpha1_APIServiceDescription(in *operators.APIServiceDescription, out *APIServiceDescription, s conversion.Scope) error { + out.Name = in.Name + out.Group = in.Group + out.Version = in.Version + out.Kind = in.Kind + out.DeploymentName = in.DeploymentName + out.ContainerPort = in.ContainerPort + out.DisplayName = in.DisplayName + out.Description = in.Description + out.Resources = *(*[]APIResourceReference)(unsafe.Pointer(&in.Resources)) + out.StatusDescriptors = *(*[]StatusDescriptor)(unsafe.Pointer(&in.StatusDescriptors)) + out.SpecDescriptors = *(*[]SpecDescriptor)(unsafe.Pointer(&in.SpecDescriptors)) + out.ActionDescriptor = *(*[]ActionDescriptor)(unsafe.Pointer(&in.ActionDescriptor)) + return nil +} + +// Convert_operators_APIServiceDescription_To_v1alpha1_APIServiceDescription is an autogenerated conversion function. +func Convert_operators_APIServiceDescription_To_v1alpha1_APIServiceDescription(in *operators.APIServiceDescription, out *APIServiceDescription, s conversion.Scope) error { + return autoConvert_operators_APIServiceDescription_To_v1alpha1_APIServiceDescription(in, out, s) +} + +func autoConvert_v1alpha1_ActionDescriptor_To_operators_ActionDescriptor(in *ActionDescriptor, out *operators.ActionDescriptor, s conversion.Scope) error { + out.Path = in.Path + out.DisplayName = in.DisplayName + out.Description = in.Description + out.XDescriptors = *(*[]string)(unsafe.Pointer(&in.XDescriptors)) + out.Value = (*json.RawMessage)(unsafe.Pointer(in.Value)) + return nil +} + +// Convert_v1alpha1_ActionDescriptor_To_operators_ActionDescriptor is an autogenerated conversion function. +func Convert_v1alpha1_ActionDescriptor_To_operators_ActionDescriptor(in *ActionDescriptor, out *operators.ActionDescriptor, s conversion.Scope) error { + return autoConvert_v1alpha1_ActionDescriptor_To_operators_ActionDescriptor(in, out, s) +} + +func autoConvert_operators_ActionDescriptor_To_v1alpha1_ActionDescriptor(in *operators.ActionDescriptor, out *ActionDescriptor, s conversion.Scope) error { + out.Path = in.Path + out.DisplayName = in.DisplayName + out.Description = in.Description + out.XDescriptors = *(*[]string)(unsafe.Pointer(&in.XDescriptors)) + out.Value = (*json.RawMessage)(unsafe.Pointer(in.Value)) + return nil +} + +// Convert_operators_ActionDescriptor_To_v1alpha1_ActionDescriptor is an autogenerated conversion function. +func Convert_operators_ActionDescriptor_To_v1alpha1_ActionDescriptor(in *operators.ActionDescriptor, out *ActionDescriptor, s conversion.Scope) error { + return autoConvert_operators_ActionDescriptor_To_v1alpha1_ActionDescriptor(in, out, s) +} + +func autoConvert_v1alpha1_AppLink_To_operators_AppLink(in *AppLink, out *operators.AppLink, s conversion.Scope) error { + out.Name = in.Name + out.URL = in.URL + return nil +} + +// Convert_v1alpha1_AppLink_To_operators_AppLink is an autogenerated conversion function. +func Convert_v1alpha1_AppLink_To_operators_AppLink(in *AppLink, out *operators.AppLink, s conversion.Scope) error { + return autoConvert_v1alpha1_AppLink_To_operators_AppLink(in, out, s) +} + +func autoConvert_operators_AppLink_To_v1alpha1_AppLink(in *operators.AppLink, out *AppLink, s conversion.Scope) error { + out.Name = in.Name + out.URL = in.URL + return nil +} + +// Convert_operators_AppLink_To_v1alpha1_AppLink is an autogenerated conversion function. +func Convert_operators_AppLink_To_v1alpha1_AppLink(in *operators.AppLink, out *AppLink, s conversion.Scope) error { + return autoConvert_operators_AppLink_To_v1alpha1_AppLink(in, out, s) +} + +func autoConvert_v1alpha1_CRDDescription_To_operators_CRDDescription(in *CRDDescription, out *operators.CRDDescription, s conversion.Scope) error { + out.Name = in.Name + out.Version = in.Version + out.Kind = in.Kind + out.DisplayName = in.DisplayName + out.Description = in.Description + out.Resources = *(*[]operators.APIResourceReference)(unsafe.Pointer(&in.Resources)) + out.StatusDescriptors = *(*[]operators.StatusDescriptor)(unsafe.Pointer(&in.StatusDescriptors)) + out.SpecDescriptors = *(*[]operators.SpecDescriptor)(unsafe.Pointer(&in.SpecDescriptors)) + out.ActionDescriptor = *(*[]operators.ActionDescriptor)(unsafe.Pointer(&in.ActionDescriptor)) + return nil +} + +// Convert_v1alpha1_CRDDescription_To_operators_CRDDescription is an autogenerated conversion function. +func Convert_v1alpha1_CRDDescription_To_operators_CRDDescription(in *CRDDescription, out *operators.CRDDescription, s conversion.Scope) error { + return autoConvert_v1alpha1_CRDDescription_To_operators_CRDDescription(in, out, s) +} + +func autoConvert_operators_CRDDescription_To_v1alpha1_CRDDescription(in *operators.CRDDescription, out *CRDDescription, s conversion.Scope) error { + out.Name = in.Name + out.Version = in.Version + out.Kind = in.Kind + out.DisplayName = in.DisplayName + out.Description = in.Description + out.Resources = *(*[]APIResourceReference)(unsafe.Pointer(&in.Resources)) + out.StatusDescriptors = *(*[]StatusDescriptor)(unsafe.Pointer(&in.StatusDescriptors)) + out.SpecDescriptors = *(*[]SpecDescriptor)(unsafe.Pointer(&in.SpecDescriptors)) + out.ActionDescriptor = *(*[]ActionDescriptor)(unsafe.Pointer(&in.ActionDescriptor)) + return nil +} + +// Convert_operators_CRDDescription_To_v1alpha1_CRDDescription is an autogenerated conversion function. +func Convert_operators_CRDDescription_To_v1alpha1_CRDDescription(in *operators.CRDDescription, out *CRDDescription, s conversion.Scope) error { + return autoConvert_operators_CRDDescription_To_v1alpha1_CRDDescription(in, out, s) +} + +func autoConvert_v1alpha1_CatalogSource_To_operators_CatalogSource(in *CatalogSource, out *operators.CatalogSource, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1alpha1_CatalogSourceSpec_To_operators_CatalogSourceSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1alpha1_CatalogSourceStatus_To_operators_CatalogSourceStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_CatalogSource_To_operators_CatalogSource is an autogenerated conversion function. +func Convert_v1alpha1_CatalogSource_To_operators_CatalogSource(in *CatalogSource, out *operators.CatalogSource, s conversion.Scope) error { + return autoConvert_v1alpha1_CatalogSource_To_operators_CatalogSource(in, out, s) +} + +func autoConvert_operators_CatalogSource_To_v1alpha1_CatalogSource(in *operators.CatalogSource, out *CatalogSource, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_operators_CatalogSourceSpec_To_v1alpha1_CatalogSourceSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_operators_CatalogSourceStatus_To_v1alpha1_CatalogSourceStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_operators_CatalogSource_To_v1alpha1_CatalogSource is an autogenerated conversion function. +func Convert_operators_CatalogSource_To_v1alpha1_CatalogSource(in *operators.CatalogSource, out *CatalogSource, s conversion.Scope) error { + return autoConvert_operators_CatalogSource_To_v1alpha1_CatalogSource(in, out, s) +} + +func autoConvert_v1alpha1_CatalogSourceList_To_operators_CatalogSourceList(in *CatalogSourceList, out *operators.CatalogSourceList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]operators.CatalogSource)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_CatalogSourceList_To_operators_CatalogSourceList is an autogenerated conversion function. +func Convert_v1alpha1_CatalogSourceList_To_operators_CatalogSourceList(in *CatalogSourceList, out *operators.CatalogSourceList, s conversion.Scope) error { + return autoConvert_v1alpha1_CatalogSourceList_To_operators_CatalogSourceList(in, out, s) +} + +func autoConvert_operators_CatalogSourceList_To_v1alpha1_CatalogSourceList(in *operators.CatalogSourceList, out *CatalogSourceList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]CatalogSource)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_operators_CatalogSourceList_To_v1alpha1_CatalogSourceList is an autogenerated conversion function. +func Convert_operators_CatalogSourceList_To_v1alpha1_CatalogSourceList(in *operators.CatalogSourceList, out *CatalogSourceList, s conversion.Scope) error { + return autoConvert_operators_CatalogSourceList_To_v1alpha1_CatalogSourceList(in, out, s) +} + +func autoConvert_v1alpha1_CatalogSourceSpec_To_operators_CatalogSourceSpec(in *CatalogSourceSpec, out *operators.CatalogSourceSpec, s conversion.Scope) error { + out.SourceType = operators.SourceType(in.SourceType) + out.ConfigMap = in.ConfigMap + out.Address = in.Address + out.Image = in.Image + out.Secrets = *(*[]string)(unsafe.Pointer(&in.Secrets)) + out.DisplayName = in.DisplayName + out.Description = in.Description + out.Publisher = in.Publisher + if err := Convert_v1alpha1_Icon_To_operators_Icon(&in.Icon, &out.Icon, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_CatalogSourceSpec_To_operators_CatalogSourceSpec is an autogenerated conversion function. +func Convert_v1alpha1_CatalogSourceSpec_To_operators_CatalogSourceSpec(in *CatalogSourceSpec, out *operators.CatalogSourceSpec, s conversion.Scope) error { + return autoConvert_v1alpha1_CatalogSourceSpec_To_operators_CatalogSourceSpec(in, out, s) +} + +func autoConvert_operators_CatalogSourceSpec_To_v1alpha1_CatalogSourceSpec(in *operators.CatalogSourceSpec, out *CatalogSourceSpec, s conversion.Scope) error { + out.SourceType = SourceType(in.SourceType) + out.ConfigMap = in.ConfigMap + out.Address = in.Address + out.Image = in.Image + out.Secrets = *(*[]string)(unsafe.Pointer(&in.Secrets)) + out.DisplayName = in.DisplayName + out.Description = in.Description + out.Publisher = in.Publisher + if err := Convert_operators_Icon_To_v1alpha1_Icon(&in.Icon, &out.Icon, s); err != nil { + return err + } + return nil +} + +// Convert_operators_CatalogSourceSpec_To_v1alpha1_CatalogSourceSpec is an autogenerated conversion function. +func Convert_operators_CatalogSourceSpec_To_v1alpha1_CatalogSourceSpec(in *operators.CatalogSourceSpec, out *CatalogSourceSpec, s conversion.Scope) error { + return autoConvert_operators_CatalogSourceSpec_To_v1alpha1_CatalogSourceSpec(in, out, s) +} + +func autoConvert_v1alpha1_CatalogSourceStatus_To_operators_CatalogSourceStatus(in *CatalogSourceStatus, out *operators.CatalogSourceStatus, s conversion.Scope) error { + out.ConfigMapResource = (*operators.ConfigMapResourceReference)(unsafe.Pointer(in.ConfigMapResource)) + out.RegistryServiceStatus = (*operators.RegistryServiceStatus)(unsafe.Pointer(in.RegistryServiceStatus)) + out.LastSync = in.LastSync + return nil +} + +// Convert_v1alpha1_CatalogSourceStatus_To_operators_CatalogSourceStatus is an autogenerated conversion function. +func Convert_v1alpha1_CatalogSourceStatus_To_operators_CatalogSourceStatus(in *CatalogSourceStatus, out *operators.CatalogSourceStatus, s conversion.Scope) error { + return autoConvert_v1alpha1_CatalogSourceStatus_To_operators_CatalogSourceStatus(in, out, s) +} + +func autoConvert_operators_CatalogSourceStatus_To_v1alpha1_CatalogSourceStatus(in *operators.CatalogSourceStatus, out *CatalogSourceStatus, s conversion.Scope) error { + out.ConfigMapResource = (*ConfigMapResourceReference)(unsafe.Pointer(in.ConfigMapResource)) + out.RegistryServiceStatus = (*RegistryServiceStatus)(unsafe.Pointer(in.RegistryServiceStatus)) + out.LastSync = in.LastSync + return nil +} + +// Convert_operators_CatalogSourceStatus_To_v1alpha1_CatalogSourceStatus is an autogenerated conversion function. +func Convert_operators_CatalogSourceStatus_To_v1alpha1_CatalogSourceStatus(in *operators.CatalogSourceStatus, out *CatalogSourceStatus, s conversion.Scope) error { + return autoConvert_operators_CatalogSourceStatus_To_v1alpha1_CatalogSourceStatus(in, out, s) +} + +func autoConvert_v1alpha1_ClusterServiceVersion_To_operators_ClusterServiceVersion(in *ClusterServiceVersion, out *operators.ClusterServiceVersion, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1alpha1_ClusterServiceVersionSpec_To_operators_ClusterServiceVersionSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1alpha1_ClusterServiceVersionStatus_To_operators_ClusterServiceVersionStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_ClusterServiceVersion_To_operators_ClusterServiceVersion is an autogenerated conversion function. +func Convert_v1alpha1_ClusterServiceVersion_To_operators_ClusterServiceVersion(in *ClusterServiceVersion, out *operators.ClusterServiceVersion, s conversion.Scope) error { + return autoConvert_v1alpha1_ClusterServiceVersion_To_operators_ClusterServiceVersion(in, out, s) +} + +func autoConvert_operators_ClusterServiceVersion_To_v1alpha1_ClusterServiceVersion(in *operators.ClusterServiceVersion, out *ClusterServiceVersion, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_operators_ClusterServiceVersionSpec_To_v1alpha1_ClusterServiceVersionSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_operators_ClusterServiceVersionStatus_To_v1alpha1_ClusterServiceVersionStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_operators_ClusterServiceVersion_To_v1alpha1_ClusterServiceVersion is an autogenerated conversion function. +func Convert_operators_ClusterServiceVersion_To_v1alpha1_ClusterServiceVersion(in *operators.ClusterServiceVersion, out *ClusterServiceVersion, s conversion.Scope) error { + return autoConvert_operators_ClusterServiceVersion_To_v1alpha1_ClusterServiceVersion(in, out, s) +} + +func autoConvert_v1alpha1_ClusterServiceVersionCondition_To_operators_ClusterServiceVersionCondition(in *ClusterServiceVersionCondition, out *operators.ClusterServiceVersionCondition, s conversion.Scope) error { + out.Phase = operators.ClusterServiceVersionPhase(in.Phase) + out.Message = in.Message + out.Reason = operators.ConditionReason(in.Reason) + out.LastUpdateTime = in.LastUpdateTime + out.LastTransitionTime = in.LastTransitionTime + return nil +} + +// Convert_v1alpha1_ClusterServiceVersionCondition_To_operators_ClusterServiceVersionCondition is an autogenerated conversion function. +func Convert_v1alpha1_ClusterServiceVersionCondition_To_operators_ClusterServiceVersionCondition(in *ClusterServiceVersionCondition, out *operators.ClusterServiceVersionCondition, s conversion.Scope) error { + return autoConvert_v1alpha1_ClusterServiceVersionCondition_To_operators_ClusterServiceVersionCondition(in, out, s) +} + +func autoConvert_operators_ClusterServiceVersionCondition_To_v1alpha1_ClusterServiceVersionCondition(in *operators.ClusterServiceVersionCondition, out *ClusterServiceVersionCondition, s conversion.Scope) error { + out.Phase = ClusterServiceVersionPhase(in.Phase) + out.Message = in.Message + out.Reason = ConditionReason(in.Reason) + out.LastUpdateTime = in.LastUpdateTime + out.LastTransitionTime = in.LastTransitionTime + return nil +} + +// Convert_operators_ClusterServiceVersionCondition_To_v1alpha1_ClusterServiceVersionCondition is an autogenerated conversion function. +func Convert_operators_ClusterServiceVersionCondition_To_v1alpha1_ClusterServiceVersionCondition(in *operators.ClusterServiceVersionCondition, out *ClusterServiceVersionCondition, s conversion.Scope) error { + return autoConvert_operators_ClusterServiceVersionCondition_To_v1alpha1_ClusterServiceVersionCondition(in, out, s) +} + +func autoConvert_v1alpha1_ClusterServiceVersionList_To_operators_ClusterServiceVersionList(in *ClusterServiceVersionList, out *operators.ClusterServiceVersionList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]operators.ClusterServiceVersion)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_ClusterServiceVersionList_To_operators_ClusterServiceVersionList is an autogenerated conversion function. +func Convert_v1alpha1_ClusterServiceVersionList_To_operators_ClusterServiceVersionList(in *ClusterServiceVersionList, out *operators.ClusterServiceVersionList, s conversion.Scope) error { + return autoConvert_v1alpha1_ClusterServiceVersionList_To_operators_ClusterServiceVersionList(in, out, s) +} + +func autoConvert_operators_ClusterServiceVersionList_To_v1alpha1_ClusterServiceVersionList(in *operators.ClusterServiceVersionList, out *ClusterServiceVersionList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]ClusterServiceVersion)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_operators_ClusterServiceVersionList_To_v1alpha1_ClusterServiceVersionList is an autogenerated conversion function. +func Convert_operators_ClusterServiceVersionList_To_v1alpha1_ClusterServiceVersionList(in *operators.ClusterServiceVersionList, out *ClusterServiceVersionList, s conversion.Scope) error { + return autoConvert_operators_ClusterServiceVersionList_To_v1alpha1_ClusterServiceVersionList(in, out, s) +} + +func autoConvert_v1alpha1_ClusterServiceVersionSpec_To_operators_ClusterServiceVersionSpec(in *ClusterServiceVersionSpec, out *operators.ClusterServiceVersionSpec, s conversion.Scope) error { + if err := Convert_v1alpha1_NamedInstallStrategy_To_operators_NamedInstallStrategy(&in.InstallStrategy, &out.InstallStrategy, s); err != nil { + return err + } + out.Version = in.Version + out.Maturity = in.Maturity + if err := Convert_v1alpha1_CustomResourceDefinitions_To_operators_CustomResourceDefinitions(&in.CustomResourceDefinitions, &out.CustomResourceDefinitions, s); err != nil { + return err + } + if err := Convert_v1alpha1_APIServiceDefinitions_To_operators_APIServiceDefinitions(&in.APIServiceDefinitions, &out.APIServiceDefinitions, s); err != nil { + return err + } + out.NativeAPIs = *(*[]v1.GroupVersionKind)(unsafe.Pointer(&in.NativeAPIs)) + out.MinKubeVersion = in.MinKubeVersion + out.DisplayName = in.DisplayName + out.Description = in.Description + out.Keywords = *(*[]string)(unsafe.Pointer(&in.Keywords)) + out.Maintainers = *(*[]operators.Maintainer)(unsafe.Pointer(&in.Maintainers)) + if err := Convert_v1alpha1_AppLink_To_operators_AppLink(&in.Provider, &out.Provider, s); err != nil { + return err + } + out.Links = *(*[]operators.AppLink)(unsafe.Pointer(&in.Links)) + out.Icon = *(*[]operators.Icon)(unsafe.Pointer(&in.Icon)) + out.InstallModes = *(*[]operators.InstallMode)(unsafe.Pointer(&in.InstallModes)) + out.Replaces = in.Replaces + out.Labels = *(*map[string]string)(unsafe.Pointer(&in.Labels)) + out.Annotations = *(*map[string]string)(unsafe.Pointer(&in.Annotations)) + out.Selector = (*v1.LabelSelector)(unsafe.Pointer(in.Selector)) + return nil +} + +// Convert_v1alpha1_ClusterServiceVersionSpec_To_operators_ClusterServiceVersionSpec is an autogenerated conversion function. +func Convert_v1alpha1_ClusterServiceVersionSpec_To_operators_ClusterServiceVersionSpec(in *ClusterServiceVersionSpec, out *operators.ClusterServiceVersionSpec, s conversion.Scope) error { + return autoConvert_v1alpha1_ClusterServiceVersionSpec_To_operators_ClusterServiceVersionSpec(in, out, s) +} + +func autoConvert_operators_ClusterServiceVersionSpec_To_v1alpha1_ClusterServiceVersionSpec(in *operators.ClusterServiceVersionSpec, out *ClusterServiceVersionSpec, s conversion.Scope) error { + if err := Convert_operators_NamedInstallStrategy_To_v1alpha1_NamedInstallStrategy(&in.InstallStrategy, &out.InstallStrategy, s); err != nil { + return err + } + out.Version = in.Version + out.Maturity = in.Maturity + if err := Convert_operators_CustomResourceDefinitions_To_v1alpha1_CustomResourceDefinitions(&in.CustomResourceDefinitions, &out.CustomResourceDefinitions, s); err != nil { + return err + } + if err := Convert_operators_APIServiceDefinitions_To_v1alpha1_APIServiceDefinitions(&in.APIServiceDefinitions, &out.APIServiceDefinitions, s); err != nil { + return err + } + out.NativeAPIs = *(*[]v1.GroupVersionKind)(unsafe.Pointer(&in.NativeAPIs)) + out.MinKubeVersion = in.MinKubeVersion + out.DisplayName = in.DisplayName + out.Description = in.Description + out.Keywords = *(*[]string)(unsafe.Pointer(&in.Keywords)) + out.Maintainers = *(*[]Maintainer)(unsafe.Pointer(&in.Maintainers)) + if err := Convert_operators_AppLink_To_v1alpha1_AppLink(&in.Provider, &out.Provider, s); err != nil { + return err + } + out.Links = *(*[]AppLink)(unsafe.Pointer(&in.Links)) + out.Icon = *(*[]Icon)(unsafe.Pointer(&in.Icon)) + out.InstallModes = *(*[]InstallMode)(unsafe.Pointer(&in.InstallModes)) + out.Replaces = in.Replaces + out.Labels = *(*map[string]string)(unsafe.Pointer(&in.Labels)) + out.Annotations = *(*map[string]string)(unsafe.Pointer(&in.Annotations)) + out.Selector = (*v1.LabelSelector)(unsafe.Pointer(in.Selector)) + return nil +} + +// Convert_operators_ClusterServiceVersionSpec_To_v1alpha1_ClusterServiceVersionSpec is an autogenerated conversion function. +func Convert_operators_ClusterServiceVersionSpec_To_v1alpha1_ClusterServiceVersionSpec(in *operators.ClusterServiceVersionSpec, out *ClusterServiceVersionSpec, s conversion.Scope) error { + return autoConvert_operators_ClusterServiceVersionSpec_To_v1alpha1_ClusterServiceVersionSpec(in, out, s) +} + +func autoConvert_v1alpha1_ClusterServiceVersionStatus_To_operators_ClusterServiceVersionStatus(in *ClusterServiceVersionStatus, out *operators.ClusterServiceVersionStatus, s conversion.Scope) error { + out.Phase = operators.ClusterServiceVersionPhase(in.Phase) + out.Message = in.Message + out.Reason = operators.ConditionReason(in.Reason) + out.LastUpdateTime = in.LastUpdateTime + out.LastTransitionTime = in.LastTransitionTime + out.Conditions = *(*[]operators.ClusterServiceVersionCondition)(unsafe.Pointer(&in.Conditions)) + out.RequirementStatus = *(*[]operators.RequirementStatus)(unsafe.Pointer(&in.RequirementStatus)) + out.CertsLastUpdated = in.CertsLastUpdated + out.CertsRotateAt = in.CertsRotateAt + return nil +} + +// Convert_v1alpha1_ClusterServiceVersionStatus_To_operators_ClusterServiceVersionStatus is an autogenerated conversion function. +func Convert_v1alpha1_ClusterServiceVersionStatus_To_operators_ClusterServiceVersionStatus(in *ClusterServiceVersionStatus, out *operators.ClusterServiceVersionStatus, s conversion.Scope) error { + return autoConvert_v1alpha1_ClusterServiceVersionStatus_To_operators_ClusterServiceVersionStatus(in, out, s) +} + +func autoConvert_operators_ClusterServiceVersionStatus_To_v1alpha1_ClusterServiceVersionStatus(in *operators.ClusterServiceVersionStatus, out *ClusterServiceVersionStatus, s conversion.Scope) error { + out.Phase = ClusterServiceVersionPhase(in.Phase) + out.Message = in.Message + out.Reason = ConditionReason(in.Reason) + out.LastUpdateTime = in.LastUpdateTime + out.LastTransitionTime = in.LastTransitionTime + out.Conditions = *(*[]ClusterServiceVersionCondition)(unsafe.Pointer(&in.Conditions)) + out.RequirementStatus = *(*[]RequirementStatus)(unsafe.Pointer(&in.RequirementStatus)) + out.CertsLastUpdated = in.CertsLastUpdated + out.CertsRotateAt = in.CertsRotateAt + return nil +} + +// Convert_operators_ClusterServiceVersionStatus_To_v1alpha1_ClusterServiceVersionStatus is an autogenerated conversion function. +func Convert_operators_ClusterServiceVersionStatus_To_v1alpha1_ClusterServiceVersionStatus(in *operators.ClusterServiceVersionStatus, out *ClusterServiceVersionStatus, s conversion.Scope) error { + return autoConvert_operators_ClusterServiceVersionStatus_To_v1alpha1_ClusterServiceVersionStatus(in, out, s) +} + +func autoConvert_v1alpha1_ConfigMapResourceReference_To_operators_ConfigMapResourceReference(in *ConfigMapResourceReference, out *operators.ConfigMapResourceReference, s conversion.Scope) error { + out.Name = in.Name + out.Namespace = in.Namespace + out.UID = types.UID(in.UID) + out.ResourceVersion = in.ResourceVersion + return nil +} + +// Convert_v1alpha1_ConfigMapResourceReference_To_operators_ConfigMapResourceReference is an autogenerated conversion function. +func Convert_v1alpha1_ConfigMapResourceReference_To_operators_ConfigMapResourceReference(in *ConfigMapResourceReference, out *operators.ConfigMapResourceReference, s conversion.Scope) error { + return autoConvert_v1alpha1_ConfigMapResourceReference_To_operators_ConfigMapResourceReference(in, out, s) +} + +func autoConvert_operators_ConfigMapResourceReference_To_v1alpha1_ConfigMapResourceReference(in *operators.ConfigMapResourceReference, out *ConfigMapResourceReference, s conversion.Scope) error { + out.Name = in.Name + out.Namespace = in.Namespace + out.UID = types.UID(in.UID) + out.ResourceVersion = in.ResourceVersion + return nil +} + +// Convert_operators_ConfigMapResourceReference_To_v1alpha1_ConfigMapResourceReference is an autogenerated conversion function. +func Convert_operators_ConfigMapResourceReference_To_v1alpha1_ConfigMapResourceReference(in *operators.ConfigMapResourceReference, out *ConfigMapResourceReference, s conversion.Scope) error { + return autoConvert_operators_ConfigMapResourceReference_To_v1alpha1_ConfigMapResourceReference(in, out, s) +} + +func autoConvert_v1alpha1_CustomResourceDefinitions_To_operators_CustomResourceDefinitions(in *CustomResourceDefinitions, out *operators.CustomResourceDefinitions, s conversion.Scope) error { + out.Owned = *(*[]operators.CRDDescription)(unsafe.Pointer(&in.Owned)) + out.Required = *(*[]operators.CRDDescription)(unsafe.Pointer(&in.Required)) + return nil +} + +// Convert_v1alpha1_CustomResourceDefinitions_To_operators_CustomResourceDefinitions is an autogenerated conversion function. +func Convert_v1alpha1_CustomResourceDefinitions_To_operators_CustomResourceDefinitions(in *CustomResourceDefinitions, out *operators.CustomResourceDefinitions, s conversion.Scope) error { + return autoConvert_v1alpha1_CustomResourceDefinitions_To_operators_CustomResourceDefinitions(in, out, s) +} + +func autoConvert_operators_CustomResourceDefinitions_To_v1alpha1_CustomResourceDefinitions(in *operators.CustomResourceDefinitions, out *CustomResourceDefinitions, s conversion.Scope) error { + out.Owned = *(*[]CRDDescription)(unsafe.Pointer(&in.Owned)) + out.Required = *(*[]CRDDescription)(unsafe.Pointer(&in.Required)) + return nil +} + +// Convert_operators_CustomResourceDefinitions_To_v1alpha1_CustomResourceDefinitions is an autogenerated conversion function. +func Convert_operators_CustomResourceDefinitions_To_v1alpha1_CustomResourceDefinitions(in *operators.CustomResourceDefinitions, out *CustomResourceDefinitions, s conversion.Scope) error { + return autoConvert_operators_CustomResourceDefinitions_To_v1alpha1_CustomResourceDefinitions(in, out, s) +} + +func autoConvert_v1alpha1_DependentStatus_To_operators_DependentStatus(in *DependentStatus, out *operators.DependentStatus, s conversion.Scope) error { + out.Group = in.Group + out.Version = in.Version + out.Kind = in.Kind + out.Status = operators.StatusReason(in.Status) + out.UUID = in.UUID + out.Message = in.Message + return nil +} + +// Convert_v1alpha1_DependentStatus_To_operators_DependentStatus is an autogenerated conversion function. +func Convert_v1alpha1_DependentStatus_To_operators_DependentStatus(in *DependentStatus, out *operators.DependentStatus, s conversion.Scope) error { + return autoConvert_v1alpha1_DependentStatus_To_operators_DependentStatus(in, out, s) +} + +func autoConvert_operators_DependentStatus_To_v1alpha1_DependentStatus(in *operators.DependentStatus, out *DependentStatus, s conversion.Scope) error { + out.Group = in.Group + out.Version = in.Version + out.Kind = in.Kind + out.Status = StatusReason(in.Status) + out.UUID = in.UUID + out.Message = in.Message + return nil +} + +// Convert_operators_DependentStatus_To_v1alpha1_DependentStatus is an autogenerated conversion function. +func Convert_operators_DependentStatus_To_v1alpha1_DependentStatus(in *operators.DependentStatus, out *DependentStatus, s conversion.Scope) error { + return autoConvert_operators_DependentStatus_To_v1alpha1_DependentStatus(in, out, s) +} + +func autoConvert_v1alpha1_Icon_To_operators_Icon(in *Icon, out *operators.Icon, s conversion.Scope) error { + out.Data = in.Data + out.MediaType = in.MediaType + return nil +} + +// Convert_v1alpha1_Icon_To_operators_Icon is an autogenerated conversion function. +func Convert_v1alpha1_Icon_To_operators_Icon(in *Icon, out *operators.Icon, s conversion.Scope) error { + return autoConvert_v1alpha1_Icon_To_operators_Icon(in, out, s) +} + +func autoConvert_operators_Icon_To_v1alpha1_Icon(in *operators.Icon, out *Icon, s conversion.Scope) error { + out.Data = in.Data + out.MediaType = in.MediaType + return nil +} + +// Convert_operators_Icon_To_v1alpha1_Icon is an autogenerated conversion function. +func Convert_operators_Icon_To_v1alpha1_Icon(in *operators.Icon, out *Icon, s conversion.Scope) error { + return autoConvert_operators_Icon_To_v1alpha1_Icon(in, out, s) +} + +func autoConvert_v1alpha1_InstallMode_To_operators_InstallMode(in *InstallMode, out *operators.InstallMode, s conversion.Scope) error { + out.Type = operators.InstallModeType(in.Type) + out.Supported = in.Supported + return nil +} + +// Convert_v1alpha1_InstallMode_To_operators_InstallMode is an autogenerated conversion function. +func Convert_v1alpha1_InstallMode_To_operators_InstallMode(in *InstallMode, out *operators.InstallMode, s conversion.Scope) error { + return autoConvert_v1alpha1_InstallMode_To_operators_InstallMode(in, out, s) +} + +func autoConvert_operators_InstallMode_To_v1alpha1_InstallMode(in *operators.InstallMode, out *InstallMode, s conversion.Scope) error { + out.Type = InstallModeType(in.Type) + out.Supported = in.Supported + return nil +} + +// Convert_operators_InstallMode_To_v1alpha1_InstallMode is an autogenerated conversion function. +func Convert_operators_InstallMode_To_v1alpha1_InstallMode(in *operators.InstallMode, out *InstallMode, s conversion.Scope) error { + return autoConvert_operators_InstallMode_To_v1alpha1_InstallMode(in, out, s) +} + +func autoConvert_v1alpha1_InstallPlan_To_operators_InstallPlan(in *InstallPlan, out *operators.InstallPlan, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1alpha1_InstallPlanSpec_To_operators_InstallPlanSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1alpha1_InstallPlanStatus_To_operators_InstallPlanStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_InstallPlan_To_operators_InstallPlan is an autogenerated conversion function. +func Convert_v1alpha1_InstallPlan_To_operators_InstallPlan(in *InstallPlan, out *operators.InstallPlan, s conversion.Scope) error { + return autoConvert_v1alpha1_InstallPlan_To_operators_InstallPlan(in, out, s) +} + +func autoConvert_operators_InstallPlan_To_v1alpha1_InstallPlan(in *operators.InstallPlan, out *InstallPlan, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_operators_InstallPlanSpec_To_v1alpha1_InstallPlanSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_operators_InstallPlanStatus_To_v1alpha1_InstallPlanStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_operators_InstallPlan_To_v1alpha1_InstallPlan is an autogenerated conversion function. +func Convert_operators_InstallPlan_To_v1alpha1_InstallPlan(in *operators.InstallPlan, out *InstallPlan, s conversion.Scope) error { + return autoConvert_operators_InstallPlan_To_v1alpha1_InstallPlan(in, out, s) +} + +func autoConvert_v1alpha1_InstallPlanCondition_To_operators_InstallPlanCondition(in *InstallPlanCondition, out *operators.InstallPlanCondition, s conversion.Scope) error { + out.Type = operators.InstallPlanConditionType(in.Type) + out.Status = corev1.ConditionStatus(in.Status) + out.LastUpdateTime = in.LastUpdateTime + out.LastTransitionTime = in.LastTransitionTime + out.Reason = operators.InstallPlanConditionReason(in.Reason) + out.Message = in.Message + return nil +} + +// Convert_v1alpha1_InstallPlanCondition_To_operators_InstallPlanCondition is an autogenerated conversion function. +func Convert_v1alpha1_InstallPlanCondition_To_operators_InstallPlanCondition(in *InstallPlanCondition, out *operators.InstallPlanCondition, s conversion.Scope) error { + return autoConvert_v1alpha1_InstallPlanCondition_To_operators_InstallPlanCondition(in, out, s) +} + +func autoConvert_operators_InstallPlanCondition_To_v1alpha1_InstallPlanCondition(in *operators.InstallPlanCondition, out *InstallPlanCondition, s conversion.Scope) error { + out.Type = InstallPlanConditionType(in.Type) + out.Status = corev1.ConditionStatus(in.Status) + out.LastUpdateTime = in.LastUpdateTime + out.LastTransitionTime = in.LastTransitionTime + out.Reason = InstallPlanConditionReason(in.Reason) + out.Message = in.Message + return nil +} + +// Convert_operators_InstallPlanCondition_To_v1alpha1_InstallPlanCondition is an autogenerated conversion function. +func Convert_operators_InstallPlanCondition_To_v1alpha1_InstallPlanCondition(in *operators.InstallPlanCondition, out *InstallPlanCondition, s conversion.Scope) error { + return autoConvert_operators_InstallPlanCondition_To_v1alpha1_InstallPlanCondition(in, out, s) +} + +func autoConvert_v1alpha1_InstallPlanList_To_operators_InstallPlanList(in *InstallPlanList, out *operators.InstallPlanList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]operators.InstallPlan)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_InstallPlanList_To_operators_InstallPlanList is an autogenerated conversion function. +func Convert_v1alpha1_InstallPlanList_To_operators_InstallPlanList(in *InstallPlanList, out *operators.InstallPlanList, s conversion.Scope) error { + return autoConvert_v1alpha1_InstallPlanList_To_operators_InstallPlanList(in, out, s) +} + +func autoConvert_operators_InstallPlanList_To_v1alpha1_InstallPlanList(in *operators.InstallPlanList, out *InstallPlanList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]InstallPlan)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_operators_InstallPlanList_To_v1alpha1_InstallPlanList is an autogenerated conversion function. +func Convert_operators_InstallPlanList_To_v1alpha1_InstallPlanList(in *operators.InstallPlanList, out *InstallPlanList, s conversion.Scope) error { + return autoConvert_operators_InstallPlanList_To_v1alpha1_InstallPlanList(in, out, s) +} + +func autoConvert_v1alpha1_InstallPlanReference_To_operators_InstallPlanReference(in *InstallPlanReference, out *operators.InstallPlanReference, s conversion.Scope) error { + out.APIVersion = in.APIVersion + out.Kind = in.Kind + out.Name = in.Name + out.UID = types.UID(in.UID) + return nil +} + +// Convert_v1alpha1_InstallPlanReference_To_operators_InstallPlanReference is an autogenerated conversion function. +func Convert_v1alpha1_InstallPlanReference_To_operators_InstallPlanReference(in *InstallPlanReference, out *operators.InstallPlanReference, s conversion.Scope) error { + return autoConvert_v1alpha1_InstallPlanReference_To_operators_InstallPlanReference(in, out, s) +} + +func autoConvert_operators_InstallPlanReference_To_v1alpha1_InstallPlanReference(in *operators.InstallPlanReference, out *InstallPlanReference, s conversion.Scope) error { + out.APIVersion = in.APIVersion + out.Kind = in.Kind + out.Name = in.Name + out.UID = types.UID(in.UID) + return nil +} + +// Convert_operators_InstallPlanReference_To_v1alpha1_InstallPlanReference is an autogenerated conversion function. +func Convert_operators_InstallPlanReference_To_v1alpha1_InstallPlanReference(in *operators.InstallPlanReference, out *InstallPlanReference, s conversion.Scope) error { + return autoConvert_operators_InstallPlanReference_To_v1alpha1_InstallPlanReference(in, out, s) +} + +func autoConvert_v1alpha1_InstallPlanSpec_To_operators_InstallPlanSpec(in *InstallPlanSpec, out *operators.InstallPlanSpec, s conversion.Scope) error { + out.CatalogSource = in.CatalogSource + out.CatalogSourceNamespace = in.CatalogSourceNamespace + out.ClusterServiceVersionNames = *(*[]string)(unsafe.Pointer(&in.ClusterServiceVersionNames)) + out.Approval = operators.Approval(in.Approval) + out.Approved = in.Approved + return nil +} + +// Convert_v1alpha1_InstallPlanSpec_To_operators_InstallPlanSpec is an autogenerated conversion function. +func Convert_v1alpha1_InstallPlanSpec_To_operators_InstallPlanSpec(in *InstallPlanSpec, out *operators.InstallPlanSpec, s conversion.Scope) error { + return autoConvert_v1alpha1_InstallPlanSpec_To_operators_InstallPlanSpec(in, out, s) +} + +func autoConvert_operators_InstallPlanSpec_To_v1alpha1_InstallPlanSpec(in *operators.InstallPlanSpec, out *InstallPlanSpec, s conversion.Scope) error { + out.CatalogSource = in.CatalogSource + out.CatalogSourceNamespace = in.CatalogSourceNamespace + out.ClusterServiceVersionNames = *(*[]string)(unsafe.Pointer(&in.ClusterServiceVersionNames)) + out.Approval = Approval(in.Approval) + out.Approved = in.Approved + return nil +} + +// Convert_operators_InstallPlanSpec_To_v1alpha1_InstallPlanSpec is an autogenerated conversion function. +func Convert_operators_InstallPlanSpec_To_v1alpha1_InstallPlanSpec(in *operators.InstallPlanSpec, out *InstallPlanSpec, s conversion.Scope) error { + return autoConvert_operators_InstallPlanSpec_To_v1alpha1_InstallPlanSpec(in, out, s) +} + +func autoConvert_v1alpha1_InstallPlanStatus_To_operators_InstallPlanStatus(in *InstallPlanStatus, out *operators.InstallPlanStatus, s conversion.Scope) error { + out.Phase = operators.InstallPlanPhase(in.Phase) + out.Conditions = *(*[]operators.InstallPlanCondition)(unsafe.Pointer(&in.Conditions)) + out.CatalogSources = *(*[]string)(unsafe.Pointer(&in.CatalogSources)) + out.Plan = *(*[]*operators.Step)(unsafe.Pointer(&in.Plan)) + return nil +} + +// Convert_v1alpha1_InstallPlanStatus_To_operators_InstallPlanStatus is an autogenerated conversion function. +func Convert_v1alpha1_InstallPlanStatus_To_operators_InstallPlanStatus(in *InstallPlanStatus, out *operators.InstallPlanStatus, s conversion.Scope) error { + return autoConvert_v1alpha1_InstallPlanStatus_To_operators_InstallPlanStatus(in, out, s) +} + +func autoConvert_operators_InstallPlanStatus_To_v1alpha1_InstallPlanStatus(in *operators.InstallPlanStatus, out *InstallPlanStatus, s conversion.Scope) error { + out.Phase = InstallPlanPhase(in.Phase) + out.Conditions = *(*[]InstallPlanCondition)(unsafe.Pointer(&in.Conditions)) + out.CatalogSources = *(*[]string)(unsafe.Pointer(&in.CatalogSources)) + out.Plan = *(*[]*Step)(unsafe.Pointer(&in.Plan)) + return nil +} + +// Convert_operators_InstallPlanStatus_To_v1alpha1_InstallPlanStatus is an autogenerated conversion function. +func Convert_operators_InstallPlanStatus_To_v1alpha1_InstallPlanStatus(in *operators.InstallPlanStatus, out *InstallPlanStatus, s conversion.Scope) error { + return autoConvert_operators_InstallPlanStatus_To_v1alpha1_InstallPlanStatus(in, out, s) +} + +func autoConvert_v1alpha1_Maintainer_To_operators_Maintainer(in *Maintainer, out *operators.Maintainer, s conversion.Scope) error { + out.Name = in.Name + out.Email = in.Email + return nil +} + +// Convert_v1alpha1_Maintainer_To_operators_Maintainer is an autogenerated conversion function. +func Convert_v1alpha1_Maintainer_To_operators_Maintainer(in *Maintainer, out *operators.Maintainer, s conversion.Scope) error { + return autoConvert_v1alpha1_Maintainer_To_operators_Maintainer(in, out, s) +} + +func autoConvert_operators_Maintainer_To_v1alpha1_Maintainer(in *operators.Maintainer, out *Maintainer, s conversion.Scope) error { + out.Name = in.Name + out.Email = in.Email + return nil +} + +// Convert_operators_Maintainer_To_v1alpha1_Maintainer is an autogenerated conversion function. +func Convert_operators_Maintainer_To_v1alpha1_Maintainer(in *operators.Maintainer, out *Maintainer, s conversion.Scope) error { + return autoConvert_operators_Maintainer_To_v1alpha1_Maintainer(in, out, s) +} + +func autoConvert_v1alpha1_NamedInstallStrategy_To_operators_NamedInstallStrategy(in *NamedInstallStrategy, out *operators.NamedInstallStrategy, s conversion.Scope) error { + out.StrategyName = in.StrategyName + out.StrategySpecRaw = *(*json.RawMessage)(unsafe.Pointer(&in.StrategySpecRaw)) + return nil +} + +// Convert_v1alpha1_NamedInstallStrategy_To_operators_NamedInstallStrategy is an autogenerated conversion function. +func Convert_v1alpha1_NamedInstallStrategy_To_operators_NamedInstallStrategy(in *NamedInstallStrategy, out *operators.NamedInstallStrategy, s conversion.Scope) error { + return autoConvert_v1alpha1_NamedInstallStrategy_To_operators_NamedInstallStrategy(in, out, s) +} + +func autoConvert_operators_NamedInstallStrategy_To_v1alpha1_NamedInstallStrategy(in *operators.NamedInstallStrategy, out *NamedInstallStrategy, s conversion.Scope) error { + out.StrategyName = in.StrategyName + out.StrategySpecRaw = *(*json.RawMessage)(unsafe.Pointer(&in.StrategySpecRaw)) + return nil +} + +// Convert_operators_NamedInstallStrategy_To_v1alpha1_NamedInstallStrategy is an autogenerated conversion function. +func Convert_operators_NamedInstallStrategy_To_v1alpha1_NamedInstallStrategy(in *operators.NamedInstallStrategy, out *NamedInstallStrategy, s conversion.Scope) error { + return autoConvert_operators_NamedInstallStrategy_To_v1alpha1_NamedInstallStrategy(in, out, s) +} + +func autoConvert_v1alpha1_RegistryServiceStatus_To_operators_RegistryServiceStatus(in *RegistryServiceStatus, out *operators.RegistryServiceStatus, s conversion.Scope) error { + out.Protocol = in.Protocol + out.ServiceName = in.ServiceName + out.ServiceNamespace = in.ServiceNamespace + out.Port = in.Port + out.CreatedAt = in.CreatedAt + return nil +} + +// Convert_v1alpha1_RegistryServiceStatus_To_operators_RegistryServiceStatus is an autogenerated conversion function. +func Convert_v1alpha1_RegistryServiceStatus_To_operators_RegistryServiceStatus(in *RegistryServiceStatus, out *operators.RegistryServiceStatus, s conversion.Scope) error { + return autoConvert_v1alpha1_RegistryServiceStatus_To_operators_RegistryServiceStatus(in, out, s) +} + +func autoConvert_operators_RegistryServiceStatus_To_v1alpha1_RegistryServiceStatus(in *operators.RegistryServiceStatus, out *RegistryServiceStatus, s conversion.Scope) error { + out.Protocol = in.Protocol + out.ServiceName = in.ServiceName + out.ServiceNamespace = in.ServiceNamespace + out.Port = in.Port + out.CreatedAt = in.CreatedAt + return nil +} + +// Convert_operators_RegistryServiceStatus_To_v1alpha1_RegistryServiceStatus is an autogenerated conversion function. +func Convert_operators_RegistryServiceStatus_To_v1alpha1_RegistryServiceStatus(in *operators.RegistryServiceStatus, out *RegistryServiceStatus, s conversion.Scope) error { + return autoConvert_operators_RegistryServiceStatus_To_v1alpha1_RegistryServiceStatus(in, out, s) +} + +func autoConvert_v1alpha1_RequirementStatus_To_operators_RequirementStatus(in *RequirementStatus, out *operators.RequirementStatus, s conversion.Scope) error { + out.Group = in.Group + out.Version = in.Version + out.Kind = in.Kind + out.Name = in.Name + out.Status = operators.StatusReason(in.Status) + out.Message = in.Message + out.UUID = in.UUID + out.Dependents = *(*[]operators.DependentStatus)(unsafe.Pointer(&in.Dependents)) + return nil +} + +// Convert_v1alpha1_RequirementStatus_To_operators_RequirementStatus is an autogenerated conversion function. +func Convert_v1alpha1_RequirementStatus_To_operators_RequirementStatus(in *RequirementStatus, out *operators.RequirementStatus, s conversion.Scope) error { + return autoConvert_v1alpha1_RequirementStatus_To_operators_RequirementStatus(in, out, s) +} + +func autoConvert_operators_RequirementStatus_To_v1alpha1_RequirementStatus(in *operators.RequirementStatus, out *RequirementStatus, s conversion.Scope) error { + out.Group = in.Group + out.Version = in.Version + out.Kind = in.Kind + out.Name = in.Name + out.Status = StatusReason(in.Status) + out.Message = in.Message + out.UUID = in.UUID + out.Dependents = *(*[]DependentStatus)(unsafe.Pointer(&in.Dependents)) + return nil +} + +// Convert_operators_RequirementStatus_To_v1alpha1_RequirementStatus is an autogenerated conversion function. +func Convert_operators_RequirementStatus_To_v1alpha1_RequirementStatus(in *operators.RequirementStatus, out *RequirementStatus, s conversion.Scope) error { + return autoConvert_operators_RequirementStatus_To_v1alpha1_RequirementStatus(in, out, s) +} + +func autoConvert_v1alpha1_SpecDescriptor_To_operators_SpecDescriptor(in *SpecDescriptor, out *operators.SpecDescriptor, s conversion.Scope) error { + out.Path = in.Path + out.DisplayName = in.DisplayName + out.Description = in.Description + out.XDescriptors = *(*[]string)(unsafe.Pointer(&in.XDescriptors)) + out.Value = (*json.RawMessage)(unsafe.Pointer(in.Value)) + return nil +} + +// Convert_v1alpha1_SpecDescriptor_To_operators_SpecDescriptor is an autogenerated conversion function. +func Convert_v1alpha1_SpecDescriptor_To_operators_SpecDescriptor(in *SpecDescriptor, out *operators.SpecDescriptor, s conversion.Scope) error { + return autoConvert_v1alpha1_SpecDescriptor_To_operators_SpecDescriptor(in, out, s) +} + +func autoConvert_operators_SpecDescriptor_To_v1alpha1_SpecDescriptor(in *operators.SpecDescriptor, out *SpecDescriptor, s conversion.Scope) error { + out.Path = in.Path + out.DisplayName = in.DisplayName + out.Description = in.Description + out.XDescriptors = *(*[]string)(unsafe.Pointer(&in.XDescriptors)) + out.Value = (*json.RawMessage)(unsafe.Pointer(in.Value)) + return nil +} + +// Convert_operators_SpecDescriptor_To_v1alpha1_SpecDescriptor is an autogenerated conversion function. +func Convert_operators_SpecDescriptor_To_v1alpha1_SpecDescriptor(in *operators.SpecDescriptor, out *SpecDescriptor, s conversion.Scope) error { + return autoConvert_operators_SpecDescriptor_To_v1alpha1_SpecDescriptor(in, out, s) +} + +func autoConvert_v1alpha1_StatusDescriptor_To_operators_StatusDescriptor(in *StatusDescriptor, out *operators.StatusDescriptor, s conversion.Scope) error { + out.Path = in.Path + out.DisplayName = in.DisplayName + out.Description = in.Description + out.XDescriptors = *(*[]string)(unsafe.Pointer(&in.XDescriptors)) + out.Value = (*json.RawMessage)(unsafe.Pointer(in.Value)) + return nil +} + +// Convert_v1alpha1_StatusDescriptor_To_operators_StatusDescriptor is an autogenerated conversion function. +func Convert_v1alpha1_StatusDescriptor_To_operators_StatusDescriptor(in *StatusDescriptor, out *operators.StatusDescriptor, s conversion.Scope) error { + return autoConvert_v1alpha1_StatusDescriptor_To_operators_StatusDescriptor(in, out, s) +} + +func autoConvert_operators_StatusDescriptor_To_v1alpha1_StatusDescriptor(in *operators.StatusDescriptor, out *StatusDescriptor, s conversion.Scope) error { + out.Path = in.Path + out.DisplayName = in.DisplayName + out.Description = in.Description + out.XDescriptors = *(*[]string)(unsafe.Pointer(&in.XDescriptors)) + out.Value = (*json.RawMessage)(unsafe.Pointer(in.Value)) + return nil +} + +// Convert_operators_StatusDescriptor_To_v1alpha1_StatusDescriptor is an autogenerated conversion function. +func Convert_operators_StatusDescriptor_To_v1alpha1_StatusDescriptor(in *operators.StatusDescriptor, out *StatusDescriptor, s conversion.Scope) error { + return autoConvert_operators_StatusDescriptor_To_v1alpha1_StatusDescriptor(in, out, s) +} + +func autoConvert_v1alpha1_Step_To_operators_Step(in *Step, out *operators.Step, s conversion.Scope) error { + out.Resolving = in.Resolving + if err := Convert_v1alpha1_StepResource_To_operators_StepResource(&in.Resource, &out.Resource, s); err != nil { + return err + } + out.Status = operators.StepStatus(in.Status) + return nil +} + +// Convert_v1alpha1_Step_To_operators_Step is an autogenerated conversion function. +func Convert_v1alpha1_Step_To_operators_Step(in *Step, out *operators.Step, s conversion.Scope) error { + return autoConvert_v1alpha1_Step_To_operators_Step(in, out, s) +} + +func autoConvert_operators_Step_To_v1alpha1_Step(in *operators.Step, out *Step, s conversion.Scope) error { + out.Resolving = in.Resolving + if err := Convert_operators_StepResource_To_v1alpha1_StepResource(&in.Resource, &out.Resource, s); err != nil { + return err + } + out.Status = StepStatus(in.Status) + return nil +} + +// Convert_operators_Step_To_v1alpha1_Step is an autogenerated conversion function. +func Convert_operators_Step_To_v1alpha1_Step(in *operators.Step, out *Step, s conversion.Scope) error { + return autoConvert_operators_Step_To_v1alpha1_Step(in, out, s) +} + +func autoConvert_v1alpha1_StepResource_To_operators_StepResource(in *StepResource, out *operators.StepResource, s conversion.Scope) error { + out.CatalogSource = in.CatalogSource + out.CatalogSourceNamespace = in.CatalogSourceNamespace + out.Group = in.Group + out.Version = in.Version + out.Kind = in.Kind + out.Name = in.Name + out.Manifest = in.Manifest + return nil +} + +// Convert_v1alpha1_StepResource_To_operators_StepResource is an autogenerated conversion function. +func Convert_v1alpha1_StepResource_To_operators_StepResource(in *StepResource, out *operators.StepResource, s conversion.Scope) error { + return autoConvert_v1alpha1_StepResource_To_operators_StepResource(in, out, s) +} + +func autoConvert_operators_StepResource_To_v1alpha1_StepResource(in *operators.StepResource, out *StepResource, s conversion.Scope) error { + out.CatalogSource = in.CatalogSource + out.CatalogSourceNamespace = in.CatalogSourceNamespace + out.Group = in.Group + out.Version = in.Version + out.Kind = in.Kind + out.Name = in.Name + out.Manifest = in.Manifest + return nil +} + +// Convert_operators_StepResource_To_v1alpha1_StepResource is an autogenerated conversion function. +func Convert_operators_StepResource_To_v1alpha1_StepResource(in *operators.StepResource, out *StepResource, s conversion.Scope) error { + return autoConvert_operators_StepResource_To_v1alpha1_StepResource(in, out, s) +} + +func autoConvert_v1alpha1_Subscription_To_operators_Subscription(in *Subscription, out *operators.Subscription, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + out.Spec = (*operators.SubscriptionSpec)(unsafe.Pointer(in.Spec)) + if err := Convert_v1alpha1_SubscriptionStatus_To_operators_SubscriptionStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_Subscription_To_operators_Subscription is an autogenerated conversion function. +func Convert_v1alpha1_Subscription_To_operators_Subscription(in *Subscription, out *operators.Subscription, s conversion.Scope) error { + return autoConvert_v1alpha1_Subscription_To_operators_Subscription(in, out, s) +} + +func autoConvert_operators_Subscription_To_v1alpha1_Subscription(in *operators.Subscription, out *Subscription, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + out.Spec = (*SubscriptionSpec)(unsafe.Pointer(in.Spec)) + if err := Convert_operators_SubscriptionStatus_To_v1alpha1_SubscriptionStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_operators_Subscription_To_v1alpha1_Subscription is an autogenerated conversion function. +func Convert_operators_Subscription_To_v1alpha1_Subscription(in *operators.Subscription, out *Subscription, s conversion.Scope) error { + return autoConvert_operators_Subscription_To_v1alpha1_Subscription(in, out, s) +} + +func autoConvert_v1alpha1_SubscriptionCatalogHealth_To_operators_SubscriptionCatalogHealth(in *SubscriptionCatalogHealth, out *operators.SubscriptionCatalogHealth, s conversion.Scope) error { + out.CatalogSourceRef = (*corev1.ObjectReference)(unsafe.Pointer(in.CatalogSourceRef)) + out.LastUpdated = (*v1.Time)(unsafe.Pointer(in.LastUpdated)) + out.Healthy = in.Healthy + return nil +} + +// Convert_v1alpha1_SubscriptionCatalogHealth_To_operators_SubscriptionCatalogHealth is an autogenerated conversion function. +func Convert_v1alpha1_SubscriptionCatalogHealth_To_operators_SubscriptionCatalogHealth(in *SubscriptionCatalogHealth, out *operators.SubscriptionCatalogHealth, s conversion.Scope) error { + return autoConvert_v1alpha1_SubscriptionCatalogHealth_To_operators_SubscriptionCatalogHealth(in, out, s) +} + +func autoConvert_operators_SubscriptionCatalogHealth_To_v1alpha1_SubscriptionCatalogHealth(in *operators.SubscriptionCatalogHealth, out *SubscriptionCatalogHealth, s conversion.Scope) error { + out.CatalogSourceRef = (*corev1.ObjectReference)(unsafe.Pointer(in.CatalogSourceRef)) + out.LastUpdated = (*v1.Time)(unsafe.Pointer(in.LastUpdated)) + out.Healthy = in.Healthy + return nil +} + +// Convert_operators_SubscriptionCatalogHealth_To_v1alpha1_SubscriptionCatalogHealth is an autogenerated conversion function. +func Convert_operators_SubscriptionCatalogHealth_To_v1alpha1_SubscriptionCatalogHealth(in *operators.SubscriptionCatalogHealth, out *SubscriptionCatalogHealth, s conversion.Scope) error { + return autoConvert_operators_SubscriptionCatalogHealth_To_v1alpha1_SubscriptionCatalogHealth(in, out, s) +} + +func autoConvert_v1alpha1_SubscriptionCondition_To_operators_SubscriptionCondition(in *SubscriptionCondition, out *operators.SubscriptionCondition, s conversion.Scope) error { + out.Type = operators.SubscriptionConditionType(in.Type) + out.Status = corev1.ConditionStatus(in.Status) + out.Reason = in.Reason + out.Message = in.Message + out.LastHeartbeatTime = (*v1.Time)(unsafe.Pointer(in.LastHeartbeatTime)) + out.LastTransitionTime = (*v1.Time)(unsafe.Pointer(in.LastTransitionTime)) + return nil +} + +// Convert_v1alpha1_SubscriptionCondition_To_operators_SubscriptionCondition is an autogenerated conversion function. +func Convert_v1alpha1_SubscriptionCondition_To_operators_SubscriptionCondition(in *SubscriptionCondition, out *operators.SubscriptionCondition, s conversion.Scope) error { + return autoConvert_v1alpha1_SubscriptionCondition_To_operators_SubscriptionCondition(in, out, s) +} + +func autoConvert_operators_SubscriptionCondition_To_v1alpha1_SubscriptionCondition(in *operators.SubscriptionCondition, out *SubscriptionCondition, s conversion.Scope) error { + out.Type = SubscriptionConditionType(in.Type) + out.Status = corev1.ConditionStatus(in.Status) + out.Reason = in.Reason + out.Message = in.Message + out.LastHeartbeatTime = (*v1.Time)(unsafe.Pointer(in.LastHeartbeatTime)) + out.LastTransitionTime = (*v1.Time)(unsafe.Pointer(in.LastTransitionTime)) + return nil +} + +// Convert_operators_SubscriptionCondition_To_v1alpha1_SubscriptionCondition is an autogenerated conversion function. +func Convert_operators_SubscriptionCondition_To_v1alpha1_SubscriptionCondition(in *operators.SubscriptionCondition, out *SubscriptionCondition, s conversion.Scope) error { + return autoConvert_operators_SubscriptionCondition_To_v1alpha1_SubscriptionCondition(in, out, s) +} + +func autoConvert_v1alpha1_SubscriptionList_To_operators_SubscriptionList(in *SubscriptionList, out *operators.SubscriptionList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]operators.Subscription)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_SubscriptionList_To_operators_SubscriptionList is an autogenerated conversion function. +func Convert_v1alpha1_SubscriptionList_To_operators_SubscriptionList(in *SubscriptionList, out *operators.SubscriptionList, s conversion.Scope) error { + return autoConvert_v1alpha1_SubscriptionList_To_operators_SubscriptionList(in, out, s) +} + +func autoConvert_operators_SubscriptionList_To_v1alpha1_SubscriptionList(in *operators.SubscriptionList, out *SubscriptionList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]Subscription)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_operators_SubscriptionList_To_v1alpha1_SubscriptionList is an autogenerated conversion function. +func Convert_operators_SubscriptionList_To_v1alpha1_SubscriptionList(in *operators.SubscriptionList, out *SubscriptionList, s conversion.Scope) error { + return autoConvert_operators_SubscriptionList_To_v1alpha1_SubscriptionList(in, out, s) +} + +func autoConvert_v1alpha1_SubscriptionSpec_To_operators_SubscriptionSpec(in *SubscriptionSpec, out *operators.SubscriptionSpec, s conversion.Scope) error { + out.CatalogSource = in.CatalogSource + out.CatalogSourceNamespace = in.CatalogSourceNamespace + out.Package = in.Package + out.Channel = in.Channel + out.StartingCSV = in.StartingCSV + out.InstallPlanApproval = operators.Approval(in.InstallPlanApproval) + return nil +} + +// Convert_v1alpha1_SubscriptionSpec_To_operators_SubscriptionSpec is an autogenerated conversion function. +func Convert_v1alpha1_SubscriptionSpec_To_operators_SubscriptionSpec(in *SubscriptionSpec, out *operators.SubscriptionSpec, s conversion.Scope) error { + return autoConvert_v1alpha1_SubscriptionSpec_To_operators_SubscriptionSpec(in, out, s) +} + +func autoConvert_operators_SubscriptionSpec_To_v1alpha1_SubscriptionSpec(in *operators.SubscriptionSpec, out *SubscriptionSpec, s conversion.Scope) error { + out.CatalogSource = in.CatalogSource + out.CatalogSourceNamespace = in.CatalogSourceNamespace + out.Package = in.Package + out.Channel = in.Channel + out.StartingCSV = in.StartingCSV + out.InstallPlanApproval = Approval(in.InstallPlanApproval) + return nil +} + +// Convert_operators_SubscriptionSpec_To_v1alpha1_SubscriptionSpec is an autogenerated conversion function. +func Convert_operators_SubscriptionSpec_To_v1alpha1_SubscriptionSpec(in *operators.SubscriptionSpec, out *SubscriptionSpec, s conversion.Scope) error { + return autoConvert_operators_SubscriptionSpec_To_v1alpha1_SubscriptionSpec(in, out, s) +} + +func autoConvert_v1alpha1_SubscriptionStatus_To_operators_SubscriptionStatus(in *SubscriptionStatus, out *operators.SubscriptionStatus, s conversion.Scope) error { + out.CurrentCSV = in.CurrentCSV + out.InstalledCSV = in.InstalledCSV + out.Install = (*operators.InstallPlanReference)(unsafe.Pointer(in.Install)) + out.State = operators.SubscriptionState(in.State) + out.Reason = operators.ConditionReason(in.Reason) + out.InstallPlanRef = (*corev1.ObjectReference)(unsafe.Pointer(in.InstallPlanRef)) + out.CatalogHealth = *(*[]operators.SubscriptionCatalogHealth)(unsafe.Pointer(&in.CatalogHealth)) + out.Conditions = *(*[]operators.SubscriptionCondition)(unsafe.Pointer(&in.Conditions)) + out.LastUpdated = in.LastUpdated + return nil +} + +// Convert_v1alpha1_SubscriptionStatus_To_operators_SubscriptionStatus is an autogenerated conversion function. +func Convert_v1alpha1_SubscriptionStatus_To_operators_SubscriptionStatus(in *SubscriptionStatus, out *operators.SubscriptionStatus, s conversion.Scope) error { + return autoConvert_v1alpha1_SubscriptionStatus_To_operators_SubscriptionStatus(in, out, s) +} + +func autoConvert_operators_SubscriptionStatus_To_v1alpha1_SubscriptionStatus(in *operators.SubscriptionStatus, out *SubscriptionStatus, s conversion.Scope) error { + out.CurrentCSV = in.CurrentCSV + out.InstalledCSV = in.InstalledCSV + out.Install = (*InstallPlanReference)(unsafe.Pointer(in.Install)) + out.State = SubscriptionState(in.State) + out.Reason = ConditionReason(in.Reason) + out.InstallPlanRef = (*corev1.ObjectReference)(unsafe.Pointer(in.InstallPlanRef)) + out.CatalogHealth = *(*[]SubscriptionCatalogHealth)(unsafe.Pointer(&in.CatalogHealth)) + out.Conditions = *(*[]SubscriptionCondition)(unsafe.Pointer(&in.Conditions)) + out.LastUpdated = in.LastUpdated + return nil +} + +// Convert_operators_SubscriptionStatus_To_v1alpha1_SubscriptionStatus is an autogenerated conversion function. +func Convert_operators_SubscriptionStatus_To_v1alpha1_SubscriptionStatus(in *operators.SubscriptionStatus, out *SubscriptionStatus, s conversion.Scope) error { + return autoConvert_operators_SubscriptionStatus_To_v1alpha1_SubscriptionStatus(in, out, s) +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..ad6546e79f --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,1108 @@ +// +build !ignore_autogenerated + +/* +Copyright 2019 Red Hat, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + json "encoding/json" + + corev1 "k8s.io/api/core/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIResourceReference) DeepCopyInto(out *APIResourceReference) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIResourceReference. +func (in *APIResourceReference) DeepCopy() *APIResourceReference { + if in == nil { + return nil + } + out := new(APIResourceReference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIServiceDefinitions) DeepCopyInto(out *APIServiceDefinitions) { + *out = *in + if in.Owned != nil { + in, out := &in.Owned, &out.Owned + *out = make([]APIServiceDescription, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Required != nil { + in, out := &in.Required, &out.Required + *out = make([]APIServiceDescription, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceDefinitions. +func (in *APIServiceDefinitions) DeepCopy() *APIServiceDefinitions { + if in == nil { + return nil + } + out := new(APIServiceDefinitions) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIServiceDescription) DeepCopyInto(out *APIServiceDescription) { + *out = *in + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = make([]APIResourceReference, len(*in)) + copy(*out, *in) + } + if in.StatusDescriptors != nil { + in, out := &in.StatusDescriptors, &out.StatusDescriptors + *out = make([]StatusDescriptor, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.SpecDescriptors != nil { + in, out := &in.SpecDescriptors, &out.SpecDescriptors + *out = make([]SpecDescriptor, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ActionDescriptor != nil { + in, out := &in.ActionDescriptor, &out.ActionDescriptor + *out = make([]ActionDescriptor, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceDescription. +func (in *APIServiceDescription) DeepCopy() *APIServiceDescription { + if in == nil { + return nil + } + out := new(APIServiceDescription) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ActionDescriptor) DeepCopyInto(out *ActionDescriptor) { + *out = *in + if in.XDescriptors != nil { + in, out := &in.XDescriptors, &out.XDescriptors + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Value != nil { + in, out := &in.Value, &out.Value + *out = new(json.RawMessage) + if **in != nil { + in, out := *in, *out + *out = make([]byte, len(*in)) + copy(*out, *in) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ActionDescriptor. +func (in *ActionDescriptor) DeepCopy() *ActionDescriptor { + if in == nil { + return nil + } + out := new(ActionDescriptor) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AppLink) DeepCopyInto(out *AppLink) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppLink. +func (in *AppLink) DeepCopy() *AppLink { + if in == nil { + return nil + } + out := new(AppLink) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CRDDescription) DeepCopyInto(out *CRDDescription) { + *out = *in + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = make([]APIResourceReference, len(*in)) + copy(*out, *in) + } + if in.StatusDescriptors != nil { + in, out := &in.StatusDescriptors, &out.StatusDescriptors + *out = make([]StatusDescriptor, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.SpecDescriptors != nil { + in, out := &in.SpecDescriptors, &out.SpecDescriptors + *out = make([]SpecDescriptor, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ActionDescriptor != nil { + in, out := &in.ActionDescriptor, &out.ActionDescriptor + *out = make([]ActionDescriptor, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CRDDescription. +func (in *CRDDescription) DeepCopy() *CRDDescription { + if in == nil { + return nil + } + out := new(CRDDescription) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CatalogSource) DeepCopyInto(out *CatalogSource) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CatalogSource. +func (in *CatalogSource) DeepCopy() *CatalogSource { + if in == nil { + return nil + } + out := new(CatalogSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CatalogSource) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CatalogSourceList) DeepCopyInto(out *CatalogSourceList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]CatalogSource, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CatalogSourceList. +func (in *CatalogSourceList) DeepCopy() *CatalogSourceList { + if in == nil { + return nil + } + out := new(CatalogSourceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CatalogSourceList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CatalogSourceSpec) DeepCopyInto(out *CatalogSourceSpec) { + *out = *in + if in.Secrets != nil { + in, out := &in.Secrets, &out.Secrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + out.Icon = in.Icon + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CatalogSourceSpec. +func (in *CatalogSourceSpec) DeepCopy() *CatalogSourceSpec { + if in == nil { + return nil + } + out := new(CatalogSourceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CatalogSourceStatus) DeepCopyInto(out *CatalogSourceStatus) { + *out = *in + if in.ConfigMapResource != nil { + in, out := &in.ConfigMapResource, &out.ConfigMapResource + *out = new(ConfigMapResourceReference) + **out = **in + } + if in.RegistryServiceStatus != nil { + in, out := &in.RegistryServiceStatus, &out.RegistryServiceStatus + *out = new(RegistryServiceStatus) + (*in).DeepCopyInto(*out) + } + in.LastSync.DeepCopyInto(&out.LastSync) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CatalogSourceStatus. +func (in *CatalogSourceStatus) DeepCopy() *CatalogSourceStatus { + if in == nil { + return nil + } + out := new(CatalogSourceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterServiceVersion) DeepCopyInto(out *ClusterServiceVersion) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterServiceVersion. +func (in *ClusterServiceVersion) DeepCopy() *ClusterServiceVersion { + if in == nil { + return nil + } + out := new(ClusterServiceVersion) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterServiceVersion) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterServiceVersionCondition) DeepCopyInto(out *ClusterServiceVersionCondition) { + *out = *in + in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime) + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterServiceVersionCondition. +func (in *ClusterServiceVersionCondition) DeepCopy() *ClusterServiceVersionCondition { + if in == nil { + return nil + } + out := new(ClusterServiceVersionCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterServiceVersionList) DeepCopyInto(out *ClusterServiceVersionList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterServiceVersion, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterServiceVersionList. +func (in *ClusterServiceVersionList) DeepCopy() *ClusterServiceVersionList { + if in == nil { + return nil + } + out := new(ClusterServiceVersionList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterServiceVersionList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterServiceVersionSpec) DeepCopyInto(out *ClusterServiceVersionSpec) { + *out = *in + in.InstallStrategy.DeepCopyInto(&out.InstallStrategy) + in.Version.DeepCopyInto(&out.Version) + in.CustomResourceDefinitions.DeepCopyInto(&out.CustomResourceDefinitions) + in.APIServiceDefinitions.DeepCopyInto(&out.APIServiceDefinitions) + if in.NativeAPIs != nil { + in, out := &in.NativeAPIs, &out.NativeAPIs + *out = make([]v1.GroupVersionKind, len(*in)) + copy(*out, *in) + } + if in.Keywords != nil { + in, out := &in.Keywords, &out.Keywords + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Maintainers != nil { + in, out := &in.Maintainers, &out.Maintainers + *out = make([]Maintainer, len(*in)) + copy(*out, *in) + } + out.Provider = in.Provider + if in.Links != nil { + in, out := &in.Links, &out.Links + *out = make([]AppLink, len(*in)) + copy(*out, *in) + } + if in.Icon != nil { + in, out := &in.Icon, &out.Icon + *out = make([]Icon, len(*in)) + copy(*out, *in) + } + if in.InstallModes != nil { + in, out := &in.InstallModes, &out.InstallModes + *out = make([]InstallMode, len(*in)) + copy(*out, *in) + } + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterServiceVersionSpec. +func (in *ClusterServiceVersionSpec) DeepCopy() *ClusterServiceVersionSpec { + if in == nil { + return nil + } + out := new(ClusterServiceVersionSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterServiceVersionStatus) DeepCopyInto(out *ClusterServiceVersionStatus) { + *out = *in + in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime) + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]ClusterServiceVersionCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.RequirementStatus != nil { + in, out := &in.RequirementStatus, &out.RequirementStatus + *out = make([]RequirementStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.CertsLastUpdated.DeepCopyInto(&out.CertsLastUpdated) + in.CertsRotateAt.DeepCopyInto(&out.CertsRotateAt) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterServiceVersionStatus. +func (in *ClusterServiceVersionStatus) DeepCopy() *ClusterServiceVersionStatus { + if in == nil { + return nil + } + out := new(ClusterServiceVersionStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ConfigMapResourceReference) DeepCopyInto(out *ConfigMapResourceReference) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigMapResourceReference. +func (in *ConfigMapResourceReference) DeepCopy() *ConfigMapResourceReference { + if in == nil { + return nil + } + out := new(ConfigMapResourceReference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CustomResourceDefinitions) DeepCopyInto(out *CustomResourceDefinitions) { + *out = *in + if in.Owned != nil { + in, out := &in.Owned, &out.Owned + *out = make([]CRDDescription, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Required != nil { + in, out := &in.Required, &out.Required + *out = make([]CRDDescription, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceDefinitions. +func (in *CustomResourceDefinitions) DeepCopy() *CustomResourceDefinitions { + if in == nil { + return nil + } + out := new(CustomResourceDefinitions) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DependentStatus) DeepCopyInto(out *DependentStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DependentStatus. +func (in *DependentStatus) DeepCopy() *DependentStatus { + if in == nil { + return nil + } + out := new(DependentStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Icon) DeepCopyInto(out *Icon) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Icon. +func (in *Icon) DeepCopy() *Icon { + if in == nil { + return nil + } + out := new(Icon) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstallMode) DeepCopyInto(out *InstallMode) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallMode. +func (in *InstallMode) DeepCopy() *InstallMode { + if in == nil { + return nil + } + out := new(InstallMode) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in InstallModeSet) DeepCopyInto(out *InstallModeSet) { + { + in := &in + *out = make(InstallModeSet, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + return + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallModeSet. +func (in InstallModeSet) DeepCopy() InstallModeSet { + if in == nil { + return nil + } + out := new(InstallModeSet) + in.DeepCopyInto(out) + return *out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstallPlan) DeepCopyInto(out *InstallPlan) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallPlan. +func (in *InstallPlan) DeepCopy() *InstallPlan { + if in == nil { + return nil + } + out := new(InstallPlan) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *InstallPlan) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstallPlanCondition) DeepCopyInto(out *InstallPlanCondition) { + *out = *in + in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime) + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallPlanCondition. +func (in *InstallPlanCondition) DeepCopy() *InstallPlanCondition { + if in == nil { + return nil + } + out := new(InstallPlanCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstallPlanList) DeepCopyInto(out *InstallPlanList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]InstallPlan, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallPlanList. +func (in *InstallPlanList) DeepCopy() *InstallPlanList { + if in == nil { + return nil + } + out := new(InstallPlanList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *InstallPlanList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstallPlanReference) DeepCopyInto(out *InstallPlanReference) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallPlanReference. +func (in *InstallPlanReference) DeepCopy() *InstallPlanReference { + if in == nil { + return nil + } + out := new(InstallPlanReference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstallPlanSpec) DeepCopyInto(out *InstallPlanSpec) { + *out = *in + if in.ClusterServiceVersionNames != nil { + in, out := &in.ClusterServiceVersionNames, &out.ClusterServiceVersionNames + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallPlanSpec. +func (in *InstallPlanSpec) DeepCopy() *InstallPlanSpec { + if in == nil { + return nil + } + out := new(InstallPlanSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstallPlanStatus) DeepCopyInto(out *InstallPlanStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]InstallPlanCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.CatalogSources != nil { + in, out := &in.CatalogSources, &out.CatalogSources + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Plan != nil { + in, out := &in.Plan, &out.Plan + *out = make([]*Step, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(Step) + **out = **in + } + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallPlanStatus. +func (in *InstallPlanStatus) DeepCopy() *InstallPlanStatus { + if in == nil { + return nil + } + out := new(InstallPlanStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Maintainer) DeepCopyInto(out *Maintainer) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Maintainer. +func (in *Maintainer) DeepCopy() *Maintainer { + if in == nil { + return nil + } + out := new(Maintainer) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NamedInstallStrategy) DeepCopyInto(out *NamedInstallStrategy) { + *out = *in + if in.StrategySpecRaw != nil { + in, out := &in.StrategySpecRaw, &out.StrategySpecRaw + *out = make(json.RawMessage, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NamedInstallStrategy. +func (in *NamedInstallStrategy) DeepCopy() *NamedInstallStrategy { + if in == nil { + return nil + } + out := new(NamedInstallStrategy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RegistryServiceStatus) DeepCopyInto(out *RegistryServiceStatus) { + *out = *in + in.CreatedAt.DeepCopyInto(&out.CreatedAt) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RegistryServiceStatus. +func (in *RegistryServiceStatus) DeepCopy() *RegistryServiceStatus { + if in == nil { + return nil + } + out := new(RegistryServiceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RequirementStatus) DeepCopyInto(out *RequirementStatus) { + *out = *in + if in.Dependents != nil { + in, out := &in.Dependents, &out.Dependents + *out = make([]DependentStatus, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RequirementStatus. +func (in *RequirementStatus) DeepCopy() *RequirementStatus { + if in == nil { + return nil + } + out := new(RequirementStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SpecDescriptor) DeepCopyInto(out *SpecDescriptor) { + *out = *in + if in.XDescriptors != nil { + in, out := &in.XDescriptors, &out.XDescriptors + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Value != nil { + in, out := &in.Value, &out.Value + *out = new(json.RawMessage) + if **in != nil { + in, out := *in, *out + *out = make([]byte, len(*in)) + copy(*out, *in) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpecDescriptor. +func (in *SpecDescriptor) DeepCopy() *SpecDescriptor { + if in == nil { + return nil + } + out := new(SpecDescriptor) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StatusDescriptor) DeepCopyInto(out *StatusDescriptor) { + *out = *in + if in.XDescriptors != nil { + in, out := &in.XDescriptors, &out.XDescriptors + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Value != nil { + in, out := &in.Value, &out.Value + *out = new(json.RawMessage) + if **in != nil { + in, out := *in, *out + *out = make([]byte, len(*in)) + copy(*out, *in) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StatusDescriptor. +func (in *StatusDescriptor) DeepCopy() *StatusDescriptor { + if in == nil { + return nil + } + out := new(StatusDescriptor) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Step) DeepCopyInto(out *Step) { + *out = *in + out.Resource = in.Resource + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Step. +func (in *Step) DeepCopy() *Step { + if in == nil { + return nil + } + out := new(Step) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StepResource) DeepCopyInto(out *StepResource) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StepResource. +func (in *StepResource) DeepCopy() *StepResource { + if in == nil { + return nil + } + out := new(StepResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Subscription) DeepCopyInto(out *Subscription) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.Spec != nil { + in, out := &in.Spec, &out.Spec + *out = new(SubscriptionSpec) + **out = **in + } + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Subscription. +func (in *Subscription) DeepCopy() *Subscription { + if in == nil { + return nil + } + out := new(Subscription) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Subscription) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriptionCatalogHealth) DeepCopyInto(out *SubscriptionCatalogHealth) { + *out = *in + if in.CatalogSourceRef != nil { + in, out := &in.CatalogSourceRef, &out.CatalogSourceRef + *out = new(corev1.ObjectReference) + **out = **in + } + if in.LastUpdated != nil { + in, out := &in.LastUpdated, &out.LastUpdated + *out = (*in).DeepCopy() + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionCatalogHealth. +func (in *SubscriptionCatalogHealth) DeepCopy() *SubscriptionCatalogHealth { + if in == nil { + return nil + } + out := new(SubscriptionCatalogHealth) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriptionCondition) DeepCopyInto(out *SubscriptionCondition) { + *out = *in + if in.LastHeartbeatTime != nil { + in, out := &in.LastHeartbeatTime, &out.LastHeartbeatTime + *out = (*in).DeepCopy() + } + if in.LastTransitionTime != nil { + in, out := &in.LastTransitionTime, &out.LastTransitionTime + *out = (*in).DeepCopy() + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionCondition. +func (in *SubscriptionCondition) DeepCopy() *SubscriptionCondition { + if in == nil { + return nil + } + out := new(SubscriptionCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriptionList) DeepCopyInto(out *SubscriptionList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Subscription, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionList. +func (in *SubscriptionList) DeepCopy() *SubscriptionList { + if in == nil { + return nil + } + out := new(SubscriptionList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SubscriptionList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriptionSpec) DeepCopyInto(out *SubscriptionSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionSpec. +func (in *SubscriptionSpec) DeepCopy() *SubscriptionSpec { + if in == nil { + return nil + } + out := new(SubscriptionSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriptionStatus) DeepCopyInto(out *SubscriptionStatus) { + *out = *in + if in.Install != nil { + in, out := &in.Install, &out.Install + *out = new(InstallPlanReference) + **out = **in + } + if in.InstallPlanRef != nil { + in, out := &in.InstallPlanRef, &out.InstallPlanRef + *out = new(corev1.ObjectReference) + **out = **in + } + if in.CatalogHealth != nil { + in, out := &in.CatalogHealth, &out.CatalogHealth + *out = make([]SubscriptionCatalogHealth, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]SubscriptionCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.LastUpdated.DeepCopyInto(&out.LastUpdated) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionStatus. +func (in *SubscriptionStatus) DeepCopy() *SubscriptionStatus { + if in == nil { + return nil + } + out := new(SubscriptionStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/zz_generated.deepcopy.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/zz_generated.deepcopy.go new file mode 100644 index 0000000000..04342b256a --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/zz_generated.deepcopy.go @@ -0,0 +1,1218 @@ +// +build !ignore_autogenerated + +/* +Copyright 2019 Red Hat, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package operators + +import ( + json "encoding/json" + + corev1 "k8s.io/api/core/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIResourceReference) DeepCopyInto(out *APIResourceReference) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIResourceReference. +func (in *APIResourceReference) DeepCopy() *APIResourceReference { + if in == nil { + return nil + } + out := new(APIResourceReference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIServiceDefinitions) DeepCopyInto(out *APIServiceDefinitions) { + *out = *in + if in.Owned != nil { + in, out := &in.Owned, &out.Owned + *out = make([]APIServiceDescription, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Required != nil { + in, out := &in.Required, &out.Required + *out = make([]APIServiceDescription, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceDefinitions. +func (in *APIServiceDefinitions) DeepCopy() *APIServiceDefinitions { + if in == nil { + return nil + } + out := new(APIServiceDefinitions) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIServiceDescription) DeepCopyInto(out *APIServiceDescription) { + *out = *in + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = make([]APIResourceReference, len(*in)) + copy(*out, *in) + } + if in.StatusDescriptors != nil { + in, out := &in.StatusDescriptors, &out.StatusDescriptors + *out = make([]StatusDescriptor, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.SpecDescriptors != nil { + in, out := &in.SpecDescriptors, &out.SpecDescriptors + *out = make([]SpecDescriptor, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ActionDescriptor != nil { + in, out := &in.ActionDescriptor, &out.ActionDescriptor + *out = make([]ActionDescriptor, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceDescription. +func (in *APIServiceDescription) DeepCopy() *APIServiceDescription { + if in == nil { + return nil + } + out := new(APIServiceDescription) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ActionDescriptor) DeepCopyInto(out *ActionDescriptor) { + *out = *in + if in.XDescriptors != nil { + in, out := &in.XDescriptors, &out.XDescriptors + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Value != nil { + in, out := &in.Value, &out.Value + *out = new(json.RawMessage) + if **in != nil { + in, out := *in, *out + *out = make([]byte, len(*in)) + copy(*out, *in) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ActionDescriptor. +func (in *ActionDescriptor) DeepCopy() *ActionDescriptor { + if in == nil { + return nil + } + out := new(ActionDescriptor) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AppLink) DeepCopyInto(out *AppLink) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppLink. +func (in *AppLink) DeepCopy() *AppLink { + if in == nil { + return nil + } + out := new(AppLink) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CRDDescription) DeepCopyInto(out *CRDDescription) { + *out = *in + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = make([]APIResourceReference, len(*in)) + copy(*out, *in) + } + if in.StatusDescriptors != nil { + in, out := &in.StatusDescriptors, &out.StatusDescriptors + *out = make([]StatusDescriptor, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.SpecDescriptors != nil { + in, out := &in.SpecDescriptors, &out.SpecDescriptors + *out = make([]SpecDescriptor, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ActionDescriptor != nil { + in, out := &in.ActionDescriptor, &out.ActionDescriptor + *out = make([]ActionDescriptor, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CRDDescription. +func (in *CRDDescription) DeepCopy() *CRDDescription { + if in == nil { + return nil + } + out := new(CRDDescription) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CatalogSource) DeepCopyInto(out *CatalogSource) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CatalogSource. +func (in *CatalogSource) DeepCopy() *CatalogSource { + if in == nil { + return nil + } + out := new(CatalogSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CatalogSource) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CatalogSourceList) DeepCopyInto(out *CatalogSourceList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]CatalogSource, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CatalogSourceList. +func (in *CatalogSourceList) DeepCopy() *CatalogSourceList { + if in == nil { + return nil + } + out := new(CatalogSourceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CatalogSourceList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CatalogSourceSpec) DeepCopyInto(out *CatalogSourceSpec) { + *out = *in + if in.Secrets != nil { + in, out := &in.Secrets, &out.Secrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + out.Icon = in.Icon + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CatalogSourceSpec. +func (in *CatalogSourceSpec) DeepCopy() *CatalogSourceSpec { + if in == nil { + return nil + } + out := new(CatalogSourceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CatalogSourceStatus) DeepCopyInto(out *CatalogSourceStatus) { + *out = *in + if in.ConfigMapResource != nil { + in, out := &in.ConfigMapResource, &out.ConfigMapResource + *out = new(ConfigMapResourceReference) + **out = **in + } + if in.RegistryServiceStatus != nil { + in, out := &in.RegistryServiceStatus, &out.RegistryServiceStatus + *out = new(RegistryServiceStatus) + (*in).DeepCopyInto(*out) + } + in.LastSync.DeepCopyInto(&out.LastSync) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CatalogSourceStatus. +func (in *CatalogSourceStatus) DeepCopy() *CatalogSourceStatus { + if in == nil { + return nil + } + out := new(CatalogSourceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterServiceVersion) DeepCopyInto(out *ClusterServiceVersion) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterServiceVersion. +func (in *ClusterServiceVersion) DeepCopy() *ClusterServiceVersion { + if in == nil { + return nil + } + out := new(ClusterServiceVersion) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterServiceVersion) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterServiceVersionCondition) DeepCopyInto(out *ClusterServiceVersionCondition) { + *out = *in + in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime) + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterServiceVersionCondition. +func (in *ClusterServiceVersionCondition) DeepCopy() *ClusterServiceVersionCondition { + if in == nil { + return nil + } + out := new(ClusterServiceVersionCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterServiceVersionList) DeepCopyInto(out *ClusterServiceVersionList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterServiceVersion, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterServiceVersionList. +func (in *ClusterServiceVersionList) DeepCopy() *ClusterServiceVersionList { + if in == nil { + return nil + } + out := new(ClusterServiceVersionList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterServiceVersionList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterServiceVersionSpec) DeepCopyInto(out *ClusterServiceVersionSpec) { + *out = *in + in.InstallStrategy.DeepCopyInto(&out.InstallStrategy) + in.Version.DeepCopyInto(&out.Version) + in.CustomResourceDefinitions.DeepCopyInto(&out.CustomResourceDefinitions) + in.APIServiceDefinitions.DeepCopyInto(&out.APIServiceDefinitions) + if in.NativeAPIs != nil { + in, out := &in.NativeAPIs, &out.NativeAPIs + *out = make([]v1.GroupVersionKind, len(*in)) + copy(*out, *in) + } + if in.Keywords != nil { + in, out := &in.Keywords, &out.Keywords + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Maintainers != nil { + in, out := &in.Maintainers, &out.Maintainers + *out = make([]Maintainer, len(*in)) + copy(*out, *in) + } + out.Provider = in.Provider + if in.Links != nil { + in, out := &in.Links, &out.Links + *out = make([]AppLink, len(*in)) + copy(*out, *in) + } + if in.Icon != nil { + in, out := &in.Icon, &out.Icon + *out = make([]Icon, len(*in)) + copy(*out, *in) + } + if in.InstallModes != nil { + in, out := &in.InstallModes, &out.InstallModes + *out = make([]InstallMode, len(*in)) + copy(*out, *in) + } + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterServiceVersionSpec. +func (in *ClusterServiceVersionSpec) DeepCopy() *ClusterServiceVersionSpec { + if in == nil { + return nil + } + out := new(ClusterServiceVersionSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterServiceVersionStatus) DeepCopyInto(out *ClusterServiceVersionStatus) { + *out = *in + in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime) + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]ClusterServiceVersionCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.RequirementStatus != nil { + in, out := &in.RequirementStatus, &out.RequirementStatus + *out = make([]RequirementStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.CertsLastUpdated.DeepCopyInto(&out.CertsLastUpdated) + in.CertsRotateAt.DeepCopyInto(&out.CertsRotateAt) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterServiceVersionStatus. +func (in *ClusterServiceVersionStatus) DeepCopy() *ClusterServiceVersionStatus { + if in == nil { + return nil + } + out := new(ClusterServiceVersionStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ConfigMapResourceReference) DeepCopyInto(out *ConfigMapResourceReference) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigMapResourceReference. +func (in *ConfigMapResourceReference) DeepCopy() *ConfigMapResourceReference { + if in == nil { + return nil + } + out := new(ConfigMapResourceReference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CustomResourceDefinitions) DeepCopyInto(out *CustomResourceDefinitions) { + *out = *in + if in.Owned != nil { + in, out := &in.Owned, &out.Owned + *out = make([]CRDDescription, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Required != nil { + in, out := &in.Required, &out.Required + *out = make([]CRDDescription, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceDefinitions. +func (in *CustomResourceDefinitions) DeepCopy() *CustomResourceDefinitions { + if in == nil { + return nil + } + out := new(CustomResourceDefinitions) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DependentStatus) DeepCopyInto(out *DependentStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DependentStatus. +func (in *DependentStatus) DeepCopy() *DependentStatus { + if in == nil { + return nil + } + out := new(DependentStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Icon) DeepCopyInto(out *Icon) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Icon. +func (in *Icon) DeepCopy() *Icon { + if in == nil { + return nil + } + out := new(Icon) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstallMode) DeepCopyInto(out *InstallMode) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallMode. +func (in *InstallMode) DeepCopy() *InstallMode { + if in == nil { + return nil + } + out := new(InstallMode) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in InstallModeSet) DeepCopyInto(out *InstallModeSet) { + { + in := &in + *out = make(InstallModeSet, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + return + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallModeSet. +func (in InstallModeSet) DeepCopy() InstallModeSet { + if in == nil { + return nil + } + out := new(InstallModeSet) + in.DeepCopyInto(out) + return *out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstallPlan) DeepCopyInto(out *InstallPlan) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallPlan. +func (in *InstallPlan) DeepCopy() *InstallPlan { + if in == nil { + return nil + } + out := new(InstallPlan) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *InstallPlan) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstallPlanCondition) DeepCopyInto(out *InstallPlanCondition) { + *out = *in + in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime) + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallPlanCondition. +func (in *InstallPlanCondition) DeepCopy() *InstallPlanCondition { + if in == nil { + return nil + } + out := new(InstallPlanCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstallPlanList) DeepCopyInto(out *InstallPlanList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]InstallPlan, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallPlanList. +func (in *InstallPlanList) DeepCopy() *InstallPlanList { + if in == nil { + return nil + } + out := new(InstallPlanList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *InstallPlanList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstallPlanReference) DeepCopyInto(out *InstallPlanReference) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallPlanReference. +func (in *InstallPlanReference) DeepCopy() *InstallPlanReference { + if in == nil { + return nil + } + out := new(InstallPlanReference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstallPlanSpec) DeepCopyInto(out *InstallPlanSpec) { + *out = *in + if in.ClusterServiceVersionNames != nil { + in, out := &in.ClusterServiceVersionNames, &out.ClusterServiceVersionNames + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallPlanSpec. +func (in *InstallPlanSpec) DeepCopy() *InstallPlanSpec { + if in == nil { + return nil + } + out := new(InstallPlanSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstallPlanStatus) DeepCopyInto(out *InstallPlanStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]InstallPlanCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.CatalogSources != nil { + in, out := &in.CatalogSources, &out.CatalogSources + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Plan != nil { + in, out := &in.Plan, &out.Plan + *out = make([]*Step, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(Step) + **out = **in + } + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallPlanStatus. +func (in *InstallPlanStatus) DeepCopy() *InstallPlanStatus { + if in == nil { + return nil + } + out := new(InstallPlanStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Maintainer) DeepCopyInto(out *Maintainer) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Maintainer. +func (in *Maintainer) DeepCopy() *Maintainer { + if in == nil { + return nil + } + out := new(Maintainer) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NamedInstallStrategy) DeepCopyInto(out *NamedInstallStrategy) { + *out = *in + if in.StrategySpecRaw != nil { + in, out := &in.StrategySpecRaw, &out.StrategySpecRaw + *out = make(json.RawMessage, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NamedInstallStrategy. +func (in *NamedInstallStrategy) DeepCopy() *NamedInstallStrategy { + if in == nil { + return nil + } + out := new(NamedInstallStrategy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorGroup) DeepCopyInto(out *OperatorGroup) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorGroup. +func (in *OperatorGroup) DeepCopy() *OperatorGroup { + if in == nil { + return nil + } + out := new(OperatorGroup) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OperatorGroup) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorGroupList) DeepCopyInto(out *OperatorGroupList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OperatorGroup, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorGroupList. +func (in *OperatorGroupList) DeepCopy() *OperatorGroupList { + if in == nil { + return nil + } + out := new(OperatorGroupList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OperatorGroupList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorGroupSpec) DeepCopyInto(out *OperatorGroupSpec) { + *out = *in + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.TargetNamespaces != nil { + in, out := &in.TargetNamespaces, &out.TargetNamespaces + *out = make([]string, len(*in)) + copy(*out, *in) + } + in.ServiceAccount.DeepCopyInto(&out.ServiceAccount) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorGroupSpec. +func (in *OperatorGroupSpec) DeepCopy() *OperatorGroupSpec { + if in == nil { + return nil + } + out := new(OperatorGroupSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorGroupStatus) DeepCopyInto(out *OperatorGroupStatus) { + *out = *in + if in.Namespaces != nil { + in, out := &in.Namespaces, &out.Namespaces + *out = make([]string, len(*in)) + copy(*out, *in) + } + in.LastUpdated.DeepCopyInto(&out.LastUpdated) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorGroupStatus. +func (in *OperatorGroupStatus) DeepCopy() *OperatorGroupStatus { + if in == nil { + return nil + } + out := new(OperatorGroupStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RegistryServiceStatus) DeepCopyInto(out *RegistryServiceStatus) { + *out = *in + in.CreatedAt.DeepCopyInto(&out.CreatedAt) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RegistryServiceStatus. +func (in *RegistryServiceStatus) DeepCopy() *RegistryServiceStatus { + if in == nil { + return nil + } + out := new(RegistryServiceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RequirementStatus) DeepCopyInto(out *RequirementStatus) { + *out = *in + if in.Dependents != nil { + in, out := &in.Dependents, &out.Dependents + *out = make([]DependentStatus, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RequirementStatus. +func (in *RequirementStatus) DeepCopy() *RequirementStatus { + if in == nil { + return nil + } + out := new(RequirementStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SpecDescriptor) DeepCopyInto(out *SpecDescriptor) { + *out = *in + if in.XDescriptors != nil { + in, out := &in.XDescriptors, &out.XDescriptors + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Value != nil { + in, out := &in.Value, &out.Value + *out = new(json.RawMessage) + if **in != nil { + in, out := *in, *out + *out = make([]byte, len(*in)) + copy(*out, *in) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpecDescriptor. +func (in *SpecDescriptor) DeepCopy() *SpecDescriptor { + if in == nil { + return nil + } + out := new(SpecDescriptor) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StatusDescriptor) DeepCopyInto(out *StatusDescriptor) { + *out = *in + if in.XDescriptors != nil { + in, out := &in.XDescriptors, &out.XDescriptors + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Value != nil { + in, out := &in.Value, &out.Value + *out = new(json.RawMessage) + if **in != nil { + in, out := *in, *out + *out = make([]byte, len(*in)) + copy(*out, *in) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StatusDescriptor. +func (in *StatusDescriptor) DeepCopy() *StatusDescriptor { + if in == nil { + return nil + } + out := new(StatusDescriptor) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Step) DeepCopyInto(out *Step) { + *out = *in + out.Resource = in.Resource + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Step. +func (in *Step) DeepCopy() *Step { + if in == nil { + return nil + } + out := new(Step) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StepResource) DeepCopyInto(out *StepResource) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StepResource. +func (in *StepResource) DeepCopy() *StepResource { + if in == nil { + return nil + } + out := new(StepResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Subscription) DeepCopyInto(out *Subscription) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.Spec != nil { + in, out := &in.Spec, &out.Spec + *out = new(SubscriptionSpec) + **out = **in + } + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Subscription. +func (in *Subscription) DeepCopy() *Subscription { + if in == nil { + return nil + } + out := new(Subscription) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Subscription) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriptionCatalogHealth) DeepCopyInto(out *SubscriptionCatalogHealth) { + *out = *in + if in.CatalogSourceRef != nil { + in, out := &in.CatalogSourceRef, &out.CatalogSourceRef + *out = new(corev1.ObjectReference) + **out = **in + } + if in.LastUpdated != nil { + in, out := &in.LastUpdated, &out.LastUpdated + *out = (*in).DeepCopy() + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionCatalogHealth. +func (in *SubscriptionCatalogHealth) DeepCopy() *SubscriptionCatalogHealth { + if in == nil { + return nil + } + out := new(SubscriptionCatalogHealth) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriptionCondition) DeepCopyInto(out *SubscriptionCondition) { + *out = *in + if in.LastHeartbeatTime != nil { + in, out := &in.LastHeartbeatTime, &out.LastHeartbeatTime + *out = (*in).DeepCopy() + } + if in.LastTransitionTime != nil { + in, out := &in.LastTransitionTime, &out.LastTransitionTime + *out = (*in).DeepCopy() + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionCondition. +func (in *SubscriptionCondition) DeepCopy() *SubscriptionCondition { + if in == nil { + return nil + } + out := new(SubscriptionCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriptionList) DeepCopyInto(out *SubscriptionList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Subscription, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionList. +func (in *SubscriptionList) DeepCopy() *SubscriptionList { + if in == nil { + return nil + } + out := new(SubscriptionList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SubscriptionList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriptionSpec) DeepCopyInto(out *SubscriptionSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionSpec. +func (in *SubscriptionSpec) DeepCopy() *SubscriptionSpec { + if in == nil { + return nil + } + out := new(SubscriptionSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriptionStatus) DeepCopyInto(out *SubscriptionStatus) { + *out = *in + if in.Install != nil { + in, out := &in.Install, &out.Install + *out = new(InstallPlanReference) + **out = **in + } + if in.InstallPlanRef != nil { + in, out := &in.InstallPlanRef, &out.InstallPlanRef + *out = new(corev1.ObjectReference) + **out = **in + } + if in.CatalogHealth != nil { + in, out := &in.CatalogHealth, &out.CatalogHealth + *out = make([]SubscriptionCatalogHealth, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]SubscriptionCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.LastUpdated.DeepCopyInto(&out.LastUpdated) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionStatus. +func (in *SubscriptionStatus) DeepCopy() *SubscriptionStatus { + if in == nil { + return nil + } + out := new(SubscriptionStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/lib/version/version.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/lib/version/version.go new file mode 100644 index 0000000000..51e1fac659 --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/lib/version/version.go @@ -0,0 +1,66 @@ +package version + +import ( + "encoding/json" + + "github.com/blang/semver" +) + +// +k8s:openapi-gen=true +// OperatorVersion is a wrapper around semver.Version which supports correct +// marshaling to YAML and JSON. +type OperatorVersion struct { + semver.Version +} + +// DeepCopyInto creates a deep-copy of the Version value. +func (v *OperatorVersion) DeepCopyInto(out *OperatorVersion) { + out.Major = v.Major + out.Minor = v.Minor + out.Patch = v.Patch + + if v.Pre != nil { + pre := make([]semver.PRVersion, len(v.Pre)) + copy(pre, v.Pre) + out.Pre = pre + } + + if v.Build != nil { + build := make([]string, len(v.Build)) + copy(build, v.Build) + out.Build = build + } +} + +// MarshalJSON implements the encoding/json.Marshaler interface. +func (v OperatorVersion) MarshalJSON() ([]byte, error) { + return json.Marshal(v.String()) +} + +// UnmarshalJSON implements the encoding/json.Unmarshaler interface. +func (v *OperatorVersion) UnmarshalJSON(data []byte) (err error) { + var versionString string + + if err = json.Unmarshal(data, &versionString); err != nil { + return + } + + version := semver.Version{} + version, err = semver.ParseTolerant(versionString) + if err != nil { + return err + } + v.Version = version + return +} + +// OpenAPISchemaType is used by the kube-openapi generator when constructing +// the OpenAPI spec of this type. +// +// See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators +func (_ OperatorVersion) OpenAPISchemaType() []string { return []string{"string"} } + +// OpenAPISchemaFormat is used by the kube-openapi generator when constructing +// the OpenAPI spec of this type. +// "semver" is not a standard openapi format but tooling may use the value regardless +func (_ OperatorVersion) OpenAPISchemaFormat() string { return "semver" } diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/lib/version/version_test.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/lib/version/version_test.go new file mode 100644 index 0000000000..e6c14f7b48 --- /dev/null +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/lib/version/version_test.go @@ -0,0 +1,77 @@ +package version + +import ( + "encoding/json" + "testing" + + "github.com/blang/semver" + "github.com/stretchr/testify/require" +) + +func TestOperatorVersionMarshal(t *testing.T) { + tests := []struct { + name string + in OperatorVersion + out []byte + err error + }{ + { + name: "MMP", + in: OperatorVersion{semver.MustParse("1.2.3")}, + out: []byte(`"1.2.3"`), + }, + { + name: "empty", + in: OperatorVersion{semver.Version{}}, + out: []byte(`"0.0.0"`), + }, + { + name: "with-timestamp", + in: OperatorVersion{semver.MustParse("1.2.3-1556715351")}, + out: []byte(`"1.2.3-1556715351"`), + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + m, err := tt.in.MarshalJSON() + require.Equal(t, tt.out, m, string(m)) + require.Equal(t, tt.err, err) + }) + } +} + +func TestOperatorVersionUnmarshal(t *testing.T) { + type TestStruct struct { + Version OperatorVersion `json:"v"` + } + tests := []struct { + name string + in []byte + out TestStruct + err error + }{ + { + name: "MMP", + in: []byte(`{"v": "1.2.3"}`), + out: TestStruct{Version: OperatorVersion{semver.MustParse("1.2.3")}}, + }, + { + name: "empty", + in: []byte(`{"v": "0.0.0"}`), + out: TestStruct{Version: OperatorVersion{semver.Version{Major: 0, Minor: 0, Patch: 0}}}, + }, + { + name: "with-timestamp", + in: []byte(`{"v": "1.2.3-1556715351"}`), + out: TestStruct{OperatorVersion{semver.MustParse("1.2.3-1556715351")}}, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + s := TestStruct{} + err := json.Unmarshal(tt.in, &s) + require.Equal(t, tt.out, s) + require.Equal(t, tt.err, err) + }) + } +}