Skip to content

Commit 558e29b

Browse files
committed
update build logic, update license headers
1 parent fda14a3 commit 558e29b

File tree

81 files changed

+412
-2177
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+412
-2177
lines changed

.reuse/dep5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ Disclaimer: The code in this project may include calls to APIs ("API Calls") of
2525
parties the right to use of access any SAP External Product, through API Calls.
2626

2727
Files: **
28-
Copyright: 2024 SAP SE or an SAP affiliate company and project-operator contributors
28+
Copyright: 2025 SAP SE or an SAP affiliate company and project-operator contributors
2929
License: Apache-2.0

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Build the manager binary
2-
FROM --platform=$BUILDPLATFORM golang:1.23.4 as builder
2+
FROM --platform=$BUILDPLATFORM golang:1.23.4 AS builder
33
ARG TARGETOS
44
ARG TARGETARCH
55

66
WORKDIR /workspace
7-
# Copy the Go Modules manifests
7+
# Copy the go module manifests
88
COPY go.mod go.mod
99
COPY go.sum go.sum
1010
# Cache deps before building and copying source so that we don't need to re-download as much
@@ -34,3 +34,4 @@ COPY --from=builder /workspace/manager .
3434
USER 65532:65532
3535

3636
ENTRYPOINT ["/manager"]
37+

Makefile

Lines changed: 62 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,177 +1,117 @@
1-
21
# Image URL to use all building/pushing image targets
3-
IMG ?= controller:latest
4-
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
5-
ENVTEST_K8S_VERSION = 1.25.0
6-
7-
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
8-
ifeq (,$(shell go env GOBIN))
9-
GOBIN=$(shell go env GOPATH)/bin
10-
else
11-
GOBIN=$(shell go env GOBIN)
12-
endif
13-
14-
# Setting SHELL to bash allows bash commands to be executed by recipes.
15-
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
16-
SHELL = /usr/bin/env bash -o pipefail
17-
.SHELLFLAGS = -ec
2+
IMG ?= project-operator:latest
3+
# K8s version used by envtest
4+
ENVTEST_K8S_VERSION = 1.30.3
5+
6+
# Set shell to bash
7+
SHELL = /usr/bin/env bash
8+
.SHELLFLAGS = -o pipefail -ec
189

1910
.PHONY: all
2011
all: build
2112

2213
##@ General
2314

24-
# The help target prints out all targets with their descriptions organized
25-
# beneath their categories. The categories are represented by '##@' and the
26-
# target descriptions by '##'. The awk commands is responsible for reading the
27-
# entire set of makefiles included in this invocation, looking for lines of the
28-
# file as xyz: ## something, and then pretty-format the target and help. Then,
29-
# if there's a line with ##@ something, that gets pretty-printed as a category.
30-
# More info on the usage of ANSI control characters for terminal formatting:
31-
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
32-
# More info on the awk command:
33-
# http://linuxcommand.org/lc3_adv_awk.php
34-
3515
.PHONY: help
36-
help: ## Display this help.
37-
@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)
16+
help: ## Display this help
17+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
3818

3919
##@ Development
4020

4121
.PHONY: manifests
42-
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
43-
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:generateEmbeddedObjectMeta=true webhook paths="main.go" paths="./api/..." paths="./controllers/..." paths="./webhooks/..." paths="./pkg/..." paths="./internal/..." output:crd:artifacts:config=config/crd/bases
44-
rm -rf crds && cp -r config/crd/bases crds
22+
manifests: controller-gen ## Generate CustomResourceDefinition objects
23+
$(LOCALBIN)/controller-gen crd paths="./api/..." output:crd:artifacts:config=crds && \
24+
test ! -d chart || test -e chart/crds || ln -s ../crds chart/crds
4525

4626
.PHONY: generate
47-
generate: controller-gen client-gen informer-gen lister-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
48-
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./api/..."
49-
./hack/gen-typed-client
27+
generate: generate-deepcopy generate-client ## Generate required code pieces
28+
29+
.PHONY: generate-deepcopy
30+
generate-deepcopy: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations
31+
$(LOCALBIN)/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./api/..."
32+
33+
.PHONY: generate-client
34+
generate-client: ## Generate typed client
35+
./hack/genclient.sh
5036

5137
.PHONY: fmt
52-
fmt: ## Run go fmt against code.
38+
fmt: ## Run go fmt against code
5339
go fmt ./...
5440

