From 3115316ee01f8b5aa12bf8427c6c929270f2de45 Mon Sep 17 00:00:00 2001 From: Dale Haiducek <19750917+dhaiducek@users.noreply.github.com> Date: Wed, 13 Sep 2023 11:09:31 -0400 Subject: [PATCH] Update Make commands for Mac Signed-off-by: Dale Haiducek <19750917+dhaiducek@users.noreply.github.com> --- Makefile | 102 ++++++++++++++++++++++++++----------------------------- 1 file changed, 48 insertions(+), 54 deletions(-) diff --git a/Makefile b/Makefile index dec7d51c..d80419e4 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,16 @@ REPLACES_VERSION ?= 0.2.1 LOCAL_BIN ?= $(PWD)/ci-tools/bin export PATH := $(LOCAL_BIN):$(PATH) +# Detect the OS to set per-OS defaults +GOOS := $(shell go env GOOS) +GOARCH := $(shell go env GOARCH) + +# Fix sed issues on mac by using GSED and fix base64 issues on macos by omitting the -w 0 parameter +SED="sed" +ifeq ($(GOOS), darwin) + SED="gsed" +endif + get-replaces-version: @echo $(REPLACES_VERSION) @@ -20,7 +30,7 @@ get-replaces-version: # - use environment variables to overwrite this value (e.g export CHANNELS="candidate,fast,stable") CHANNELS ?= 3.11 ifneq ($(origin CHANNELS), undefined) -BUNDLE_CHANNELS := --channels=$(CHANNELS) + BUNDLE_CHANNELS := --channels=$(CHANNELS) endif # DEFAULT_CHANNEL defines the default channel used in the bundle. @@ -30,7 +40,7 @@ endif # - use environment variables to overwrite this value (e.g export DEFAULT_CHANNEL="stable") DEFAULT_CHANNEL ?= 3.11 ifneq ($(origin DEFAULT_CHANNEL), undefined) -BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL) + BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL) endif BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) # Option to use podman or docker @@ -57,9 +67,9 @@ ENVTEST_K8S_VERSION = 1.21 # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) ifeq (,$(shell go env GOBIN)) -GOBIN=$(shell go env GOPATH)/bin + GOBIN=$(shell go env GOPATH)/bin else -GOBIN=$(shell go env GOBIN) + GOBIN=$(shell go env GOBIN) endif # Setting SHELL to bash allows bash commands to be executed by recipes. @@ -87,6 +97,9 @@ all: build help: ## Display this help. @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) +clean: ## Clean up build artifacts. + rm $(LOCAL_BIN)/* + ##@ Development CONTROLLER_GEN = $(LOCAL_BIN)/controller-gen @@ -232,14 +245,14 @@ deploy-olm: .PHONY: deploy-using-olm deploy-using-olm: - sed -i 's#quay.io/gatekeeper/gatekeeper-operator-bundle-index:latest#$(BUNDLE_INDEX_IMG)#g' config/olm-install/install-resources.yaml - sed -i 's#mygatekeeper#$(NAMESPACE)#g' config/olm-install/install-resources.yaml - sed -i 's#channel: stable#channel: $(DEFAULT_CHANNEL)#g' config/olm-install/install-resources.yaml + $(SED) -i 's#quay.io/gatekeeper/gatekeeper-operator-bundle-index:latest#$(BUNDLE_INDEX_IMG)#g' config/olm-install/install-resources.yaml + $(SED) -i 's#mygatekeeper#$(NAMESPACE)#g' config/olm-install/install-resources.yaml + $(SED) -i 's#channel: stable#channel: $(DEFAULT_CHANNEL)#g' config/olm-install/install-resources.yaml $(KUSTOMIZE) build config/olm-install | kubectl apply -f - .PHONY: patch-image patch-image: ## Patches the manager's image pull policy to be IfNotPresent. - sed -i 's/imagePullPolicy: Always/imagePullPolicy: IfNotPresent/g' config/manager/manager.yaml + $(SED) -i 's/imagePullPolicy: Always/imagePullPolicy: IfNotPresent/g' config/manager/manager.yaml .PHONY: controller-gen controller-gen: ## Download controller-gen locally if necessary. @@ -268,16 +281,16 @@ bundle: operator-sdk manifests kustomize ## Generate bundle manifests and metada cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG) VERSION=$(VERSION) ;\ $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version $${VERSION/v/} $(BUNDLE_METADATA_OPTS) - sed -i 's/base64data: \"\"/base64data: \"PHN2ZyBpZD0iZjc0ZTM5ZDEtODA2Yy00M2E0LTgyZGQtZjM3ZjM1NWQ4YWYzIiBkYXRhLW5hbWU9Ikljb24iIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDM2IDM2Ij4KICA8ZGVmcz4KICAgIDxzdHlsZT4KICAgICAgLmE0MWM1MjM0LWExNGEtNGYzZC05MTYwLTQ0NzJiNzZkMDA0MCB7CiAgICAgICAgZmlsbDogI2UwMDsKICAgICAgfQogICAgPC9zdHlsZT4KICA8L2RlZnM+CiAgPGc+CiAgICA8cGF0aCBjbGFzcz0iYTQxYzUyMzQtYTE0YS00ZjNkLTkxNjAtNDQ3MmI3NmQwMDQwIiBkPSJNMjUsMTcuMzhIMjMuMjNhNS4yNyw1LjI3LDAsMCwwLTEuMDktMi42NGwxLjI1LTEuMjVhLjYyLjYyLDAsMSwwLS44OC0uODhsLTEuMjUsMS4yNWE1LjI3LDUuMjcsMCwwLDAtMi42NC0xLjA5VjExYS42Mi42MiwwLDEsMC0xLjI0LDB2MS43N2E1LjI3LDUuMjcsMCwwLDAtMi42NCwxLjA5bC0xLjI1LTEuMjVhLjYyLjYyLDAsMCwwLS44OC44OGwxLjI1LDEuMjVhNS4yNyw1LjI3LDAsMCwwLTEuMDksMi42NEgxMWEuNjIuNjIsMCwwLDAsMCwxLjI0aDEuNzdhNS4yNyw1LjI3LDAsMCwwLDEuMDksMi42NGwtMS4yNSwxLjI1YS42MS42MSwwLDAsMCwwLC44OC42My42MywwLDAsMCwuODgsMGwxLjI1LTEuMjVhNS4yNyw1LjI3LDAsMCwwLDIuNjQsMS4wOVYyNWEuNjIuNjIsMCww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MTYwLTQ0NzJiNzZkMDA0MCIgZD0iTTksMTAuNjJBLjYyLjYyLDAsMCwxLDguMzgsMTBWNy42Mkg2QS42Mi42MiwwLDAsMSw2LDYuMzhIOUEuNjIuNjIsMCwwLDEsOS42Miw3djNBLjYyLjYyLDAsMCwxLDksMTAuNjJaIi8+CiAgPC9nPgo8L3N2Zz4K\"/g' bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml - sed -i 's/mediatype: \"\"/mediatype: \"image\/svg+xml\"/g' bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml - sed -i 's/^ version:.*/ version: $(VERSION)/' bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml - sed -i '/^ createdAt:.*/d' bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml - sed -i 's/$(CHANNELS)/"$(CHANNELS)"/g' bundle/metadata/annotations.yaml -ifneq ($(REPLACES_VERSION), none) - sed -i 's/^ replaces:.*/ replaces: gatekeeper-operator.v$(REPLACES_VERSION)/' bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml -else - sed -i 's/^ replaces:.*/ # replaces: none/' bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml -endif + $(SED) -i 's/base64data: \"\"/base64data: \"PHN2ZyBpZD0iZjc0ZTM5ZDEtODA2Yy00M2E0LTgyZGQtZjM3ZjM1NWQ4YWYzIiBkYXRhLW5hbWU9Ikljb24iIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDM2IDM2Ij4KICA8ZGVmcz4KICAgIDxzdHlsZT4KICAgICAgLmE0MWM1MjM0LWExNGEtNGYzZC05MTYwLTQ0NzJiNzZkMDA0MCB7CiAgICAgICAgZmlsbDogI2UwMDsKICAgICAgfQogICAgPC9zdHlsZT4KICA8L2RlZnM+CiAgPGc+CiAgICA8cGF0aCBjbGFzcz0iYTQxYzUyMzQtYTE0YS00ZjNkLTkxNjAtNDQ3MmI3NmQwMDQwIiBkPSJNMjUsM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yLjYyLDAsMCwxLDAsMS4yNFoiLz4KICAgIDxwYXRoIGNsYXNzPSJhNDFjNTIzNC1hMTRhLTRmM2QtOTE2MC00NDcyYjc2ZDAwNDAiIGQ9Ik03LDMwLjYyQS42Mi42MiwwLDAsMSw2LjM4LDMwVjI3QS42Mi42MiwwLDAsMSw3LDI2LjM4aDNhLjYyLjYyLDAsMCwxLDAsMS4yNEg3LjYyVjMwQS42Mi42MiwwLDAsMSw3LDMwLjYyWiIvPgogICAgPHBhdGggY2xhc3M9ImE0MWM1MjM0LWExNGEtNGYzZC05MTYwLTQ0NzJiNzZkMDA0MCIgZD0iTTI5LDkuNjJIMjZhLjYyLjYyLDAsMCwxLDAtMS4yNGgyLjM4VjZhLjYyLjYyLDAsMCwxLDEuMjQsMFY5QS42Mi42MiwwLDAsMSwyOSw5LjYyWiIvPgogICAgPHBhdGggY2xhc3M9ImE0MWM1MjM0LWExNGEtNGYzZC05MTYwLTQ0NzJiNzZkMDA0MCIgZD0iTTksMTAuNjJBLjYyLjYyLDAsMCwxLDguMzgsMTBWNy42Mkg2QS42Mi42MiwwLDAsMSw2LDYuMzhIOUEuNjIuNjIsMCwwLDEsOS42Miw3djNBLjYyLjYyLDAsMCwxLDksMTAuNjJaIi8+CiAgPC9nPgo8L3N2Zz4K\"/g' bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml + $(SED) -i 's/mediatype: \"\"/mediatype: \"image\/svg+xml\"/g' bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml + $(SED) -i 's/^ version:.*/ version: $(VERSION)/' bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml + $(SED) -i '/^ createdAt:.*/d' bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml + $(SED) -i 's/$(CHANNELS)/"$(CHANNELS)"/g' bundle/metadata/annotations.yaml + ifneq ($(REPLACES_VERSION), none) + $(SED) -i 's/^ replaces:.*/ replaces: gatekeeper-operator.v$(REPLACES_VERSION)/' bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml + else + $(SED) -i 's/^ replaces:.*/ # replaces: none/' bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml + endif $(OPERATOR_SDK) bundle validate ./bundle # Requires running cluster (for example through 'make test-cluster') @@ -293,22 +306,15 @@ bundle-build: ## Build the bundle image. bundle-push: ## Push the bundle image. $(MAKE) docker-push IMG=$(BUNDLE_IMG) -.PHONY: opm OPM = $(LOCAL_BIN)/opm -opm: ## Download opm locally if necessary. -ifeq (,$(wildcard $(OPM))) -ifeq (,$(shell which opm 2>/dev/null)) - @{ \ - set -e ;\ - mkdir -p $(dir $(OPM)) ;\ - OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \ - curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/$(OPM_VERSION)/$${OS}-$${ARCH}-opm ;\ - chmod +x $(OPM) ;\ - } -else -OPM = $(shell which opm) -endif -endif + +.PHONY: opm +opm: $(OPM) + +$(OPM): + mkdir -p $(@D) + curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/$(OPM_VERSION)/$(GOOS)-$(GOARCH)-opm + chmod +x $(OPM) # Path used to import Gatekeeper manifests. For example, this could be a local # file system directory if kustomize has errors using the GitHub URL. See @@ -358,7 +364,7 @@ CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:$(VERSION) # Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image. ifneq ($(origin CATALOG_BASE_IMG), undefined) -FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG) + FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG) endif # Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'. @@ -373,30 +379,18 @@ catalog-build: opm ## Build a catalog image. catalog-push: ## Push a catalog image. $(MAKE) docker-push IMG=$(CATALOG_IMG) -# Detect the OS to set per-OS defaults -OS_NAME = $(shell uname -s) # operator-sdk variables # ====================== OPERATOR_SDK_VERSION ?= v1.28.1 -ifeq ($(OS_NAME), Linux) - OPERATOR_SDK_URL=https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk_linux_amd64 -else ifeq ($(OS_NAME), Darwin) - OPERATOR_SDK_URL=https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk_darwin_amd64 -endif - -# Get the current operator-sdk binary. If there isn't any, we'll use the -# GOBIN path -ifeq (, $(shell which operator-sdk)) -OPERATOR_SDK=$(GOBIN)/operator-sdk -else -OPERATOR_SDK=$(shell which operator-sdk) -endif +OPERATOR_SDK = $(LOCAL_BIN)/operator-sdk +OPERATOR_SDK_URL := https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk_$(GOOS)_$(GOARCH) .PHONY: operator-sdk operator-sdk: $(OPERATOR_SDK) $(OPERATOR_SDK): - curl -L $(OPERATOR_SDK_URL) -o $(OPERATOR_SDK) || (echo "curl returned $$? trying to fetch operator-sdk. Please install operator-sdk and try again"; exit 1) + mkdir -p $(@D) + curl -L $(OPERATOR_SDK_URL) -o $(OPERATOR_SDK) || (echo "curl returned $$? trying to fetch operator-sdk"; exit 1) chmod +x $(OPERATOR_SDK) # Current Gatekeeper version @@ -421,11 +415,11 @@ BUILDDATE = $(shell date -u +'%Y-%m-%dT%H:%M:%SZ') GIT_TREESTATE = "clean" DIFF = $(shell git diff --quiet >/dev/null 2>&1; if [ $$? -eq 1 ]; then echo "1"; fi) ifeq ($(DIFF), 1) - GIT_TREESTATE = "dirty" + GIT_TREESTATE = "dirty" endif VERSION_PKG = "github.com/gatekeeper/gatekeeper-operator/pkg/version" LDFLAGS = "-X $(VERSION_PKG).gitVersion=$(GIT_VERSION) \ - -X $(VERSION_PKG).gitCommit=$(GIT_HASH) \ - -X $(VERSION_PKG).gitTreeState=$(GIT_TREESTATE) \ - -X $(VERSION_PKG).buildDate=$(BUILDDATE)" + -X $(VERSION_PKG).gitCommit=$(GIT_HASH) \ + -X $(VERSION_PKG).gitTreeState=$(GIT_TREESTATE) \ + -X $(VERSION_PKG).buildDate=$(BUILDDATE)"