2020-11-17 00:17:34 +00:00
CURRENT = $( shell dirname $( realpath $( firstword $( MAKEFILE_LIST) ) ) )
ROOT := $( CURRENT)
2022-11-03 02:03:37 +00:00
SED ?= sed
REALPATH ?= realpath
2023-06-05 12:18:04 +00:00
i f e q ( $( shell uname ) , D a r w i n )
SED ?= gsed
REALPATH ?= grealpath
e n d i f
2024-03-08 22:27:25 +00:00
KUBERNETES_VERSION_MINOR := 29
KUBERNETES_VERSION_PATCH := 2
2023-07-31 08:53:37 +00:00
2018-02-09 10:11:33 +00:00
PROJECT := arangodb_operator
SCRIPTDIR := $( shell pwd )
ROOTDIR := $( shell cd $( SCRIPTDIR) && pwd )
VERSION := $( shell cat $( ROOTDIR) /VERSION)
VERSION_MAJOR_MINOR_PATCH := $( shell echo $( VERSION) | cut -f 1 -d '+' )
VERSION_MAJOR_MINOR := $( shell echo $( VERSION_MAJOR_MINOR_PATCH) | cut -f 1,2 -d '.' )
VERSION_MAJOR := $( shell echo $( VERSION_MAJOR_MINOR) | cut -f 1 -d '.' )
COMMIT := $( shell git rev-parse --short HEAD)
2019-10-16 07:05:56 +00:00
DOCKERCLI := $( shell which docker)
2021-09-23 13:48:43 +00:00
RELEASE_MODE ?= community
2018-02-09 10:11:33 +00:00
2021-11-22 10:57:45 +00:00
MAIN_DIR := $( ROOT) /pkg/entry/$( RELEASE_MODE)
2018-02-09 10:11:33 +00:00
GOBUILDDIR := $( SCRIPTDIR) /.gobuild
SRCDIR := $( SCRIPTDIR)
2018-05-14 07:13:05 +00:00
CACHEVOL := $( PROJECT) -gocache
2018-02-09 10:11:33 +00:00
BINDIR := $( ROOTDIR) /bin
2021-09-23 13:48:43 +00:00
VBINDIR := $( BINDIR) /$( RELEASE_MODE)
2018-02-13 15:06:36 +00:00
VENDORDIR := $( ROOTDIR) /deps
2018-07-02 12:58:06 +00:00
DASHBOARDDIR := $( ROOTDIR) /dashboard
2021-11-22 18:00:17 +00:00
LOCALDIR := $( ROOT) /local
2018-02-09 10:11:33 +00:00
ORGPATH := github.com/arangodb
ORGDIR := $( GOBUILDDIR) /src/$( ORGPATH)
2018-03-13 15:25:33 +00:00
REPONAME := kube-arangodb
2019-10-16 07:05:56 +00:00
REPODIR := $( ORGDIR) /$( REPONAME)
2018-02-09 10:11:33 +00:00
REPOPATH := $( ORGPATH) /$( REPONAME)
2021-11-22 18:00:17 +00:00
i n c l u d e $( ROOT ) / $( RELEASE_MODE ) . m k
2022-02-02 10:56:57 +00:00
i f n d e f K E E P _ G O P A T H
GOPATH := $( GOBUILDDIR)
e n d i f
2023-08-17 10:39:14 +00:00
TEST_BUILD ?= 0
2022-02-02 10:56:57 +00:00
GOBUILDARGS ?=
2024-03-07 08:24:19 +00:00
GOBASEVERSION := 1.21.8
2024-01-19 11:58:11 +00:00
GOVERSION := $( GOBASEVERSION) -alpine3.18
2022-01-04 15:27:25 +00:00
DISTRIBUTION := alpine:3.15
2024-01-17 10:25:50 +00:00
GOCOMPAT := $( shell sed -En 's/^go (.*)$$/\1/p' go.mod)
2023-08-17 10:39:14 +00:00
GOBUILDTAGS := $( RELEASE_MODE)
i f e q ( $( TEST_BUILD ) , 1 )
GOBUILDTAGS := $( GOBUILDTAGS) ,test_build
e n d i f
2018-02-09 10:11:33 +00:00
PULSAR := $( GOBUILDDIR) /bin/pulsar$( shell go env GOEXE)
2018-07-02 12:58:06 +00:00
GOASSETSBUILDER := $( GOBUILDDIR) /bin/go-assets-builder$( shell go env GOEXE)
2018-02-09 10:11:33 +00:00
2021-07-08 10:11:39 +00:00
BUILDTIME = $( shell go run " $( ROOT) /tools/dategen/ " )
2024-01-08 12:06:38 +00:00
GOBUILDLDFLAGS := -X $( REPOPATH) /pkg/version.version= $( VERSION) -X $( REPOPATH) /pkg/version.buildDate= $( BUILDTIME) -X $( REPOPATH) /pkg/version.build= $( COMMIT)
GOBUILDGCFLAGS :=
# Go Strip Section
GOBUILDSTRIP ?= 1
i f e q ( $( GOBUILDSTRIP ) , 1 )
GOBUILDLDFLAGS += -w -s
e n d i f
# Go Disable function inlining
GOBUILDDISABLEFUNCTIONINLINING ?= 1
i f e q ( $( GOBUILDDISABLEFUNCTIONINLINING ) , 1 )
GOBUILDGCFLAGS += -l
e n d i f
# Go Disable bound checks
GOBUILDDISABLEBOUNDCHECKS ?= 1
i f e q ( $( GOBUILDDISABLEBOUNDCHECKS ) , 1 )
GOBUILDGCFLAGS += -B
e n d i f
2019-09-24 07:22:06 +00:00
HELM ?= $( shell which helm)
2020-06-17 06:29:11 +00:00
UPPER = $( shell echo '$1' | tr '[:lower:]' '[:upper:]' )
LOWER = $( shell echo '$1' | tr '[:upper:]' '[:lower:]' )
UPPER_ENV = $( shell echo '$1' | tr '[:lower:]' '[:upper:]' | tr -d '-' )
2019-09-24 07:22:06 +00:00
.PHONY : helm
helm :
i f e q ( $( HELM ) , )
2023-10-11 07:53:08 +00:00
$( error "Before templating you need to install helm in PATH or export helm binary using 'export HELM=<path to helm>'" )
2019-09-24 07:22:06 +00:00
e n d i f
2022-10-26 21:26:17 +00:00
HELM_OPTIONS = --set " operator.image= $( OPERATORIMAGE) " \
--set "operator.imagePullPolicy=Always" \
--set "operator.resources=null" \
--set " operator.debug= $( DEBUG) "
2022-10-26 21:44:21 +00:00
i f e q ( $( shell $ ( HELM ) version --client --template '{{.Version }}' 2> /dev /null | cut -f 1 -d '.') , v 3 )
2022-10-26 21:26:17 +00:00
# Using helm v3
HELM_PACKAGE_CMD = $( HELM) package " $( ROOTDIR) /chart/ $( CHART_NAME) " -d " $( ROOTDIR) /bin/charts " \
--version " $( VERSION_MAJOR_MINOR_PATCH) "
HELM_CMD = $( HELM) template $( NAME) " $( ROOTDIR) /chart/ $( CHART_NAME) " $( HELM_OPTIONS) --namespace " $( DEPLOYMENTNAMESPACE) "
e l s e
# Using helm v2
HELM_PACKAGE_CMD = $( HELM) package " $( ROOTDIR) /chart/ $( CHART_NAME) " -d " $( ROOTDIR) /bin/charts " \
--save= false --version " $( VERSION_MAJOR_MINOR_PATCH) "
HELM_CMD = $( HELM) template " $( ROOTDIR) /chart/ $( CHART_NAME) " --name " $( NAME) " $( HELM_OPTIONS) \
--namespace " $( DEPLOYMENTNAMESPACE) "
e n d i f
2019-09-23 07:00:10 +00:00
2019-06-25 11:55:48 +00:00
i f n d e f L O C A L O N L Y
2018-03-12 12:28:19 +00:00
PUSHIMAGES := 1
2018-03-12 11:18:50 +00:00
e n d i f
2019-06-25 11:55:48 +00:00
i f d e f I M A G E T A G
2018-03-12 11:18:50 +00:00
IMAGESUFFIX := :$( IMAGETAG)
2019-06-25 11:55:48 +00:00
e l s e
2018-03-12 11:18:50 +00:00
IMAGESUFFIX := :dev
e n d i f
2022-01-10 07:26:29 +00:00
i f e q ( $( DEBUG ) , t r u e )
2021-12-28 11:04:01 +00:00
DEBUG := true
DOCKERFILE := Dockerfile.debug
# required by DLV https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv_exec.md
2022-05-08 14:02:30 +00:00
COMPILE_DEBUG_FLAGS := -gcflags= "all=-N -l" -ldflags "-extldflags '-static'"
2021-12-28 11:04:01 +00:00
e l s e
DEBUG := false
DOCKERFILE := Dockerfile
COMPILE_DEBUG_FLAGS :=
e n d i f
2022-08-15 08:23:25 +00:00
PROTOC_VERSION := 21.1
i f e q ( $( shell uname ) , D a r w i n )
PROTOC_ARCHIVE_SUFFIX := osx-universal_binary
e l s e
PROTOC_ARCHIVE_SUFFIX := linux-x86_64
e n d i f
PROTOC_URL := https://github.com/protocolbuffers/protobuf/releases/download/v${ PROTOC_VERSION } /protoc-${ PROTOC_VERSION } -${ PROTOC_ARCHIVE_SUFFIX } .zip
2018-03-20 07:04:22 +00:00
i f e q ( $( MANIFESTSUFFIX ) , - )
# Release setting
MANIFESTSUFFIX :=
e l s e
2018-03-19 10:09:20 +00:00
i f n d e f M A N I F E S T S U F F I X
MANIFESTSUFFIX := -dev
2018-03-12 11:18:50 +00:00
e n d i f
2018-03-20 07:04:22 +00:00
e n d i f
2022-10-26 21:44:21 +00:00
i f e q ( $( RELEASE_MODE ) , c o m m u n i t y )
2018-10-31 09:31:07 +00:00
MANIFESTPATHCRD := manifests/arango-crd$( MANIFESTSUFFIX) .yaml
2018-03-19 10:09:20 +00:00
MANIFESTPATHDEPLOYMENT := manifests/arango-deployment$( MANIFESTSUFFIX) .yaml
2018-05-18 09:54:53 +00:00
MANIFESTPATHDEPLOYMENTREPLICATION := manifests/arango-deployment-replication$( MANIFESTSUFFIX) .yaml
2019-09-27 11:04:23 +00:00
MANIFESTPATHBACKUP := manifests/arango-backup$( MANIFESTSUFFIX) .yaml
2021-12-31 11:38:53 +00:00
MANIFESTPATHAPPS := manifests/arango-apps$( MANIFESTSUFFIX) .yaml
2023-11-17 11:07:30 +00:00
MANIFESTPATHML := manifests/arango-ml$( MANIFESTSUFFIX) .yaml
2022-01-06 20:27:01 +00:00
MANIFESTPATHK2KCLUSTERSYNC := manifests/arango-k2kclustersync$( MANIFESTSUFFIX) .yaml
2018-03-19 10:09:20 +00:00
MANIFESTPATHSTORAGE := manifests/arango-storage$( MANIFESTSUFFIX) .yaml
2020-06-17 06:29:11 +00:00
MANIFESTPATHALL := manifests/arango-all$( MANIFESTSUFFIX) .yaml
KUSTOMIZEPATHCRD := manifests/kustomize/crd/arango-crd$( MANIFESTSUFFIX) .yaml
KUSTOMIZEPATHDEPLOYMENT := manifests/kustomize/deployment/arango-deployment$( MANIFESTSUFFIX) .yaml
KUSTOMIZEPATHDEPLOYMENTREPLICATION := manifests/kustomize/deployment-replication/arango-deployment-replication$( MANIFESTSUFFIX) .yaml
KUSTOMIZEPATHBACKUP := manifests/kustomize/backup/arango-backup$( MANIFESTSUFFIX) .yaml
2021-12-31 11:38:53 +00:00
KUSTOMIZEPATHAPPS := manifests/kustomize/apps/arango-apps$( MANIFESTSUFFIX) .yaml
2023-11-17 11:07:30 +00:00
KUSTOMIZEPATHML := manifests/kustomize/apps/arango-ml$( MANIFESTSUFFIX) .yaml
2022-10-26 21:44:21 +00:00
KUSTOMIZEPATHK2KCLUSTERSYNC := manifests/kustomize/k2kclustersync/arango-k2kclustersync$( MANIFESTSUFFIX) .yaml
2020-06-17 06:29:11 +00:00
KUSTOMIZEPATHSTORAGE := manifests/kustomize/storage/arango-storage$( MANIFESTSUFFIX) .yaml
KUSTOMIZEPATHALL := manifests/kustomize/all/arango-all$( MANIFESTSUFFIX) .yaml
2022-10-26 21:44:21 +00:00
e l s e
MANIFESTPATHCRD := manifests/enterprise-crd$( MANIFESTSUFFIX) .yaml
MANIFESTPATHDEPLOYMENT := manifests/enterprise-deployment$( MANIFESTSUFFIX) .yaml
MANIFESTPATHDEPLOYMENTREPLICATION := manifests/enterprise-deployment-replication$( MANIFESTSUFFIX) .yaml
MANIFESTPATHBACKUP := manifests/enterprise-backup$( MANIFESTSUFFIX) .yaml
MANIFESTPATHAPPS := manifests/enterprise-apps$( MANIFESTSUFFIX) .yaml
2023-11-17 11:07:30 +00:00
MANIFESTPATHML := manifests/enterprise-ml$( MANIFESTSUFFIX) .yaml
2022-10-26 21:44:21 +00:00
MANIFESTPATHK2KCLUSTERSYNC := manifests/enterprise-k2kclustersync$( MANIFESTSUFFIX) .yaml
MANIFESTPATHSTORAGE := manifests/enterprise-storage$( MANIFESTSUFFIX) .yaml
MANIFESTPATHALL := manifests/enterprise-all$( MANIFESTSUFFIX) .yaml
KUSTOMIZEPATHCRD := manifests/kustomize-enterprise/crd/enterprise-crd$( MANIFESTSUFFIX) .yaml
KUSTOMIZEPATHDEPLOYMENT := manifests/kustomize-enterprise/deployment/enterprise-deployment$( MANIFESTSUFFIX) .yaml
KUSTOMIZEPATHDEPLOYMENTREPLICATION := manifests/kustomize-enterprise/deployment-replication/enterprise-deployment-replication$( MANIFESTSUFFIX) .yaml
KUSTOMIZEPATHBACKUP := manifests/kustomize-enterprise/backup/enterprise-backup$( MANIFESTSUFFIX) .yaml
KUSTOMIZEPATHAPPS := manifests/kustomize-enterprise/apps/enterprise-apps$( MANIFESTSUFFIX) .yaml
2023-11-17 11:07:30 +00:00
KUSTOMIZEPATHML := manifests/kustomize/apps/enterprise-ml$( MANIFESTSUFFIX) .yaml
2022-10-26 21:44:21 +00:00
KUSTOMIZEPATHK2KCLUSTERSYNC := manifests/kustomize-enterprise/k2kclustersync/enterprise-k2kclustersync$( MANIFESTSUFFIX) .yaml
KUSTOMIZEPATHSTORAGE := manifests/kustomize-enterprise/storage/enterprise-storage$( MANIFESTSUFFIX) .yaml
KUSTOMIZEPATHALL := manifests/kustomize-enterprise/all/enterprise-all$( MANIFESTSUFFIX) .yaml
e n d i f
2018-03-12 11:18:50 +00:00
i f n d e f D E P L O Y M E N T N A M E S P A C E
DEPLOYMENTNAMESPACE := default
2018-02-20 17:53:33 +00:00
e n d i f
2021-09-09 14:32:11 +00:00
BASEUBIIMAGE ?= registry.access.redhat.com/ubi8/ubi-minimal:8.4
2019-10-31 06:48:27 +00:00
2021-09-23 13:48:43 +00:00
OPERATORIMAGENAME ?= $( REPONAME)
2018-02-20 17:53:33 +00:00
i f n d e f O P E R A T O R I M A G E
2021-09-23 13:48:43 +00:00
OPERATORIMAGE := $( DOCKERNAMESPACE) /$( OPERATORIMAGENAME) $( IMAGESUFFIX)
2018-02-20 17:53:33 +00:00
e n d i f
2019-10-31 06:48:27 +00:00
i f n d e f O P E R A T O R U B I I M A G E
2021-09-23 13:48:43 +00:00
OPERATORUBIIMAGE := $( DOCKERNAMESPACE) /$( OPERATORIMAGENAME) $( IMAGESUFFIX) -ubi
2019-10-31 06:48:27 +00:00
e n d i f
2018-02-27 08:30:00 +00:00
i f n d e f E N T E R P R I S E I M A G E
ENTERPRISEIMAGE := $( DEFAULTENTERPRISEIMAGE)
e n d i f
2018-12-03 13:34:58 +00:00
i f n d e f E N T E R P R I S E L I C E N S E
ENTERPRISELICENSE := $( DEFAULTENTERPRISELICENSE)
e n d i f
2018-07-06 06:14:51 +00:00
DASHBOARDBUILDIMAGE := kube-arangodb-dashboard-builder
2018-02-20 17:53:33 +00:00
2018-03-30 13:40:11 +00:00
i f n d e f A L L O W C H A O S
ALLOWCHAOS := true
e n d i f
2019-10-16 07:05:56 +00:00
BINNAME := $( PROJECT)
BIN := $( BINDIR) /$( BINNAME)
2018-02-09 10:11:33 +00:00
2022-06-13 12:44:58 +00:00
BIN_OPS_NAME := $( PROJECT) _ops
BIN_OPS := $( BINDIR) /$( BIN_OPS_NAME)
2024-02-14 08:14:32 +00:00
BIN_INT_NAME := $( PROJECT) _integration
BIN_INT := $( BINDIR) /$( BIN_INT_NAME)
d e f i n e b i n a r y
$(eval _OS : =$( call UPPER_ENV ,$ 1) )
$(eval _ARCH : =$( call UPPER_ENV ,$ 2) )
VBIN_$(_OS)_$(_ARCH) := $( BINDIR) /$( RELEASE_MODE) /$1 /$2 /$( BINNAME)
VBIN_OPS_$(_OS)_$(_ARCH) := $( BINDIR) /$( RELEASE_MODE) /$1 /$2 /$( BIN_OPS_NAME)
VBIN_INT_$(_OS)_$(_ARCH) := $( BINDIR) /$( RELEASE_MODE) /$1 /$2 /$( BIN_INT_NAME)
$$ (VBIN_$(_OS)_$(_ARCH)) : $$( SOURCES ) dashboard /assets .go VERSION
@mkdir -p $( BINDIR) /$( RELEASE_MODE) /$1 /$2
CGO_ENABLED = 0 GOOS = $1 GOARCH = $2 go build $$ { GOBUILDARGS} --tags " $$ (GOBUILDTAGS) " $$ ( COMPILE_DEBUG_FLAGS) -installsuffix netgo -gcflags= all = " $$ (GOBUILDGCFLAGS) " -ldflags " $$ (GOBUILDLDFLAGS) " -o $$ @ ./cmd/main
$$ (VBIN_OPS_$(_OS)_$(_ARCH)) : $$( SOURCES ) dashboard /assets .go VERSION
@mkdir -p $( BINDIR) /$( RELEASE_MODE) /$1 /$2
CGO_ENABLED = 0 GOOS = $1 GOARCH = $2 go build $$ { GOBUILDARGS} --tags " $$ (GOBUILDTAGS) " $$ ( COMPILE_DEBUG_FLAGS) -installsuffix netgo -gcflags= all = " $$ (GOBUILDGCFLAGS) " -ldflags " $$ (GOBUILDLDFLAGS) " -o $$ @ ./cmd/main-ops
$$ (VBIN_INT_$(_OS)_$(_ARCH)) : $$( SOURCES ) dashboard /assets .go VERSION
@mkdir -p $( BINDIR) /$( RELEASE_MODE) /$1 /$2
CGO_ENABLED = 0 GOOS = $1 GOARCH = $2 go build $$ { GOBUILDARGS} --tags " $$ (GOBUILDTAGS) " $$ ( COMPILE_DEBUG_FLAGS) -installsuffix netgo -gcflags= all = " $$ (GOBUILDGCFLAGS) " -ldflags " $$ (GOBUILDLDFLAGS) " -o $$ @ ./cmd/main-int
bin-all : $$( VBIN_ $ ( _OS ) _ $ ( _ARCH ) ) $$( VBIN_OPS_ $ ( _OS ) _ $ ( _ARCH ) ) $$( VBIN_INT_ $ ( _OS ) _ $ ( _ARCH ) )
e n d e f
$( eval $ ( call binary ,linux ,amd 64) )
$( eval $ ( call binary ,linux ,arm 64) )
$( eval $ ( call binary ,darwin ,amd 64) )
$( eval $ ( call binary ,darwin ,arm 64) )
2023-11-07 13:02:41 +00:00
2019-10-16 07:05:56 +00:00
i f d e f V E R B O S E
TESTVERBOSEOPTIONS := -v
e n d i f
2018-02-20 09:58:28 +00:00
2022-08-08 14:23:57 +00:00
EXCLUDE_DIRS := vendor .gobuild deps tools pkg/generated/clientset pkg/generated/informers pkg/generated/listers
2022-07-11 11:49:47 +00:00
EXCLUDE_FILES := *generated.deepcopy.go
2022-08-15 08:23:25 +00:00
SOURCES_QUERY := find ./ -type f -name '*.go' ! -name '*.pb.go' $( foreach EXCLUDE_DIR,$( EXCLUDE_DIRS) , ! -path " */ $( EXCLUDE_DIR) /* " ) $( foreach EXCLUDE_FILE,$( EXCLUDE_FILES) , ! -path " */ $( EXCLUDE_FILE) " )
2020-03-10 09:26:38 +00:00
SOURCES := $( shell $( SOURCES_QUERY) )
2023-02-20 13:30:42 +00:00
2023-09-28 10:44:41 +00:00
NON_EE_SOURCES_QUERY := $( SOURCES_QUERY) ! -name '*.enterprise.go'
NON_EE_SOURCES := $( shell $( NON_EE_SOURCES_QUERY) )
2023-02-20 13:30:42 +00:00
YAML_EXCLUDE_DIRS := vendor .gobuild deps tools pkg/generated/clientset pkg/generated/informers pkg/generated/listers chart/kube-arangodb/templates chart/kube-arangodb-crd/templates chart/arangodb-ingress-proxy/templates
YAML_EXCLUDE_FILES :=
YAML_QUERY := find ./ -type f -name '*.yaml' $( foreach EXCLUDE_DIR,$( YAML_EXCLUDE_DIRS) , ! -path " */ $( EXCLUDE_DIR) /* " ) $( foreach EXCLUDE_FILE,$( YAML_EXCLUDE_FILES) , ! -path " */ $( EXCLUDE_FILE) " )
YAMLS := $( shell $( YAML_QUERY) )
2021-09-21 09:46:17 +00:00
DASHBOARDSOURCES := $( shell find $( DASHBOARDDIR) /src -name '*.js' ) $( DASHBOARDDIR) /package.json
2021-09-29 14:11:48 +00:00
LINT_EXCLUDES :=
i f e q ( $( RELEASE_MODE ) , e n t e r p r i s e )
LINT_EXCLUDES += .*\. community\. go$$
e l s e
LINT_EXCLUDES += .*\. enterprise\. go$$
e n d i f
2022-08-15 08:23:25 +00:00
PROTOSOURCES := $( shell find ./ -type f -name '*.proto' $( foreach EXCLUDE_DIR,$( EXCLUDE_DIRS) , ! -path " */ $( EXCLUDE_DIR) /* " ) | sort)
2019-09-24 15:25:09 +00:00
.DEFAULT_GOAL := all
2018-03-12 11:18:50 +00:00
.PHONY : all
2024-01-08 15:58:01 +00:00
all : check -vars build
2019-06-25 11:55:48 +00:00
.PHONY : compile
2023-06-05 18:46:18 +00:00
compile : check -vars build
2019-05-14 15:26:43 +00:00
2019-06-25 11:55:48 +00:00
# allall is now obsolete
2019-05-14 15:26:43 +00:00
.PHONY : allall
2019-06-25 11:55:48 +00:00
allall : all
2018-02-09 10:11:33 +00:00
2018-02-09 14:46:14 +00:00
#
# Tip: Run `eval $(minikube docker-env)` before calling make if you're developing on minikube.
#
2020-04-01 09:23:24 +00:00
.PHONY : license -verify
license-verify :
@echo ">> Verify license of files"
2023-09-28 10:44:41 +00:00
@$( GOPATH) /bin/addlicense -f "./tools/codegen/license-header.txt" -check $( NON_EE_SOURCES) $( PROTOSOURCES)
2020-04-01 09:23:24 +00:00
2023-01-17 08:18:42 +00:00
.PHONY : license -range -verify
license-range-verify :
@GOBIN= $( GOPATH) /bin go run " $( ROOT) /tools/license/ " $( SOURCES)
2023-02-20 06:46:27 +00:00
.PHONY : license -range
license-range :
@GOBIN= $( GOPATH) /bin go run " $( ROOT) /tools/license/ " -w $( SOURCES)
2019-09-27 11:04:23 +00:00
.PHONY : fmt
fmt :
2020-04-01 09:23:24 +00:00
@echo ">> Ensuring style of files"
2021-05-11 19:16:58 +00:00
@$( GOPATH) /bin/goimports -w $( SOURCES)
2022-08-08 14:23:57 +00:00
@$( GOPATH) /bin/gci write -s "standard" -s "default" -s "prefix(github.com/arangodb)" -s "prefix(github.com/arangodb/kube-arangodb)" $( SOURCES)
2020-04-01 09:23:24 +00:00
2023-02-20 13:30:42 +00:00
.PHONY : yamlfmt
yamlfmt :
@echo ">> Ensuring style of yaml files"
2023-11-20 12:11:39 +00:00
@$( GOPATH) /bin/yamlfmt -quiet $( YAMLS)
.PHONY : yamlfmt -verify
yamlfmt-verify :
@echo ">> Verifying style of yaml files"
@$( GOPATH) /bin/yamlfmt -lint -quiet $( YAMLS)
2023-02-20 13:30:42 +00:00
2020-07-21 07:32:02 +00:00
.PHONY : license
license :
@echo ">> Ensuring license of files"
2023-09-28 10:44:41 +00:00
@$( GOPATH) /bin/addlicense -f "./tools/codegen/license-header.txt" $( NON_EE_SOURCES) $( PROTOSOURCES)
2020-07-21 07:32:02 +00:00
2020-04-01 09:23:24 +00:00
.PHONY : fmt -verify
fmt-verify : license -verify
@echo ">> Verify files style"
2021-05-11 19:16:58 +00:00
@if [ X" $$ ( $( GOPATH) /bin/goimports -l $( SOURCES) | wc -l) " != X"0" ] ; then echo ">> Style errors" ; $( GOPATH) /bin/goimports -l $( SOURCES) ; exit 1; fi
2020-03-10 09:26:38 +00:00
.PHONY : linter
2021-05-07 14:13:15 +00:00
linter :
2023-08-17 10:39:14 +00:00
@$( GOPATH) /bin/golangci-lint run --build-tags " $( GOBUILDTAGS) " $( foreach LINT_EXCLUDE,$( LINT_EXCLUDES) ,--exclude '$(LINT_EXCLUDE)' ) ./...
2022-06-30 18:39:07 +00:00
.PHONY : linter -fix
linter-fix :
2023-08-17 10:39:14 +00:00
@$( GOPATH) /bin/golangci-lint run --fix --build-tags " $( GOBUILDTAGS) " $( foreach LINT_EXCLUDE,$( LINT_EXCLUDES) ,--exclude '$(LINT_EXCLUDE)' ) ./...
2019-09-27 11:04:23 +00:00
2024-02-16 09:04:43 +00:00
.PHONY : protolint protolint -fix
protolint :
@$( GOPATH) /bin/protolint lint $( PROTOSOURCES)
protolint-fix :
@$( GOPATH) /bin/protolint lint --fix $( PROTOSOURCES)
2023-09-14 11:54:27 +00:00
.PHONY : vulncheck vulncheck -optional
2023-06-05 18:46:18 +00:00
vulncheck :
2023-09-14 11:54:27 +00:00
@echo ">> Checking for known vulnerabilities (required)"
@$( GOPATH) /bin/govulncheck --tags $( GOBUILDTAGS) ./...
vulncheck-optional :
@echo ">> Checking for known vulnerabilities (optional)"
2023-08-17 10:39:14 +00:00
@-$( GOPATH) /bin/govulncheck --tags $( GOBUILDTAGS) ./...
2023-06-05 18:46:18 +00:00
2018-03-12 11:18:50 +00:00
.PHONY : build
2020-03-20 13:39:32 +00:00
build : docker manifests
i f n d e f I G N O R E _ U B I
build : docker -ubi
e n d i f
2018-02-09 10:11:33 +00:00
2018-03-12 11:18:50 +00:00
.PHONY : clean
2018-02-09 10:11:33 +00:00
clean :
2023-11-07 13:02:41 +00:00
rm -Rf $( BIN) $( BINDIR) $( DASHBOARDDIR) /build $( DASHBOARDDIR) /node_modules $( VBIN_LINUX_AMD64) $( VBIN_LINUX_ARM64) $( VBIN_OPS_LINUX_AMD64) $( VBIN_OPS_LINUX_ARM64) $( VBIN_OPS_DARWIN_AMD64) $( VBIN_OPS_DARWIN_ARM64) $( VBIN_OPS_WIN_AMD64)
2018-02-09 10:11:33 +00:00
2018-03-12 11:18:50 +00:00
.PHONY : check -vars
check-vars :
i f n d e f D O C K E R N A M E S P A C E
@echo "DOCKERNAMESPACE must be set"
@exit 1
e n d i f
@echo " Using docker namespace: $( DOCKERNAMESPACE) "
2023-07-31 08:53:37 +00:00
KUBERNETES_APIS := k8s.io/api \
k8s.io/apiextensions-apiserver \
k8s.io/apimachinery \
k8s.io/apiserver \
k8s.io/client-go \
k8s.io/cloud-provider \
k8s.io/cluster-bootstrap \
k8s.io/code-generator \
k8s.io/component-base \
k8s.io/kubernetes \
k8s.io/metrics
KUBERNETES_MODS := k8s.io/api \
k8s.io/apiextensions-apiserver \
k8s.io/apimachinery \
k8s.io/apiserver \
k8s.io/client-go \
k8s.io/cloud-provider \
k8s.io/cluster-bootstrap \
k8s.io/code-generator \
k8s.io/component-base \
k8s.io/metrics
.PHONY : update -kubernetes -version
update-kubernetes-version :
@$( foreach API,$( KUBERNETES_APIS) , sed -i 's#$(API) => $(API) .*#$(API) => $(API) v0.$(KUBERNETES_VERSION_MINOR).$(KUBERNETES_VERSION_PATCH)#g' '$(ROOT)/go.mod' && ) echo " Replaced to K8S 1. $( KUBERNETES_VERSION_MINOR) . $( KUBERNETES_VERSION_PATCH) "
update-kubernetes-version-go :
@$( foreach API,$( KUBERNETES_MODS) , go get '$(API)@v0.$(KUBERNETES_VERSION_MINOR).$(KUBERNETES_VERSION_PATCH)' && ) echo " Go Upgraded to K8S 1. $( KUBERNETES_VERSION_MINOR) . $( KUBERNETES_VERSION_PATCH) "
2018-03-12 11:18:50 +00:00
.PHONY : update -vendor
2018-02-09 14:27:40 +00:00
update-vendor :
2019-05-07 08:10:23 +00:00
@rm -Rf $( VENDORDIR) /k8s.io/code-generator
2023-07-31 08:53:37 +00:00
@git clone --branch " kubernetes-1. $( KUBERNETES_VERSION_MINOR) . $( KUBERNETES_VERSION_PATCH) " https://github.com/kubernetes/code-generator.git $( VENDORDIR) /k8s.io/code-generator
2018-02-09 10:11:33 +00:00
@rm -Rf $( VENDORDIR) /k8s.io/code-generator/.git
2023-10-12 14:20:40 +00:00
@( cd " $( VENDORDIR) /k8s.io/code-generator " ; go mod download; go mod vendor)
2019-05-07 08:10:23 +00:00
2018-02-09 10:11:33 +00:00
2018-03-12 11:18:50 +00:00
.PHONY : update -generated
2019-05-07 09:25:49 +00:00
update-generated :
2019-05-14 08:57:50 +00:00
@rm -fr $( ORGDIR)
2019-05-07 09:25:49 +00:00
@mkdir -p $( ORGDIR)
2019-05-14 08:57:50 +00:00
@ln -s -f $( SCRIPTDIR) $( ORGDIR) /kube-arangodb
2022-11-03 02:03:37 +00:00
@$( SED) -e 's/^/\/\/ /' -e 's/ *$$//' $( ROOTDIR) /tools/codegen/license-header.txt > $( ROOTDIR) /tools/codegen/boilerplate.go.txt
2019-05-14 09:02:02 +00:00
GOPATH = $( GOBUILDDIR) $( VENDORDIR) /k8s.io/code-generator/generate-groups.sh \
2024-01-08 15:58:01 +00:00
"client lister informer deepcopy" \
2020-03-20 13:39:32 +00:00
"github.com/arangodb/kube-arangodb/pkg/generated" \
"github.com/arangodb/kube-arangodb/pkg/apis" \
2024-02-23 08:21:00 +00:00
"deployment:v1 replication:v1 storage:v1alpha backup:v1 deployment:v2alpha1 replication:v2alpha1 apps:v1 ml:v1alpha1 scheduler:v1alpha1" \
2020-03-20 13:39:32 +00:00
--go-header-file "./tools/codegen/boilerplate.go.txt" \
$( VERIFYARGS)
GOPATH = $( GOBUILDDIR) $( VENDORDIR) /k8s.io/code-generator/generate-groups.sh \
"deepcopy" \
"github.com/arangodb/kube-arangodb/pkg/generated" \
"github.com/arangodb/kube-arangodb/pkg/apis" \
2024-02-23 08:21:00 +00:00
"shared:v1 scheduler:v1alpha1/container scheduler:v1alpha1/container/resources scheduler:v1alpha1/pod scheduler:v1alpha1/pod/resources" \
2020-03-20 13:39:32 +00:00
--go-header-file "./tools/codegen/boilerplate.go.txt" \
$( VERIFYARGS)
2018-02-09 10:11:33 +00:00
2021-09-23 13:48:43 +00:00
dashboard/assets.go :
2018-07-06 06:14:51 +00:00
cd $( DASHBOARDDIR) && docker build -t $( DASHBOARDBUILDIMAGE) -f Dockerfile.build $( DASHBOARDDIR)
@mkdir -p $( DASHBOARDDIR) /build
docker run --rm \
2018-07-10 06:27:27 +00:00
-u $( shell id -u) :$( shell id -g) \
2018-07-06 06:14:51 +00:00
-v $( DASHBOARDDIR) /build:/usr/code/build \
-v $( DASHBOARDDIR) /public:/usr/code/public:ro \
-v $( DASHBOARDDIR) /src:/usr/code/src:ro \
$( DASHBOARDBUILDIMAGE)
2022-09-05 13:50:21 +00:00
$( GOASSETSBUILDER) -s /dashboard/build/ -o dashboard/assets.go -p dashboard dashboard/build
2018-07-02 12:58:06 +00:00
2024-02-14 08:14:32 +00:00
# Binaries
2021-11-22 10:57:45 +00:00
2024-02-14 08:14:32 +00:00
.PHONY : bin
bin : $( BIN )
2023-11-07 13:02:41 +00:00
2024-02-14 08:14:32 +00:00
$(BIN) : $( VBIN_LINUX_AMD 64) $( VBIN_OPS_LINUX_AMD 64) $( VBIN_INT_LINUX_AMD 64)
2021-11-22 10:57:45 +00:00
@cp " $( VBIN_LINUX_AMD64) " " $( BIN) "
2022-06-13 12:44:58 +00:00
@cp " $( VBIN_OPS_LINUX_AMD64) " " $( BIN_OPS) "
2019-10-16 07:05:56 +00:00
2018-03-12 11:18:50 +00:00
.PHONY : docker
2021-11-22 10:57:45 +00:00
docker : check -vars $( VBIN_LINUX_AMD 64) $( VBIN_LINUX_ARM 64)
2018-02-22 15:54:36 +00:00
i f d e f P U S H I M A G E S
2022-01-04 15:27:25 +00:00
docker buildx build --no-cache -f $( DOCKERFILE) --build-arg GOVERSION = $( GOVERSION) --build-arg DISTRIBUTION = $( DISTRIBUTION) \
--build-arg " VERSION= ${ VERSION_MAJOR_MINOR_PATCH } " --build-arg " RELEASE_MODE= $( RELEASE_MODE) " \
--platform linux/amd64,linux/arm64 --push -t $( OPERATORIMAGE) .
2021-11-22 10:57:45 +00:00
e l s e
2022-01-04 15:27:25 +00:00
docker buildx build --no-cache -f $( DOCKERFILE) --build-arg GOVERSION = $( GOVERSION) --build-arg DISTRIBUTION = $( DISTRIBUTION) \
--build-arg " VERSION= ${ VERSION_MAJOR_MINOR_PATCH } " --build-arg " RELEASE_MODE= $( RELEASE_MODE) " \
--platform linux/amd64,linux/arm64 -t $( OPERATORIMAGE) .
2018-02-22 15:54:36 +00:00
e n d i f
2018-02-09 10:11:33 +00:00
2019-10-31 06:48:27 +00:00
.PHONY : docker -ubi
2021-11-22 10:57:45 +00:00
docker-ubi : check -vars $( VBIN_LINUX_AMD 64)
docker build --no-cache -f " $( DOCKERFILE) .ubi " --build-arg " VERSION= ${ VERSION_MAJOR_MINOR_PATCH } " --build-arg " RELEASE_MODE= $( RELEASE_MODE) " --build-arg " IMAGE= $( BASEUBIIMAGE) " -t $( OPERATORUBIIMAGE) -local-only-build .
2022-02-10 10:55:54 +00:00
docker build --no-cache -f $( DOCKERFILE) --build-arg " VERSION= ${ VERSION_MAJOR_MINOR_PATCH } " --build-arg "TARGETARCH=amd64" --build-arg " RELEASE_MODE= $( RELEASE_MODE) " --build-arg " IMAGE= $( OPERATORUBIIMAGE) -local-only-build " -t $( OPERATORUBIIMAGE) .
2019-10-31 06:48:27 +00:00
i f d e f P U S H I M A G E S
docker push $( OPERATORUBIIMAGE)
e n d i f
2019-06-25 11:55:48 +00:00
# Manifests
2018-03-12 11:18:50 +00:00
2020-06-17 06:29:11 +00:00
d e f i n e m a n i f e s t - g e n e r a t o r
$(eval _TARGET : =$( call LOWER ,$ 1) )
$(eval _ENV : =$( call UPPER_ENV ,$ 1) )
.PHONY : manifests -$( _TARGET ) -file
manifests-$(_TARGET)-file : export CHART_NAME := $2
manifests-$(_TARGET)-file : export NAME := $( _TARGET )
manifests-$(_TARGET)-file : helm
@echo Building manifests for $( _ENV) - $$ ( MANIFESTPATH$( _ENV) )
@$$ ( HELM_CMD) $3 > " $$ (MANIFESTPATH $( _ENV) ) "
manifests : manifests -$( _TARGET ) -file
.PHONY : manifests -$( _TARGET ) -kustomize
manifests-$(_TARGET)-kustomize : export CHART_NAME := $2
manifests-$(_TARGET)-kustomize : export NAME := $( _TARGET )
manifests-$(_TARGET)-kustomize : helm
@echo Building kustomize manifests for $( _ENV) - $$ ( KUSTOMIZEPATH$( _ENV) )
@$$ ( HELM_CMD) $3 > " $$ (KUSTOMIZEPATH $( _ENV) ) "
manifests : manifests -$( _TARGET ) -kustomize
e n d e f
.PHONY : manifests
manifests :
2023-02-21 18:58:09 +00:00
.PHONY : manifests -crd -file
manifests-crd-file :
@echo Building manifests for CRD - $( MANIFESTPATHCRD)
2023-09-29 09:11:54 +00:00
@printf "" > $( MANIFESTPATHCRD)
@$( foreach FILE,$( CRDS) ,printf '%s\n# File: chart/kube-arangodb/crds/%s.yaml\n' '---' $( FILE) >> $( MANIFESTPATHCRD) && \
cat '$(ROOT)/chart/kube-arangodb/crds/$(FILE).yaml' >> $( MANIFESTPATHCRD) ; )
2023-02-21 18:58:09 +00:00
manifests : manifests -crd -file
.PHONY : manifests -crd -kustomize
manifests-crd-kustomize : manifests -crd -file
@echo Building manifests for CRD - $( KUSTOMIZEPATHCRD)
@cp " $( MANIFESTPATHCRD) " " $( KUSTOMIZEPATHCRD) "
manifests : manifests -crd -kustomize
2020-06-17 06:29:11 +00:00
$( eval $ ( call manifest -generator , deployment , kube -arangodb , \
--set "operator.features.deployment=true" \
--set "operator.features.deploymentReplications=false" \
--set "operator.features.storage=false" \
2021-12-31 11:38:53 +00:00
--set "operator.features.apps=false" \
2023-11-17 11:07:30 +00:00
--set "operator.features.ml=false" \
2022-01-06 20:27:01 +00:00
--set "operator.features.k8sToK8sClusterSync=false" \
2020-06-17 06:29:11 +00:00
--set "operator.features.backup=false" ) )
$( eval $ ( call manifest -generator , deployment -replication , kube -arangodb , \
--set "operator.features.deployment=false" \
--set "operator.features.deploymentReplications=true" \
--set "operator.features.storage=false" \
2021-12-31 11:38:53 +00:00
--set "operator.features.apps=false" \
2022-01-06 20:27:01 +00:00
--set "operator.features.k8sToK8sClusterSync=false" \
2020-06-17 06:29:11 +00:00
--set "operator.features.backup=false" ) )
$( eval $ ( call manifest -generator , storage , kube -arangodb , \
--set "operator.features.deployment=false" \
--set "operator.features.deploymentReplications=false" \
--set "operator.features.storage=true" \
2021-12-31 11:38:53 +00:00
--set "operator.features.apps=false" \
2023-11-17 11:07:30 +00:00
--set "operator.features.ml=false" \
2022-01-06 20:27:01 +00:00
--set "operator.features.k8sToK8sClusterSync=false" \
2020-06-17 06:29:11 +00:00
--set "operator.features.backup=false" ) )
$( eval $ ( call manifest -generator , backup , kube -arangodb , \
--set "operator.features.deployment=false" \
--set "operator.features.deploymentReplications=false" \
--set "operator.features.storage=false" \
2021-12-31 11:38:53 +00:00
--set "operator.features.apps=false" \
2023-11-17 11:07:30 +00:00
--set "operator.features.ml=false" \
2022-01-06 20:27:01 +00:00
--set "operator.features.k8sToK8sClusterSync=false" \
2020-06-17 06:29:11 +00:00
--set "operator.features.backup=true" ) )
2021-12-31 11:38:53 +00:00
$( eval $ ( call manifest -generator , apps , kube -arangodb , \
--set "operator.features.deployment=false" \
--set "operator.features.deploymentReplications=false" \
--set "operator.features.storage=false" \
--set "operator.features.apps=true" \
2023-11-17 11:07:30 +00:00
--set "operator.features.ml=false" \
--set "operator.features.k8sToK8sClusterSync=false" \
--set "operator.features.backup=false" ) )
$( eval $ ( call manifest -generator , ml , kube -arangodb , \
--set "operator.features.deployment=false" \
--set "operator.features.deploymentReplications=false" \
--set "operator.features.storage=false" \
--set "operator.features.apps=false" \
--set "operator.features.ml=true" \
2022-01-06 20:27:01 +00:00
--set "operator.features.k8sToK8sClusterSync=false" \
--set "operator.features.backup=false" ) )
$( eval $ ( call manifest -generator , k 2kclustersync , kube -arangodb , \
--set "operator.features.deployment=false" \
--set "operator.features.deploymentReplications=false" \
--set "operator.features.storage=false" \
--set "operator.features.apps=false" \
2023-11-17 11:07:30 +00:00
--set "operator.features.ml=false" \
2022-01-06 20:27:01 +00:00
--set "operator.features.k8sToK8sClusterSync=true" \
2021-12-31 11:38:53 +00:00
--set "operator.features.backup=false" ) )
2020-06-17 06:29:11 +00:00
$( eval $ ( call manifest -generator , all , kube -arangodb , \
--set "operator.features.deployment=true" \
--set "operator.features.deploymentReplications=true" \
--set "operator.features.storage=true" \
2021-12-31 11:38:53 +00:00
--set "operator.features.apps=true" \
2023-11-17 11:07:30 +00:00
--set "operator.features.ml=true" \
2022-01-06 20:27:01 +00:00
--set "operator.features.k8sToK8sClusterSync=true" \
2020-06-17 06:29:11 +00:00
--set "operator.features.backup=true" ) )
2019-09-23 07:00:10 +00:00
2019-09-24 07:22:06 +00:00
.PHONY : chart -crd
chart-crd : export CHART_NAME := kube -arangodb -crd
chart-crd : helm
@mkdir -p " $( ROOTDIR) /bin/charts "
@$( HELM_PACKAGE_CMD)
2020-06-17 06:29:11 +00:00
manifests : chart -crd
2019-09-24 07:22:06 +00:00
.PHONY : chart -operator
chart-operator : export CHART_NAME := kube -arangodb
chart-operator : helm
2019-09-23 07:00:10 +00:00
@mkdir -p " $( ROOTDIR) /bin/charts "
2019-09-24 07:22:06 +00:00
@$( HELM_PACKAGE_CMD)
2019-09-23 07:00:10 +00:00
2020-06-17 06:29:11 +00:00
manifests : chart -operator
2018-03-12 11:18:50 +00:00
2023-10-11 07:53:08 +00:00
.PHONY : manifests -verify
manifests-verify :
$( MAKE) manifest-verify-plain-ce
$( MAKE) manifest-verify-plain-ee
$( MAKE) manifest-verify-kustomize-ce
$( MAKE) manifest-verify-kustomize-ee
$( MAKE) manifest-verify-helm-ce
$( MAKE) manifest-verify-helm-ee
manifests-verify-env-reset :
@minikube delete && minikube start
manifest-verify-plain-ce : manifests -verify -env -reset
@echo "Trying to install via plain manifests"
kubectl apply -f ./manifests/arango-all.yaml
kubectl apply -f ./manifests/arango-apps.yaml
kubectl apply -f ./manifests/arango-backup.yaml
kubectl apply -f ./manifests/arango-crd.yaml
kubectl apply -f ./manifests/arango-deployment.yaml
kubectl apply -f ./manifests/arango-deployment-replication.yaml
kubectl apply -f ./manifests/arango-k2kclustersync.yaml
kubectl apply -f ./manifests/arango-storage.yaml
manifest-verify-plain-ee : manifests -verify -env -reset
kubectl apply -f ./manifests/enterprise-all.yaml
kubectl apply -f ./manifests/enterprise-apps.yaml
kubectl apply -f ./manifests/enterprise-backup.yaml
kubectl apply -f ./manifests/enterprise-crd.yaml
kubectl apply -f ./manifests/enterprise-deployment.yaml
kubectl apply -f ./manifests/enterprise-deployment-replication.yaml
kubectl apply -f ./manifests/enterprise-k2kclustersync.yaml
kubectl apply -f ./manifests/enterprise-storage.yaml
d e f i n e KUSTOMIZE_YAML =
apiVersion : kustomize .config .k 8s .io /v 1beta 1
kind : Kustomization
resources :
- ./all
- ./apps
- ./backup
- ./crd
- ./deployment
- ./deployment-replication
- ./k2kclustersync
e n d e f
export KUSTOMIZE_YAML
manifest-verify-kustomize-ce : manifests -verify -env -reset
@echo "Trying to install via Kustomize"
@-rm -rf ./kustomize_test
@cp -r ./manifests/kustomize ./kustomize_test
@echo " $$ KUSTOMIZE_YAML " > ./kustomize_test/kustomization.yaml
@kubectl create -k ./kustomize_test/
manifest-verify-kustomize-ee : manifests -verify -env -reset
@echo "Trying to install via Kustomize"
@-rm -rf ./kustomize_test
@cp -r ./manifests/kustomize-enterprise ./kustomize_test
@echo " $$ KUSTOMIZE_YAML " > ./kustomize_test/kustomization.yaml
@kubectl create -k ./kustomize_test/
manifest-verify-helm-ce : manifests -verify -env -reset
@echo "Trying to install via Helm charts"
helm install --generate-name --set "operator.features.storage=true" \
./bin/charts/kube-arangodb-$( VERSION_MAJOR_MINOR_PATCH) .tgz
manifest-verify-helm-ee : manifests -verify -env -reset
@echo "Trying to install via Helm charts"
helm install --generate-name --set " operator.image=arangodb/kube-arangodb-enterprise: $( VERSION_MAJOR_MINOR_PATCH) " --set "operator.features.storage=true" \
./bin/charts/kube-arangodb-$( VERSION_MAJOR_MINOR_PATCH) .tgz
2018-02-20 08:49:01 +00:00
# Testing
2018-03-12 11:18:50 +00:00
.PHONY : run -unit -tests
2019-05-07 08:10:23 +00:00
run-unit-tests : $( SOURCES )
2023-08-17 10:39:14 +00:00
go test --count= 1 --tags " $( GOBUILDTAGS) " $( TESTVERBOSEOPTIONS) \
2023-12-05 10:48:43 +00:00
$( REPOPATH) /pkg/apis/shared/... \
2019-11-04 07:49:24 +00:00
$( REPOPATH) /pkg/apis/backup/... \
$( REPOPATH) /pkg/apis/deployment/... \
$( REPOPATH) /pkg/apis/replication/... \
$( REPOPATH) /pkg/apis/storage/... \
2023-12-05 10:48:43 +00:00
$( REPOPATH) /pkg/apis/ml/... \
2019-10-18 07:54:27 +00:00
$( REPOPATH) /pkg/deployment/... \
2023-11-17 11:55:29 +00:00
$( REPOPATH) /pkg/storage/... \
2023-02-21 18:58:09 +00:00
$( REPOPATH) /pkg/crd/... \
2021-12-10 12:04:48 +00:00
$( REPOPATH) /pkg/util/... \
2023-07-06 12:33:39 +00:00
$( REPOPATH) /cmd/... \
2022-01-04 15:27:25 +00:00
$( REPOPATH) /pkg/handlers/...
2019-10-16 07:05:56 +00:00
2018-02-20 08:49:01 +00:00
# Release building
2018-04-03 07:11:44 +00:00
.PHONY : patch -readme
patch-readme :
$( ROOTDIR) /scripts/patch_readme.sh $( VERSION_MAJOR_MINOR_PATCH)
2020-03-04 10:25:14 +00:00
.PHONY : patch -examples
patch-examples :
$( ROOTDIR) /scripts/patch_examples.sh $( VERSION_MAJOR_MINOR_PATCH)
.PHONY : patch -release
2022-10-26 21:44:21 +00:00
patch-release : patch -readme patch -examples patch -chart
2020-03-04 10:25:14 +00:00
2019-09-25 10:31:12 +00:00
.PHONY : patch -chart
patch-chart :
$( ROOTDIR) /scripts/patch_chart.sh " $( VERSION_MAJOR_MINOR_PATCH) " " $( OPERATORIMAGE) "
2020-07-22 12:24:22 +00:00
.PHONY : tidy
tidy :
2024-01-17 10:25:50 +00:00
@go mod tidy -v -compat= $( GOCOMPAT)
2020-07-22 12:24:22 +00:00
.PHONY : deps -reload
deps-reload : tidy init
2020-04-01 09:23:24 +00:00
.PHONY : init
2023-02-20 06:09:13 +00:00
init : vendor tools update -generated $( BIN )
2020-04-01 09:23:24 +00:00
2023-02-20 06:09:13 +00:00
.PHONY : tools -min
tools-min : update -vendor
2021-05-07 14:13:15 +00:00
@echo ">> Fetching golangci-lint linter"
2024-02-29 15:04:06 +00:00
@GOBIN= $( GOPATH) /bin go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.2
2020-04-01 09:23:24 +00:00
@echo ">> Fetching goimports"
2021-11-22 19:06:10 +00:00
@GOBIN= $( GOPATH) /bin go install golang.org/x/tools/cmd/goimports@0bb7e5c47b1a31f85d4f173edc878a8e049764a5
2020-04-01 09:23:24 +00:00
@echo ">> Fetching license check"
2021-11-22 19:06:10 +00:00
@GOBIN= $( GOPATH) /bin go install github.com/google/addlicense@6d92264d717064f28b32464f0f9693a5b4ef0239
2023-02-20 13:30:42 +00:00
@echo ">> Fetching yamlfmt"
2023-11-20 12:11:39 +00:00
@GOBIN= $( GOPATH) /bin go install github.com/google/yamlfmt/cmd/yamlfmt@v0.10.0
2024-02-16 09:04:43 +00:00
@echo ">> Fetching protolinter"
@GOBIN= $( GOPATH) /bin go install github.com/yoheimuta/protolint/cmd/protolint@v0.47.5
2023-02-20 06:09:13 +00:00
.PHONY : tools
tools : tools -min
2022-07-11 11:49:47 +00:00
@echo ">> Fetching gci"
@GOBIN= $( GOPATH) /bin go install github.com/daixiang0/gci@v0.3.0
2023-02-21 18:58:09 +00:00
@echo ">> Fetching yamlfmt"
2023-11-20 12:11:39 +00:00
@GOBIN= $( GOPATH) /bin go install github.com/google/yamlfmt/cmd/yamlfmt@v0.10.0
2022-08-15 08:23:25 +00:00
@echo ">> Downloading protobuf compiler..."
@curl -L ${ PROTOC_URL } -o $( GOPATH) /protoc.zip
@echo ">> Unzipping protobuf compiler..."
@unzip -o $( GOPATH) /protoc.zip -d $( GOPATH) /
2023-05-08 13:28:02 +00:00
@chmod +x $( GOPATH) /bin/protoc
2022-08-15 08:23:25 +00:00
@echo ">> Fetching protoc go plugins..."
@GOBIN= $( GOPATH) /bin go install github.com/golang/protobuf/protoc-gen-go@v1.5.2
@GOBIN= $( GOPATH) /bin go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
2023-06-05 18:46:18 +00:00
@echo ">> Fetching govulncheck"
@GOBIN= $( GOPATH) /bin go install golang.org/x/vuln/cmd/govulncheck@v0.1.0
2020-04-01 09:23:24 +00:00
.PHONY : vendor
vendor :
@echo ">> Updating vendor"
2021-11-22 18:00:17 +00:00
@go mod vendor -e
2020-11-17 00:17:34 +00:00
set-deployment-api-version-v2alpha1 : export API_VERSION =2alpha 1
2023-01-27 08:56:00 +00:00
set-deployment-api-version-v2alpha1 : set -api -version /deployment set -api -version /replication
2020-11-17 00:17:34 +00:00
set-deployment-api-version-v1 : export API_VERSION =1
2023-01-27 08:56:00 +00:00
set-deployment-api-version-v1 : set -api -version /deployment set -api -version /replication
2022-11-03 12:41:19 +00:00
set-typed-api-version/% :
@grep -rHn " github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/ $* /v[A-Za-z0-9]\+ " \
" $( ROOT) /pkg/deployment/ " \
" $( ROOT) /pkg/replication/ " \
" $( ROOT) /pkg/operator/ " \
" $( ROOT) /pkg/server/ " \
" $( ROOT) /pkg/util/ " \
" $( ROOT) /pkg/handlers/ " \
" $( ROOT) /pkg/apis/backup/ " \
" $( ROOT) /pkg/upgrade/ " \
| cut -d ':' -f 1 | sort | uniq \
| xargs -n 1 $( SED) -i " s#github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/ $* /v[A-Za-z0-9]\+#github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/ $* /v $( API_VERSION) #g "
2020-11-17 00:17:34 +00:00
set-api-version/% :
@grep -rHn " github.com/arangodb/kube-arangodb/pkg/apis/ $* /v[A-Za-z0-9]\+ " \
" $( ROOT) /pkg/deployment/ " \
2020-11-23 13:19:50 +00:00
" $( ROOT) /pkg/replication/ " \
2020-11-17 00:17:34 +00:00
" $( ROOT) /pkg/operator/ " \
" $( ROOT) /pkg/server/ " \
" $( ROOT) /pkg/util/ " \
2022-01-04 15:27:25 +00:00
" $( ROOT) /pkg/handlers/ " \
2020-11-17 00:17:34 +00:00
" $( ROOT) /pkg/apis/backup/ " \
2022-03-24 11:40:51 +00:00
" $( ROOT) /pkg/upgrade/ " \
2020-11-17 00:17:34 +00:00
| cut -d ':' -f 1 | sort | uniq \
2022-11-03 02:03:37 +00:00
| xargs -n 1 $( SED) -i " s#github.com/arangodb/kube-arangodb/pkg/apis/ $* /v[A-Za-z0-9]\+#github.com/arangodb/kube-arangodb/pkg/apis/ $* /v $( API_VERSION) #g "
2020-11-17 00:17:34 +00:00
@grep -rHn "DatabaseV[A-Za-z0-9]\+()" \
" $( ROOT) /pkg/deployment/ " \
2020-11-23 13:19:50 +00:00
" $( ROOT) /pkg/replication/ " \
2020-11-17 00:17:34 +00:00
" $( ROOT) /pkg/operator/ " \
" $( ROOT) /pkg/server/ " \
" $( ROOT) /pkg/util/ " \
2022-01-04 15:27:25 +00:00
" $( ROOT) /pkg/handlers/ " \
2020-11-17 00:17:34 +00:00
" $( ROOT) /pkg/apis/backup/ " \
2022-03-24 11:40:51 +00:00
" $( ROOT) /pkg/upgrade/ " \
2020-11-17 00:17:34 +00:00
| cut -d ':' -f 1 | sort | uniq \
2022-11-03 02:03:37 +00:00
| xargs -n 1 $( SED) -i " s#DatabaseV[A-Za-z0-9]\+()\.#DatabaseV $( API_VERSION) ().#g "
2020-11-23 13:19:50 +00:00
@grep -rHn "ReplicationV[A-Za-z0-9]\+()" \
" $( ROOT) /pkg/deployment/ " \
" $( ROOT) /pkg/replication/ " \
" $( ROOT) /pkg/operator/ " \
" $( ROOT) /pkg/server/ " \
" $( ROOT) /pkg/util/ " \
2022-01-04 15:27:25 +00:00
" $( ROOT) /pkg/handlers " \
2020-11-23 13:19:50 +00:00
" $( ROOT) /pkg/apis/backup/ " \
2022-03-24 11:40:51 +00:00
" $( ROOT) /pkg/upgrade/ " \
2020-11-23 13:19:50 +00:00
| cut -d ':' -f 1 | sort | uniq \
2022-11-03 02:03:37 +00:00
| xargs -n 1 $( SED) -i " s#ReplicationV[A-Za-z0-9]\+()\.#ReplicationV $( API_VERSION) ().#g "
2020-11-23 13:19:50 +00:00
2023-07-24 14:53:50 +00:00
synchronize : synchronize -v 2alpha 1-with -v 1
2020-11-23 13:19:50 +00:00
synchronize-v2alpha1-with-v1 :
2023-12-07 21:06:18 +00:00
@echo " >> Please use only COMMUNITY mode! Current RELEASE_MODE= $( RELEASE_MODE) "
2020-11-23 13:19:50 +00:00
@rm -f pkg/apis/deployment/v1/zz_generated.deepcopy.go pkg/apis/deployment/v2alpha1/zz_generated.deepcopy.go
2022-11-03 02:03:37 +00:00
@for file in $$ ( find " $( ROOT) /pkg/apis/deployment/v1/ " -type f -exec $( REALPATH) --relative-to " $( ROOT) /pkg/apis/deployment/v1/ " { } \; ) ; do if [ ! -d " $( ROOT) /pkg/apis/deployment/v2alpha1/ $$ (dirname $$ {file}) " ] ; then mkdir -p " $( ROOT) /pkg/apis/deployment/v2alpha1/ $$ (dirname $$ {file}) " ; fi ; done
@for file in $$ ( find " $( ROOT) /pkg/apis/deployment/v1/ " -type f -exec $( REALPATH) --relative-to " $( ROOT) /pkg/apis/deployment/v1/ " { } \; ) ; do cat " $( ROOT) /pkg/apis/deployment/v1/ $$ {file} " | $( SED) "s#package v1#package v2alpha1#g" | $( SED) 's#ArangoDeploymentVersion = "v1"#ArangoDeploymentVersion = "v2alpha1"#g' > " $( ROOT) /pkg/apis/deployment/v2alpha1/ $$ {file} " ; done
2020-11-23 13:19:50 +00:00
@make update-generated
@make set-deployment-api-version-v2alpha1 bin
2021-05-07 14:13:15 +00:00
@make set-deployment-api-version-v1 bin
2022-05-03 11:10:06 +00:00
.PHONY : check -all check -enterprise check -community _check
2023-02-20 05:01:54 +00:00
check-all : check -enterprise check -community license -range -verify
2022-05-03 11:10:06 +00:00
check-enterprise :
@$( MAKE) _check RELEASE_MODE = enterprise
check-community :
@$( MAKE) _check RELEASE_MODE = community
2023-02-21 18:58:09 +00:00
_check : sync -crds
2024-02-14 08:14:32 +00:00
@$( MAKE) fmt yamlfmt license-verify linter run-unit-tests bin-all vulncheck-optional
2022-06-27 06:02:21 +00:00
2023-12-05 09:49:32 +00:00
generate : generate -internal generate -proto fmt yamlfmt
2022-08-15 08:23:25 +00:00
2022-08-08 14:23:57 +00:00
generate-internal :
2022-08-15 08:23:25 +00:00
ROOT = $( ROOT) go test --count= 1 " $( REPOPATH) /internal/... "
2023-05-08 13:28:02 +00:00
2022-08-15 08:23:25 +00:00
generate-proto :
2023-05-08 13:28:02 +00:00
PATH = " $( PATH) : $( GOBUILDDIR) /bin " $( GOBUILDDIR) /bin/protoc -I.:$( GOBUILDDIR) /include/ \
2022-08-15 08:23:25 +00:00
--go_out= . --go_opt= paths = source_relative \
--go-grpc_out= . --go-grpc_opt= paths = source_relative \
2022-10-26 21:26:17 +00:00
$( PROTOSOURCES)
2023-02-20 06:46:27 +00:00
.PHONY : fix
2023-02-20 13:30:42 +00:00
fix : license -range fmt license yamlfmt
2023-02-21 18:58:09 +00:00
CRDS := apps-job \
backups-backup backups-backuppolicy \
database-clustersynchronization database-deployment database-member database-task \
2023-11-08 15:36:20 +00:00
replication-deploymentreplication \
ml-storage ml-extension ml-job-batch ml-job-cron
2023-02-21 18:58:09 +00:00
.PHONY : sync -crds
sync-crds :
@cp $( foreach FILE,$( CRDS) ," $( ROOT) /chart/kube-arangodb/crds/ $( FILE) .yaml " ) " $( ROOT) /pkg/crd/crds/ "