-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70cf5e1
commit 2f1ce45
Showing
11 changed files
with
171 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,16 @@ IMAGE_TAG_BASE ?= stakater/ingressmonitorcontroller | |
# BUNDLE_IMG defines the image:tag used for the bundle. | ||
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>) | ||
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION) | ||
# BUNDLE_GEN_FLAGS are the flags passed to the operator-sdk generate bundle command | ||
BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS) | ||
|
||
# USE_IMAGE_DIGESTS defines if images are resolved via tags or digests | ||
# You can enable this value if you would like to use SHA Based Digests | ||
# To enable set flag to true | ||
USE_IMAGE_DIGESTS ?= false | ||
ifeq ($(USE_IMAGE_DIGESTS), true) | ||
BUNDLE_GEN_FLAGS += --use-image-digests | ||
endif | ||
|
||
# Image URL to use all building/pushing image targets | ||
IMG ?= controller:latest | ||
|
@@ -50,6 +60,12 @@ GOBIN=$(shell go env GOPATH)/bin | |
else | ||
GOBIN=$(shell go env GOBIN) | ||
endif | ||
# Setting SHELL to bash allows bash commands to be executed by recipes. | ||
# This is a requirement for 'setup-envtest.sh' in the test target. | ||
# Options are set to exit when a recipe line exits non-zero or a piped command fails. | ||
SHELL = /usr/bin/env bash -o pipefail | ||
.SHELLFLAGS = -ec | ||
all: build | ||
|
||
all: build | ||
|
||
|
@@ -83,8 +99,13 @@ fmt: ## Run go fmt against code. | |
vet: ## Run go vet against code. | ||
go vet ./... | ||
|
||
## ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. | ||
ENVTEST_ASSETS_DIR = $(shell pwd)/testbin | ||
.PHONY: test | ||
test: generate fmt vet manifests | ||
go test -v ./... -coverprofile cover.out | ||
mkdir -p $(ENVTEST_ASSETS_DIR) | ||
test -f $(ENVTEST_ASSETS_DIR)/setup-envtest.sh || curl -sSLo $(ENVTEST_ASSETS_DIR)/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.6.3/hack/setup-envtest.sh | ||
source $(ENVTEST_ASSETS_DIR)/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -count=1 -coverprofile cover.out | ||
|
||
##@ Build | ||
|
||
|
@@ -100,20 +121,25 @@ docker-build: test ## Build docker image with the manager. | |
docker-push: ## Push docker image with the manager. | ||
docker push ${IMG} | ||
|
||
|
||
ifndef ignore-not-found | ||
ignore-not-found = false | ||
endif | ||
|
||
##@ Deployment | ||
|
||
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config. | ||
$(KUSTOMIZE) build config/crd | kubectl apply -f - | ||
|
||
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. | ||
$(KUSTOMIZE) build config/crd | kubectl delete -f - | ||
$(KUSTOMIZE) build config/crd | kubectl delete -f - --ignore-not-found=$(ignore-not-found) | ||
|
||
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. | ||
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} | ||
$(KUSTOMIZE) build config/default | kubectl apply -f - | ||
|
||
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. | ||
$(KUSTOMIZE) build config/default | kubectl delete -f - | ||
$(KUSTOMIZE) build config/default | kubectl delete -f - --ignore-not-found=$(ignore-not-found) | ||
|
||
|
||
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen | ||
|
@@ -122,7 +148,7 @@ controller-gen: ## Download controller-gen locally if necessary. | |
|
||
KUSTOMIZE = $(shell pwd)/bin/kustomize | ||
kustomize: ## Download kustomize locally if necessary. | ||
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected].4) | ||
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected].7) | ||
|
||
# go-get-tool will 'go get' any package $2 and install it to $1. | ||
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
|
@@ -142,7 +168,7 @@ endef | |
bundle: manifests kustomize ## Generate bundle manifests and metadata, then validate generated files. | ||
operator-sdk generate kustomize manifests -q | ||
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG) | ||
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS) | ||
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle $(BUNDLE_GEN_FLAGS) | ||
operator-sdk bundle validate ./bundle | ||
|
||
.PHONY: bundle-build | ||
|
@@ -208,7 +234,7 @@ bump-chart-operator: | |
sed -i "/^image:/{n;n;s/tag:.*/tag: v$(VERSION)/}" charts/ingressmonitorcontroller/values.yaml | ||
|
||
# Bump Chart | ||
bump-chart: bump-chart-operator | ||
bump-chart: bump-chart-operator | ||
|
||
generate-crds: controller-gen | ||
$(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=charts/ingressmonitorcontroller/crds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
bundle/manifests/ingressmonitorcontroller-controller-manager_v1_serviceaccount.yaml
This file was deleted.
Oops, something went wrong.
51 changes: 36 additions & 15 deletions
51
bundle/manifests/ingressmonitorcontroller.clusterserviceversion.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 6 additions & 3 deletions
9
config/manifests/bases/ingressmonitorcontroller.clusterserviceversion.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.