Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 46 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,70 @@
SHELL = /usr/bin/env bash
.SHELLFLAGS = -o pipefail -ec

.PHONY: all
all: scaffold clm

##@ General

.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%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

##@ Development

.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./pkg/..." paths="./internal/..."
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations
$(LOCALBIN)/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./pkg/..." paths="./internal/..."

.PHONY: fmt
fmt: ## Run go fmt against code.
fmt: ## Run go fmt against code
go fmt ./...

.PHONY: vet
vet: ## Run go vet against code.
vet: ## Run go vet against code
go vet ./...

.PHONY: test
test:
test: generate fmt vet ## Run tests
go test ./internal/... ./pkg/...

##@ Build

.PHONY: scaffold
scaffold: generate fmt vet ## Build scaffold
GIT_BRANCH=$$(git rev-parse --abbrev-ref @) && \
GIT_COMMIT=$$(git rev-parse @) && \
if out=$$(git status --porcelain) && [ -z "$$out" ]; then GIT_TREE_STATE=clean; else GIT_TREE_STATE=dirty; fi && \
LDFLAGS=" -X \"github.com/sap/component-operator-runtime/internal/version.version=$$GIT_BRANCH\" \
-X \"github.com/sap/component-operator-runtime/internal/version.gitCommit=$$GIT_COMMIT\" \
-X \"github.com/sap/component-operator-runtime/internal/version.gitTreeState=$$GIT_TREE_STATE\"" && \
CGO_ENABLED=0 go build -ldflags "$$LDFLAGS" -o ./bin/scaffold ./scaffold

.PHONY: clm
clm: generate fmt vet ## Build clm
GIT_BRANCH=$$(git rev-parse --abbrev-ref @) && \
GIT_COMMIT=$$(git rev-parse @) && \
if out=$$(git status --porcelain) && [ -z "$$out" ]; then GIT_TREE_STATE=clean; else GIT_TREE_STATE=dirty; fi && \
LDFLAGS=" -X \"github.com/sap/component-operator-runtime/internal/version.version=$$GIT_BRANCH\" \
-X \"github.com/sap/component-operator-runtime/internal/version.gitCommit=$$GIT_COMMIT\" \
-X \"github.com/sap/component-operator-runtime/internal/version.gitTreeState=$$GIT_TREE_STATE\"" && \
CGO_ENABLED=0 go build -ldflags "$$LDFLAGS" -o ./bin/clm ./clm

##@ Build Dependencies

## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)

## Tool Binaries
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen

## Tool Versions
CONTROLLER_TOOLS_VERSION ?= v0.14.0

.PHONY: controller-gen
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
$(CONTROLLER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/controller-gen || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
controller-gen: $(LOCALBIN) ## Install controller-gen
@go mod download sigs.k8s.io/controller-tools && \
VERSION=$$(go list -m -f '{{.Version}}' sigs.k8s.io/controller-tools) && \
if [ ! -L $(LOCALBIN)/controller-gen ] || [ "$$(readlink $(LOCALBIN)/controller-gen)" != "controller-gen-$$VERSION" ]; then \
echo "Installing controller-gen $$VERSION" && \
rm -f $(LOCALBIN)/controller-gen && \
GOBIN=$(LOCALBIN) go install $$(go list -m -f '{{.Dir}}' sigs.k8s.io/controller-tools)/cmd/controller-gen && \
mv $(LOCALBIN)/controller-gen $(LOCALBIN)/controller-gen-$$VERSION && \
ln -s controller-gen-$$VERSION $(LOCALBIN)/controller-gen; \
fi
2 changes: 1 addition & 1 deletion clm/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func newDeleteCmd() *cobra.Command {
if ok, msg, err := reconciler.IsDeletionAllowed(context.TODO(), &release.Inventory, ownerId); err != nil {
return err
} else if !ok {
return fmt.Errorf(msg)
return fmt.Errorf("%s", msg)
}

if err := releaseClient.Delete(context.TODO(), release); err != nil {
Expand Down
13 changes: 11 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/sap/component-operator-runtime

go 1.24.4
go 1.25.0

require (
github.com/Masterminds/sprig/v3 v3.3.0
Expand All @@ -25,6 +25,7 @@ require (
k8s.io/kube-aggregator v0.33.2
sigs.k8s.io/cli-utils v0.37.2
sigs.k8s.io/controller-runtime v0.21.0
sigs.k8s.io/controller-tools v0.18.0
sigs.k8s.io/kustomize/api v0.19.0
sigs.k8s.io/kustomize/kyaml v0.19.0
sigs.k8s.io/structured-merge-diff/v6 v6.1.0
Expand All @@ -43,13 +44,15 @@ require (
github.com/emicklei/go-restful/v3 v3.11.2 // indirect
github.com/evanphx/json-patch v5.9.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-errors/errors v1.5.1 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.20.4 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/gobuffalo/flect v1.0.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/btree v1.1.3 // indirect
github.com/google/gnostic-models v0.6.9 // indirect
Expand All @@ -66,6 +69,8 @@ require (
github.com/json-iterator/go v1.1.12 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/term v0.5.0 // indirect
Expand All @@ -87,22 +92,26 @@ require (
go.yaml.in/yaml/v2 v2.4.2 // indirect
go.yaml.in/yaml/v3 v3.0.3 // indirect
golang.org/x/crypto v0.37.0 // indirect
golang.org/x/mod v0.24.0 // indirect
golang.org/x/net v0.39.0 // indirect
golang.org/x/oauth2 v0.27.0 // indirect
golang.org/x/sync v0.13.0 // indirect
golang.org/x/sys v0.32.0 // indirect
golang.org/x/term v0.31.0 // indirect
golang.org/x/text v0.24.0 // indirect
golang.org/x/time v0.11.0 // indirect
golang.org/x/tools v0.31.0 // indirect
golang.org/x/tools v0.32.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/protobuf v1.36.5 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/src-d/go-billy.v4 v4.3.2 // indirect
gopkg.in/src-d/go-git.v4 v4.13.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/code-generator v0.33.2 // indirect
k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff // indirect
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
Expand Down
Loading