Skip to content

Commit

Permalink
Use container-build-community target for CI
Browse files Browse the repository at this point in the history
We reuglarly push the community version for K8s to quay/medik8s
  • Loading branch information
razo7 committed May 22, 2023
1 parent 5924254 commit 8ce92a2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/post-submit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ jobs:

- name: Build and push operator and bundle images, using version 0.0.1, for pushes to main
if: ${{ github.ref_type != 'tag' }}
run: make container-build container-push
run: make container-build-community container-push

- name: Build and push versioned CSV and images, for tags
if: ${{ github.ref_type == 'tag' }}
# remove leading 'v' from tag!
run: export VERSION=$(echo $GITHUB_REF_NAME | sed 's/v//') && make container-build container-push
run: export VERSION=$(echo $GITHUB_REF_NAME | sed 's/v//') && make container-build-community container-push

- name: Build and push index image with versioned NHC + SNR images
if: ${{ github.ref_type != 'tag' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-submit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ jobs:
run: make test

- name: Test container build
run: make container-build-check
run: make container-build-community
29 changes: 19 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,14 @@ run: manifests generate fmt vet ## Run a controller from your host.
docker-build: test
docker build -t ${IMG} .

.PHONY: docker--build-check
.PHONY: docker-build-check
docker-build-check: check
docker build -t ${IMG} .

.PHONY: bundle-build-community
bundle-build-community: bundle-community-k8s ## Run bundle community changes in CSV, and then build the bundle image.
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
docker push ${IMG}
Expand Down Expand Up @@ -263,6 +267,7 @@ endef

DEFAULT_ICON_BASE64 := $(shell base64 --wrap=0 ./config/assets/snr_icon_blue.png)
export ICON_BASE64 ?= ${DEFAULT_ICON_BASE64}
export BUNDLE_CSV ?= "./bundle/manifests/$(OPERATOR_NAME).clusterserviceversion.yaml"
.PHONY: bundle
bundle: manifests operator-sdk kustomize ## Generate bundle manifests and metadata, then validate generated files.
$(OPERATOR_SDK) generate kustomize manifests -q
Expand All @@ -273,22 +278,23 @@ bundle: manifests operator-sdk kustomize ## Generate bundle manifests and metada
.PHONY: bundle-community-k8s
bundle-community-k8s: bundle-community ## Generate bundle manifests and metadata customized to k8s community release, then validate generated files.
# Note that k8s 1.25+ needs PSA label
sed -r -i "s|by default\.|by default.\n Note that prior to installing SNR on a Kubernetes 1.25+ cluster, a user must manually set a [privileged PSA label](https://kubernetes.io/docs/tasks/configure-pod-container/enforce-standards-namespace-labels/) on SNR's namespace. It gives SNR's agents permissions to reboot the node (in case it needs to be remediated).|;" ./bundle/manifests/$(OPERATOR_NAME).clusterserviceversion.yaml
sed -r -i "s|by default\.|by default.\n Note that prior to installing SNR on a Kubernetes 1.25+ cluster, a user must manually set a [privileged PSA label](https://kubernetes.io/docs/tasks/configure-pod-container/enforce-standards-namespace-labels/) on SNR's namespace. It gives SNR's agents permissions to reboot the node (in case it needs to be remediated).|;" ${BUNDLE_CSV}
$(MAKE) bundle-update

.PHONY: bundle-community
bundle-community: bundle ##Add Community Edition suffix to operator name
sed -r -i "s|displayName: Self Node Remediation Operator.*|displayName: Self Node Remediation Operator - Community Edition|;" ./bundle/manifests/$(OPERATOR_NAME).clusterserviceversion.yaml
sed -r -i "s|displayName: Self Node Remediation Operator.*|displayName: Self Node Remediation Operator - Community Edition|;" ${BUNDLE_CSV}

.PHONY: bundle-update
bundle-update: ## Update containerImage, createdAt, skipRange, and icon fields in the bundle's CSV, then validate the bundle directory
# update container image in the metadata
sed -r -i "s|containerImage: .*|containerImage: ${IMG}|;" ./bundle/manifests/$(OPERATOR_NAME).clusterserviceversion.yaml
sed -r -i "s|containerImage: .*|containerImage: ${IMG}|;" ${BUNDLE_CSV}
# set creation date
sed -r -i "s|createdAt: \".*\"|createdAt: \"`date "+%Y-%m-%d %T" `\"|;" ./bundle/manifests/$(OPERATOR_NAME).clusterserviceversion.yaml
sed -r -i "s|createdAt: \".*\"|createdAt: \"`date "+%Y-%m-%d %T" `\"|;" ${BUNDLE_CSV}
# set skipRange
sed -r -i "s|olm.skipRange: .*|olm.skipRange: '>=0.4.0 <${VERSION}'|;" ./bundle/manifests/$(OPERATOR_NAME).clusterserviceversion.yaml
sed -r -i "s|olm.skipRange: .*|olm.skipRange: '>=0.4.0 <${VERSION}'|;" ${BUNDLE_CSV}
# set icon (not version or build date related, but just to not having this huge data permanently in the CSV)
sed -r -i "s|base64data:.*|base64data: ${ICON_BASE64}|;" ./bundle/manifests/$(OPERATOR_NAME).clusterserviceversion.yaml
sed -r -i "s|base64data:.*|base64data: ${ICON_BASE64}|;" ${BUNDLE_CSV}
$(MAKE) bundle-validate

.PHONY: bundle-validate
Expand Down Expand Up @@ -370,16 +376,19 @@ catalog-push: ## Push a catalog image.
$(MAKE) docker-push IMG=$(CATALOG_IMG)

##@ Targets used by CI

.PHONY: check
# WORKAROUND: add "protoc" as dependency for downloading binary first, the golang image misses the needed "unzip"tool
check: protoc ## Dockerized version of make test
$(DOCKER_GO) "make test"

.PHONY: container-build-community
container-build-community: ## Build containers for community
make docker-build-check bundle-build-community

.PHONY: container-build
container-build: docker-build bundle-build ## Build containers

.PHONY: container-build-check
container-build-check: docker-build-check bundle-build ## Build containers

.PHONY: container-push
container-push: ## Push containers (NOTE: catalog can't be build before bundle was pushed)
Expand All @@ -404,7 +413,7 @@ verify-bundle: manifests bundle bundle-reset verify-no-changes ##Verifies bundle
bundle-reset:
VERSION=0.0.1 $(MAKE) manifests bundle
# empty creation date
sed -r -i "s|createdAt: .*|createdAt: \"\"|;" ./bundle/manifests/$(OPERATOR_NAME).clusterserviceversion.yaml
sed -r -i "s|createdAt: .*|createdAt: \"\"|;" ${BUNDLE_CSV}

SORT_IMPORTS = $(shell pwd)/bin/sort-imports
.PHONY: sort-imports
Expand Down

0 comments on commit 8ce92a2

Please sign in to comment.