github.com/oam-dev/cluster-gateway@v1.9.0/Makefile (about)

     1  
     2  # Image URL to use all building/pushing image targets
     3  IMG ?= controller:latest
     4  IMG_TAG ?= latest
     5  # Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
     6  CRD_OPTIONS ?= "crd:trivialVersions=true"
     7  
     8  OS?=linux
     9  ARCH?=amd64
    10  
    11  # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
    12  ifeq (,$(shell go env GOBIN))
    13  GOBIN=$(shell go env GOPATH)/bin
    14  else
    15  GOBIN=$(shell go env GOBIN)
    16  endif
    17  
    18  VERSION=v0.0.21
    19  
    20  all: manager
    21  
    22  # Run tests
    23  test: generate fmt vet manifests
    24  	go test ./pkg/... -coverprofile cover.out
    25  
    26  # Build manager binary
    27  manager: generate fmt vet
    28  	go build -o bin/manager ./cmd/apiserver/main.go
    29  
    30  # Run against the configured Kubernetes cluster in ~/.kube/config
    31  run: generate fmt vet manifests
    32  	go run ./cmd/apiserver/main.go
    33  
    34  local-run:
    35  	go run ./cmd/apiserver/main.go \
    36  	--standalone-debug-mode=true \
    37      --bind-address=127.0.0.1 \
    38      --etcd-servers=127.0.0.1:2379 \
    39      --secure-port=9443
    40  
    41  # Install CRDs into a cluster
    42  install: manifests kustomize
    43  	$(KUSTOMIZE) build config/crd | kubectl apply -f -
    44  
    45  # Uninstall CRDs from a cluster
    46  uninstall: manifests kustomize
    47  	$(KUSTOMIZE) build config/crd | kubectl delete -f -
    48  
    49  # Deploy controller in the configured Kubernetes cluster in ~/.kube/config
    50  deploy: manifests kustomize
    51  	cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
    52  	$(KUSTOMIZE) build config/default | kubectl apply -f -
    53  
    54  # Run go fmt against code
    55  fmt:
    56  	go fmt ./...
    57  
    58  # Run go vet against code
    59  vet:
    60  	go vet ./...
    61  
    62  # Build the docker image
    63  docker-build: test
    64  	docker build . -t ${IMG}
    65  
    66  # Push the docker image
    67  docker-push:
    68  	docker push ${IMG}
    69  
    70  # find or download controller-gen
    71  # download controller-gen if necessary
    72  controller-gen:
    73  ifeq (, $(shell which controller-gen))
    74  	@{ \
    75  	set -e ;\
    76  	CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
    77  	cd $$CONTROLLER_GEN_TMP_DIR ;\
    78  	go mod init tmp ;\
    79  	go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.3.0 ;\
    80  	rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
    81  	}
    82  CONTROLLER_GEN=$(GOBIN)/controller-gen
    83  else
    84  CONTROLLER_GEN=$(shell which controller-gen)
    85  endif
    86  
    87  kustomize:
    88  ifeq (, $(shell which kustomize))
    89  	@{ \
    90  	set -e ;\
    91  	KUSTOMIZE_GEN_TMP_DIR=$$(mktemp -d) ;\
    92  	cd $$KUSTOMIZE_GEN_TMP_DIR ;\
    93  	go mod init tmp ;\
    94  	go get sigs.k8s.io/kustomize/kustomize/v3@v3.5.4 ;\
    95  	rm -rf $$KUSTOMIZE_GEN_TMP_DIR ;\
    96  	}
    97  KUSTOMIZE=$(GOBIN)/kustomize
    98  else
    99  KUSTOMIZE=$(shell which kustomize)
   100  endif
   101  
   102  client-gen:
   103  	go install k8s.io/code-generator/cmd/client-gen@v0.21.2
   104  	apiserver-runtime-gen \
   105   	--module github.com/oam-dev/cluster-gateway \
   106   	-g client-gen \
   107   	--versions=github.com/oam-dev/cluster-gateway/pkg/apis/cluster/v1alpha1 \
   108   	--install-generators=false
   109  
   110  
   111  generate: controller-gen
   112  	${CONTROLLER_GEN} object:headerFile="hack/boilerplate.go.txt" paths="./pkg/apis/proxy/..."
   113  
   114  manifests: controller-gen
   115  	${CONTROLLER_GEN} $(CRD_OPTIONS) \
   116  		paths="./pkg/apis/proxy/..." \
   117  		rbac:roleName=manager-role \
   118  		output:crd:artifacts:config=hack/crd/bases
   119  
   120  gateway:
   121  	docker build -t oamdev/cluster-gateway:${IMG_TAG} \
   122  		--build-arg OS=${OS} \
   123  		--build-arg ARCH=${ARCH} \
   124  		-f cmd/apiserver/Dockerfile \
   125  		.
   126  
   127  ocm-addon-manager:
   128  	docker build -t oamdev/cluster-gateway-addon-manager:${IMG_TAG} \
   129  		--build-arg OS=${OS} \
   130  		--build-arg ARCH=${ARCH} \
   131  		-f cmd/addon-manager/Dockerfile \
   132  		.
   133  
   134  image: gateway ocm-addon-manager
   135  
   136  e2e-binary:
   137  	mkdir -p bin
   138  	go test -o bin/e2e -c ./e2e/
   139  
   140  e2e-binary-ocm:
   141  	mkdir -p bin
   142  	go test -o bin/e2e.ocm -c ./e2e/ocm/
   143  
   144  e2e-bench-binary:
   145  	go test -c ./e2e/benchmark/
   146  
   147  test-e2e: e2e-binary
   148  	./bin/e2e --test-cluster=loopback
   149  
   150  test-e2e-ocm: e2e-binary-ocm
   151  	./bin/e2e.ocm --test-cluster=loopback