-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from vshn/fix/tests
Update tests for updated dependencies
- Loading branch information
Showing
21 changed files
with
455 additions
and
1,071 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
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 |
---|---|---|
@@ -1,20 +1,7 @@ | ||
# Current Operator version | ||
VERSION ?= 0.0.2 | ||
# Default bundle image tag | ||
BUNDLE_IMG ?= controller-bundle:$(VERSION) | ||
# Options for 'bundle-build' | ||
ifneq ($(origin CHANNELS), undefined) | ||
BUNDLE_CHANNELS := --channels=$(CHANNELS) | ||
endif | ||
ifneq ($(origin DEFAULT_CHANNEL), undefined) | ||
BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL) | ||
endif | ||
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) | ||
|
||
# Image URL to use all building/pushing image targets | ||
IMG ?= vshn/stardog-userrole-operator:latest | ||
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion) | ||
CRD_OPTIONS ?= "crd:trivialVersions=true" | ||
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. | ||
ENVTEST_K8S_VERSION = 1.24.1 | ||
|
||
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) | ||
ifeq (,$(shell go env GOBIN)) | ||
|
@@ -23,87 +10,134 @@ else | |
GOBIN=$(shell go env GOBIN) | ||
endif | ||
|
||
# Set Shell to bash, otherwise some targets fail with dash/zsh etc. | ||
SHELL := /bin/bash | ||
# 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 | ||
|
||
.PHONY: all | ||
all: build | ||
|
||
# Run tests (see https://sdk.operatorframework.io/docs/building-operators/golang/references/envtest-setup) | ||
ENVTEST_ASSETS_DIR=$(shell pwd)/testbin | ||
integration_test: generate fmt vet manifests | ||
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/master/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 ./... -coverprofile cover.out | ||
##@ General | ||
|
||
.PHONY: dist | ||
dist: | ||
goreleaser release --snapshot --rm-dist --skip-sign | ||
# The help target prints out all targets with their descriptions organized | ||
# beneath their categories. The categories are represented by '##@' and the | ||
# target descriptions by '##'. The awk commands is responsible for reading the | ||
# entire set of makefiles included in this invocation, looking for lines of the | ||
# file as xyz: ## something, and then pretty-format the target and help. Then, | ||
# if there's a line with ##@ something, that gets pretty-printed as a category. | ||
# More info on the usage of ANSI control characters for terminal formatting: | ||
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters | ||
# More info on the awk command: | ||
# http://linuxcommand.org/lc3_adv_awk.php | ||
|
||
.PHONY: help | ||
help: ## Display this help. | ||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\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) | ||
|
||
##@ Development | ||
|
||
.PHONY: manifests | ||
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. | ||
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases | ||
|
||
.PHONY: generate | ||
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. | ||
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." | ||
|
||
.PHONY: fmt | ||
fmt: ## Run go fmt against code. | ||
go fmt ./... | ||
|
||
.PHONY: vet | ||
vet: ## Run go vet against code. | ||
go vet ./... | ||
|
||
.PHONY: test | ||
test: manifests generate fmt vet envtest ## Run tests. | ||
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out | ||
|
||
##@ Build | ||
|
||
.PHONY: build | ||
# Build manager binary | ||
build: generate fmt vet | ||
go build -o bin/stardog-userrole-operator main.go | ||
build: generate fmt vet ## Build manager binary. | ||
go build -o bin/manager main.go | ||
|
||
# Run against the configured Kubernetes cluster in ~/.kube/config | ||
run: generate fmt vet manifests | ||
.PHONY: run | ||
run: manifests generate fmt vet ## Run a controller from your host. | ||
go run ./main.go | ||
|
||
# Install CRDs into a cluster | ||
install: manifests kustomize | ||
.PHONY: docker-build | ||
docker-build: test ## Build docker image with the manager. | ||
docker build -t ${IMG} . | ||
|
||
.PHONY: docker-push | ||
docker-push: ## Push docker image with the manager. | ||
docker push ${IMG} | ||
|
||
##@ Deployment | ||
|
||
ifndef ignore-not-found | ||
ignore-not-found = false | ||
endif | ||
|
||
.PHONY: install | ||
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config. | ||
$(KUSTOMIZE) build config/crd | kubectl apply -f - | ||
|
||
# Uninstall CRDs from a cluster | ||
uninstall: manifests kustomize | ||
$(KUSTOMIZE) build config/crd | kubectl delete -f - | ||
.PHONY: uninstall | ||
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. | ||
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f - | ||
|
||
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config | ||
deploy: manifests kustomize | ||
.PHONY: deploy | ||
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 - | ||
|
||
# Generate manifests e.g. CRD, RBAC etc. | ||
manifests: controller-gen | ||
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases | ||
.PHONY: undeploy | ||
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. | ||
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f - | ||
|
||
# Run go fmt against code | ||
fmt: | ||
go fmt ./... | ||
##@ Build Dependencies | ||
|
||
# Run go vet against code | ||
vet: | ||
go vet ./... | ||
## Location to install dependencies to | ||
LOCALBIN ?= $(shell pwd)/bin | ||
$(LOCALBIN): | ||
mkdir -p $(LOCALBIN) | ||
|
||
lint: fmt vet | ||
@echo 'Check for uncommitted changes ...' | ||
git diff --exit-code | ||
## Tool Binaries | ||
KUSTOMIZE ?= $(LOCALBIN)/kustomize | ||
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen | ||
ENVTEST ?= $(LOCALBIN)/setup-envtest | ||
|
||
# Generate code | ||
generate: controller-gen | ||
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." | ||
## Tool Versions | ||
KUSTOMIZE_VERSION ?= v4.5.7 | ||
CONTROLLER_TOOLS_VERSION ?= v0.9.0 | ||
|
||
# Build the docker image | ||
docker-build: test | ||
docker build . -t ${IMG} | ||
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | ||
.PHONY: kustomize | ||
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. | ||
$(KUSTOMIZE): $(LOCALBIN) | ||
curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN) | ||
|
||
# Push the docker image | ||
docker-push: | ||
docker push ${IMG} | ||
.PHONY: controller-gen | ||
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. | ||
$(CONTROLLER_GEN): $(LOCALBIN) | ||
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION) | ||
|
||
# find or download controller-gen | ||
# download controller-gen if necessary | ||
controller-gen: | ||
ifeq (, $(shell which controller-gen)) | ||
@{ \ | ||
set -e ;\ | ||
go install sigs.k8s.io/controller-tools/cmd/[email protected] ;\ | ||
} | ||
CONTROLLER_GEN=$(GOBIN)/controller-gen | ||
else | ||
CONTROLLER_GEN=$(shell which controller-gen) | ||
endif | ||
.PHONY: envtest | ||
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. | ||
$(ENVTEST): $(LOCALBIN) | ||
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest | ||
|
||
##@ Custom commands | ||
|
||
# find or install autorest | ||
find-autorest: | ||
.PHONY: dist | ||
dist: # release snapshot | ||
goreleaser release --snapshot --rm-dist --skip-sign | ||
|
||
find-autorest: ## find or install autorest | ||
ifeq (, $(shell which autorest)) | ||
@{ \ | ||
set -e ;\ | ||
|
@@ -116,30 +150,6 @@ else | |
AUTOREST=$(shell which autorest) | ||
endif | ||
|
||
autorest: find-autorest | ||
autorest: find-autorest ## build client stub | ||
$(AUTOREST) --go --package-name="github.com/vshn/stardog-userrole-operator/stardogrest" --namespace="stardogrest" --input-file="stardogrest/stardog_swagger.yaml" --output-folder="stardogrest" | ||
go fmt ./... | ||
|
||
kustomize: | ||
ifeq (, $(shell which kustomize)) | ||
@{ \ | ||
set -e ;\ | ||
go install sigs.k8s.io/kustomize/kustomize/[email protected] ;\ | ||
} | ||
KUSTOMIZE=$(GOBIN)/kustomize | ||
else | ||
KUSTOMIZE=$(shell which kustomize) | ||
endif | ||
|
||
# Generate bundle manifests and metadata, then validate generated files. | ||
.PHONY: bundle | ||
bundle: manifests | ||
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) | ||
operator-sdk bundle validate ./bundle | ||
|
||
# Build the bundle image. | ||
.PHONY: bundle-build | ||
bundle-build: | ||
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) . |
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
...le/manifests/stardog-userrole-operator-controller-manager-metrics-service_v1_service.yaml
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
...ardog-userrole-operator-metrics-reader_rbac.authorization.k8s.io_v1beta1_clusterrole.yaml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.