Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENTESB-18466: Introduces control of OLM upgradeability using OLM OperatorCondition flag #9913

Merged
merged 6 commits into from Feb 25, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions install/operator/.gitignore
Expand Up @@ -11,3 +11,5 @@ before_launch.sh
**/*.gen.yaml
**/release/*-installer*
**/bundle
**/catalog
**/catalog.Dockerfile
47 changes: 36 additions & 11 deletions install/operator/.lib.sh
Expand Up @@ -267,19 +267,44 @@ build_image()
}

openapi_gen() {
if hash openapi-gen 2>/dev/null; then
openapi-gen --logtostderr=true -o "" \
-i ./pkg/apis/syndesis/v1alpha1 -O zz_generated.openapi -p ./pkg/apis/syndesis/v1alpha1
if ! command -v openapi-gen &> /dev/null
then
echo "Downloading and installing openapi-gen ..."
go install k8s.io/kube-openapi/cmd/openapi-gen@release-1.22
if [ $? != 0 ]; then
echo "Error: Failed to install openapi-gen"
exit 1
fi
else
echo "Warning: openapi-gen already installed but cannot guarantee if its version is compatible."
echo " To ensure compatibility, please set aside the current version."
fi

openapi-gen --logtostderr=true -o "" \
-i ./pkg/apis/syndesis/v1beta1 -O zz_generated.openapi -p ./pkg/apis/syndesis/v1beta1
openapi-gen --logtostderr=true -o "" \
-i ./pkg/apis/syndesis/v1alpha1 -O zz_generated.openapi -p ./pkg/apis/syndesis/v1alpha1
if [ $? != 0 ]; then
echo "Error: openapi-gen failed to generate the API"
exit 1
fi

openapi-gen --logtostderr=true -o "" \
-i ./pkg/apis/syndesis/v1beta2 -O zz_generated.openapi -p ./pkg/apis/syndesis/v1beta2
openapi-gen --logtostderr=true -o "" \
-i ./pkg/apis/syndesis/v1beta1 -O zz_generated.openapi -p ./pkg/apis/syndesis/v1beta1
if [ $? != 0 ]; then
echo "Error: openapi-gen failed to generate the API"
exit 1
fi

openapi-gen --logtostderr=true -o "" \
-i ./pkg/apis/syndesis/v1beta3 -O zz_generated.openapi -p ./pkg/apis/syndesis/v1beta3
else
echo "skipping go openapi generation"
openapi-gen --logtostderr=true -o "" \
-i ./pkg/apis/syndesis/v1beta2 -O zz_generated.openapi -p ./pkg/apis/syndesis/v1beta2
if [ $? != 0 ]; then
echo "Error: openapi-gen failed to generate the API"
exit 1
fi

openapi-gen --logtostderr=true -o "" \
-i ./pkg/apis/syndesis/v1beta3 -O zz_generated.openapi -p ./pkg/apis/syndesis/v1beta3
if [ $? != 0 ]; then
echo "Error: openapi-gen failed to generate the API"
exit 1
fi
}
39 changes: 36 additions & 3 deletions install/operator/config/Makefile
Expand Up @@ -183,6 +183,24 @@ else
KUSTOMIZE=$(shell which kustomize)
endif

opm:
ifeq (, $(shell which opm))
@{ \
set -e ;\
OPM_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$OPM_GEN_TMP_DIR ;\
go mod init tmp ;\
go get \
-ldflags '-w -extldflags "-static"' -tags "json1" \
-ldflags "-X '$(OPM_PKG)/cmd/opm/version.opmVersion=$(OPM_VERSION)' -X '$(OPM_PKG)/cmd/opm/version.buildDate=$(BUILD_TIME)'" \
$(OPM_PKG)/cmd/opm@$(OPM_VERSION) ;\
rm -rf $$OPM_GEN_TMP_DIR ;\
}
OPM=$(GOBIN)/opm
else
OPM=$(shell which opm)
endif

operator-sdk:
ifeq (, $(shell which operator-sdk))
@{ \
Expand All @@ -198,7 +216,7 @@ else
OPERATOR_SDK=$(shell which operator-sdk)
endif

.PHONY: kustomize operator-sdk bundle manifests generate generate-deepcopy generate-crds
.PHONY: kustomize opm operator-sdk bundle manifests generate generate-deepcopy generate-crds

generate-deepcopy: controller-gen
@$(CONTROLLER_GEN) paths="$(PKG)/..." object
Expand Down Expand Up @@ -258,9 +276,14 @@ bundle: generate-crds operator-sdk kustomize pre-bundle
# Add a timestamp to the new bundle manifest
@sed -i '/^ containerImage: .*/ a \ \ \ \ createdAt: $(TIMESTAMP)' $(BUNDLE_DIR)/$(MANIFESTS)/$(CSV_FILENAME)
# Removes any clusterrolebindings necessary for clusterroles to be added but not required for the manifests
@rm -f $(BUNDLE_DIR)/manifests/*clusterrolebinding.yaml
@rm -f $(BUNDLE_DIR)/$(MANIFESTS)/*clusterrolebinding.yaml
# Workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1934080
@rm -f $(BUNDLE_DIR)/manifests/*serviceaccount.yaml
@rm -f $(BUNDLE_DIR)/$(MANIFESTS)/*serviceaccount.yaml
# Workaround for extra cluster roles required to be present
# The operator looks to install ClusterRoleBindings to these cluster roles
# Without them, the operator installation does not finish
@cp -rf $(ROLE)/$(CLUSTER_ROLE_KAFKA).gen.yaml $(BUNDLE_DIR)/$(MANIFESTS)/$(CLUSTER_ROLE_KAFKA).yaml
@cp -rf $(ROLE)/$(CLUSTER_ROLE_PUBLIC_API).gen.yaml $(BUNDLE_DIR)/$(MANIFESTS)/$(CLUSTER_ROLE_PUBLIC_API).yaml
# Moves the docker file into the bundle directory
@mv bundle.Dockerfile $(BUNDLE_DIR)/Dockerfile && \
sed -i 's/bundle\///g' $(BUNDLE_DIR)/Dockerfile
Expand All @@ -271,6 +294,16 @@ bundle: generate-crds operator-sdk kustomize pre-bundle
bundle-build: bundle
cd bundle && docker build -f Dockerfile -t $(BUNDLE_IMG) .

.PHONY: bundle-push
bundle-push: bundle-build
docker push $(BUNDLE_IMG)

.PHONY: test-catalog
test-catalog: opm bundle-push
SRC_CATALOG=$(SRC_CATALOG) CATALOG_DIR=$(CATALOG) PACKAGE=$(PACKAGE) \
OPM=$(OPM) BUNDLE_IMAGE=$(BUNDLE_IMG) CSV_NAME=$(CSV_NAME) \
CSV_REPLACES=$(CSV_REPLACES) CHANNEL=$(DEFAULT_CHANNEL)-$(VERSION) ./script/build-catalog.sh

clean:
@find . -name "*.gen.*" -delete
ifneq ($(CSV_PATH), $(DEFAULT_CSV))
Expand Down