5541
.PHONY: vet
56-
vet: ## Run go vet against code.
42+
vet: ## Run go vet against code
5743
go vet ./...
5844

45+
##@ Testing
46+
5947
.PHONY: test
60-
test: manifests generate fmt vet envtest ## Run tests.
48+
test: manifests generate-deepcopy fmt vet envtest ## Run tests
6149
KUBEBUILDER_ASSETS="$(LOCALBIN)/k8s/current" go test ./... -coverprofile cover.out
6250

6351
##@ Build
6452

6553
.PHONY: build
66-
build: generate fmt vet ## Build manager binary.
54+
build: generate-deepcopy fmt vet ## Build manager binary
6755
go build -o bin/manager main.go
6856

6957
.PHONY: run
70-
run: manifests generate fmt vet ## Run a controller from your host.
58+
run: manifests generate-deepcopy fmt vet ## Run a controller from your host
7159
go run ./main.go
7260

73-
# If you wish built the manager image targeting other platforms you can use the --platform flag.
74-
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
75-
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
61+
# Build docker image in current architecture and tag it as ${IMG}
7662
.PHONY: docker-build
77-
docker-build: test ## Build docker image with the manager.
63+
docker-build: ## Build docker image with the manager
7864
docker build -t ${IMG} .
7965

66+
# Push docker image to the target specified in ${IMG}
8067
.PHONY: docker-push
81-
docker-push: ## Push docker image with the manager.
68+
docker-push: ## Push docker image with the manager
8269
docker push ${IMG}
8370

84-
# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
85-
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
86-
# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/
87-
# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
88-
# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=<myregistry/image:<tag>> than the export will fail)
89-
# To properly provided solutions that supports more than one platform you should use this option.
71+
# Build and push docker image for all given platforms
9072
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
9173
.PHONY: docker-buildx
92-
docker-buildx: test ## Build and push docker image for the manager for cross-platform support
93-
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
94-
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
74+
docker-buildx: ## Build and push docker image for the manager for cross-platform support
9575
- docker buildx create --name project-v3-builder
9676
docker buildx use project-v3-builder
97-
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross
77+
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} .
9878
- docker buildx rm project-v3-builder
99-
rm Dockerfile.cross
100-
101-
##@ Deployment
102-
103-
ifndef ignore-not-found
104-
ignore-not-found = false
105-
endif
106-
107-
.PHONY: install
108-
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
109-
$(KUSTOMIZE) build config/crd | kubectl apply -f -
110-
111-
.PHONY: uninstall
112-
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.
113-
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
114-
115-
.PHONY: deploy
116-
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
117-
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
118-
$(KUSTOMIZE) build config/default | kubectl apply -f -
119-
120-
.PHONY: undeploy
121-
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.
122-
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
12379

12480
##@ Build Dependencies
12581

12682
## Location to install dependencies to
12783
LOCALBIN ?= $(shell pwd)/bin
12884
$(LOCALBIN):
129-
mkdir -p $(LOCALBIN)
130-
131-
## Tool Binaries
132-
KUSTOMIZE ?= $(LOCALBIN)/kustomize
133-
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
134-
ENVTEST ?= $(LOCALBIN)/setup-envtest
135-
CLIENT_GEN ?= $(shell pwd)/bin/client-gen
136-
INFORMER_GEN ?= $(shell pwd)/bin/informer-gen
137-
LISTER_GEN ?= $(shell pwd)/bin/lister-gen
138-
139-
## Tool Versions
140-
KUSTOMIZE_VERSION ?= v3.8.7
141-
CONTROLLER_TOOLS_VERSION ?= v0.14.0
142-
CODE_GENERATOR_VERSION ?= v0.23.4
143-
144-
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
145-
.PHONY: kustomize
146-
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
147-
$(KUSTOMIZE): $(LOCALBIN)
148-
test -s $(LOCALBIN)/kustomize || { curl -Ss $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }
85+
@mkdir -p $(LOCALBIN)
14986

