-
Notifications
You must be signed in to change notification settings - Fork 182
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 #593 from pjbgf/new-kube-flag
Add kubeconfig flags
- Loading branch information
Showing
9 changed files
with
46 additions
and
22 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
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 |
---|---|---|
|
@@ -4,12 +4,20 @@ IMG ?= fluxcd/kustomize-controller:latest | |
CRD_OPTIONS ?= crd:crdVersions=v1 | ||
SOURCE_VER ?= v0.22.3 | ||
|
||
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) | ||
# Use the same version of SOPS already referenced on go.mod | ||
SOPS_VER := $(shell go list -m all | grep go.mozilla.org/sops | awk '{print $$2}') | ||
|
||
# Repository root based on Git metadata | ||
REPOSITORY_ROOT := $(shell git rev-parse --show-toplevel) | ||
BUILD_DIR := $(REPOSITORY_ROOT)/build | ||
|
||
# If gobin not set, create one on ./build and add to path. | ||
ifeq (,$(shell go env GOBIN)) | ||
GOBIN=$(shell go env GOPATH)/bin | ||
GOBIN=$(BUILD_DIR)/gobin | ||
else | ||
GOBIN=$(shell go env GOBIN) | ||
endif | ||
export PATH:=$(GOBIN):${PATH} | ||
|
||
# Allows for defining additional Go test args, e.g. '-tags integration'. | ||
GO_TEST_ARGS ?= | ||
|
@@ -25,20 +33,24 @@ ENVTEST_ARCH ?= amd64 | |
all: manager | ||
|
||
# Download the envtest binaries to testbin | ||
ENVTEST_ASSETS_DIR=$(shell pwd)/build/testbin | ||
ENVTEST_ASSETS_DIR=$(BUILD_DIR)/testbin | ||
ENVTEST_KUBERNETES_VERSION?=latest | ||
install-envtest: setup-envtest | ||
mkdir -p ${ENVTEST_ASSETS_DIR} | ||
$(ENVTEST) use $(ENVTEST_KUBERNETES_VERSION) --arch=$(ENVTEST_ARCH) --bin-dir=$(ENVTEST_ASSETS_DIR) | ||
|
||
SOPS = $(GOBIN)/sops | ||
$(SOPS): ## Download latest sops binary if none is found. | ||
$(call go-install-tool,$(SOPS),go.mozilla.org/sops/v3/cmd/sops@$(SOPS_VER)) | ||
|
||
# Run controller tests | ||
KUBEBUILDER_ASSETS?="$(shell $(ENVTEST) --arch=$(ENVTEST_ARCH) use -i $(ENVTEST_KUBERNETES_VERSION) --bin-dir=$(ENVTEST_ASSETS_DIR) -p path)" | ||
test: tidy generate fmt vet manifests api-docs download-crd-deps install-envtest | ||
test: tidy generate fmt vet manifests api-docs download-crd-deps install-envtest $(SOPS) | ||
KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS) go test ./... $(GO_TEST_ARGS) -v -coverprofile cover.out | ||
|
||
# Build manager binary | ||
manager: generate fmt vet | ||
go build -o bin/manager main.go | ||
go build -o $(BUILD_DIR)/bin/manager main.go | ||
|
||
# Run against the configured Kubernetes cluster in ~/.kube/config | ||
run: generate fmt vet manifests | ||
|
@@ -120,18 +132,18 @@ docker-deploy: | |
kubectl -n flux-system set image deployment/kustomize-controller manager=${IMG} | ||
|
||
# Find or download controller-gen | ||
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen | ||
CONTROLLER_GEN = $(GOBIN)/controller-gen | ||
.PHONY: controller-gen | ||
controller-gen: ## Download controller-gen locally if necessary. | ||
$(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/[email protected]) | ||
|
||
# Find or download gen-crd-api-reference-docs | ||
GEN_CRD_API_REFERENCE_DOCS = $(shell pwd)/bin/gen-crd-api-reference-docs | ||
GEN_CRD_API_REFERENCE_DOCS = $(GOBIN)/gen-crd-api-reference-docs | ||
.PHONY: gen-crd-api-reference-docs | ||
gen-crd-api-reference-docs: | ||
$(call go-install-tool,$(GEN_CRD_API_REFERENCE_DOCS),github.com/ahmetb/[email protected]) | ||
|
||
ENVTEST = $(shell pwd)/bin/setup-envtest | ||
ENVTEST = $(GOBIN)/setup-envtest | ||
.PHONY: envtest | ||
setup-envtest: ## Download envtest-setup locally if necessary. | ||
$(call go-install-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest) | ||
|
@@ -145,26 +157,26 @@ TMP_DIR=$$(mktemp -d) ;\ | |
cd $$TMP_DIR ;\ | ||
go mod init tmp ;\ | ||
echo "Downloading $(2)" ;\ | ||
GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\ | ||
GOBIN=$(GOBIN) go install $(2) ;\ | ||
rm -rf $$TMP_DIR ;\ | ||
} | ||
endef | ||
|
||
# Build fuzzers | ||
fuzz-build: | ||
rm -rf $(shell pwd)/build/fuzz/ | ||
mkdir -p $(shell pwd)/build/fuzz/out/ | ||
rm -rf $(BUILD_DIR)/fuzz/ | ||
mkdir -p $(BUILD_DIR)/fuzz/out/ | ||
|
||
docker build . --tag local-fuzzing:latest -f tests/fuzz/Dockerfile.builder | ||
docker run --rm \ | ||
-e FUZZING_LANGUAGE=go -e SANITIZER=address \ | ||
-e CIFUZZ_DEBUG='True' -e OSS_FUZZ_PROJECT_NAME=fluxcd \ | ||
-v "$(shell pwd)/build/fuzz/out":/out \ | ||
-v "$(BUILD_DIR)/fuzz/out":/out \ | ||
local-fuzzing:latest | ||
|
||
fuzz-smoketest: fuzz-build | ||
docker run --rm \ | ||
-v "$(shell pwd)/build/fuzz/out":/out \ | ||
-v "$(BUILD_DIR)/fuzz/out":/out \ | ||
-v "$(shell pwd)/tests/fuzz/oss_fuzz_run.sh":/runner.sh \ | ||
local-fuzzing:latest \ | ||
bash -c "/runner.sh" |
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
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,4 +1,5 @@ | ||
// +tag integration | ||
//go:build integration | ||
// +build integration | ||
|
||
/* | ||
Copyright 2022 The Flux authors | ||
|
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