15087
.PHONY: controller-gen
151-
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
152-
$(CONTROLLER_GEN): $(LOCALBIN)
153-
test -s $(LOCALBIN)/controller-gen || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
88+
controller-gen: $(LOCALBIN) ## Install controller-gen
89+
@go mod download sigs.k8s.io/controller-tools && \
90+
VERSION=$$(go list -m -f '{{.Version}}' sigs.k8s.io/controller-tools) && \
91+
if [ ! -L $(LOCALBIN)/controller-gen ] || [ "$$(readlink $(LOCALBIN)/controller-gen)" != "controller-gen-$$VERSION" ]; then \
92+
echo "Installing controller-gen $$VERSION" && \
93+
rm -f $(LOCALBIN)/controller-gen && \
94+
GOBIN=$(LOCALBIN) go install $$(go list -m -f '{{.Dir}}' sigs.k8s.io/controller-tools)/cmd/controller-gen && \
95+
mv $(LOCALBIN)/controller-gen $(LOCALBIN)/controller-gen-$$VERSION && \
96+
ln -s controller-gen-$$VERSION $(LOCALBIN)/controller-gen; \
97+
fi
98+
99+
.PHONY: setup-envtest
100+
setup-envtest: $(LOCALBIN) ## Install setup-envtest
101+
@go mod download sigs.k8s.io/controller-runtime/tools/setup-envtest && \
102+
VERSION=$$(go list -m -f '{{.Version}}' sigs.k8s.io/controller-runtime/tools/setup-envtest) && \
103+
if [ ! -L $(LOCALBIN)/setup-envtest ] || [ "$$(readlink $(LOCALBIN)/setup-envtest)" != "setup-envtest-$$VERSION" ]; then \
104+
echo "Installing setup-envtest $$VERSION" && \
105+
rm -f $(LOCALBIN)/setup-envtest && \
106+
GOBIN=$(LOCALBIN) go install $$(go list -m -f '{{.Dir}}' sigs.k8s.io/controller-runtime/tools/setup-envtest) && \
107+
mv $(LOCALBIN)/setup-envtest $(LOCALBIN)/setup-envtest-$$VERSION && \
108+
ln -s setup-envtest-$$VERSION $(LOCALBIN)/setup-envtest; \
109+
fi
154110

155111
.PHONY: envtest
156-
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
157-
$(ENVTEST): $(LOCALBIN)
158-
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
159-
ENVTESTDIR=$$($(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path) ;\
160-
chmod -R u+w $$ENVTESTDIR ;\
161-
rm -f $(LOCALBIN)/k8s/current ;\
112+
envtest: setup-envtest ## Install envtest binaries
113+
@ENVTESTDIR=$$($(LOCALBIN)/setup-envtest use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path) && \
114+
chmod -R u+w $$ENVTESTDIR && \
115+
rm -f $(LOCALBIN)/k8s/current && \
162116
ln -s $$ENVTESTDIR $(LOCALBIN)/k8s/current
163117

164-
.PHONY: client-gen
165-
client-gen: $(CLIENT_GEN) ## Download client-gen
166-
$(CLIENT_GEN): $(LOCALBIN)
167-
test -s $(LOCALBIN)/client-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/client-gen@$(CODE_GENERATOR_VERSION)
168-
169-
.PHONY: informer-gen
170-
informer-gen: $(INFORMER_GEN) ## Download informer-gen
171-
$(INFORMER_GEN): $(LOCALBIN)
172-
test -s $(LOCALBIN)/informer-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/informer-gen@$(CODE_GENERATOR_VERSION)
173-
174-
.PHONY: lister-gen
175-
lister-gen: $(LISTER_GEN) ## Download lister-gen
176-
$(LISTER_GEN): $(LOCALBIN)
177-
test -s $(LOCALBIN)/lister-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/lister-gen@$(CODE_GENERATOR_VERSION)

PROJECT

Lines changed: 0 additions & 18 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,4 @@ We as members, contributors, and leaders pledge to make participation in our com
8787

8888
## Licensing
8989

90-
Copyright 2024 SAP SE or an SAP affiliate company and project-operator contributors. Please see our [LICENSE](LICENSE) for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available [via the REUSE tool](https://api.reuse.software/info/github.com/SAP/project-operator).
90+
Copyright 2025 SAP SE or an SAP affiliate company and project-operator contributors. Please see our [LICENSE](LICENSE) for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available [via the REUSE tool](https://api.reuse.software/info/github.com/SAP/project-operator).

api/v1alpha1/groupversion_info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and project-operator contributors
2+
SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and project-operator contributors
33
SPDX-License-Identifier: Apache-2.0
44
*/
55

api/v1alpha1/project_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and project-operator contributors
2+
SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and project-operator contributors
33
SPDX-License-Identifier: Apache-2.0
44
*/
55

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/certmanager/certificate.yaml

Lines changed: 0 additions & 39 deletions
This file was deleted.

config/certmanager/kustomization.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)