Skip to content

Commit 5d99d93

Browse files
committed
Updates to Makefile
* Allows overriding of user / image Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
1 parent 9f2e15b commit 5d99d93

2 files changed

Lines changed: 18 additions & 24 deletions

File tree

Makefile

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
.PHONY: build push manifest test verify-codegen charts
22
TAG?=latest
3+
OWNER?=openfaas
4+
SERVER?=ghcr.io
5+
IMG_NAME?=inlets-operator
6+
37
LDFLAGS := "-s -w -X github.com/inlets/inlets-operator/pkg/version.Release=$(Version) -X github.com/inlets/inlets-operator/pkg/version.SHA=$(GitCommit)"
48
PLATFORM := "linux/amd64,linux/arm/v7,linux/arm64"
59

@@ -28,7 +32,6 @@ ${CODEGEN_PKG}: $(TOOLS_DIR)/code-generator.mod
2832
@echo "(re)installing k8s.io/code-generator-${CODEGEN_VERSION}"
2933
@cd $(TOOLS_DIR) && go mod download -modfile=code-generator.mod
3034

31-
3235
.PHONY: build-local
3336
build-local:
3437
@docker buildx create --use --name=multiarch --node multiarch && \
@@ -37,45 +40,29 @@ build-local:
3740
--build-arg Version=$(Version) --build-arg GitCommit=$(GitCommit) \
3841
--platform linux/amd64 \
3942
--output "type=docker,push=false" \
40-
--tag inlets/inlets-operator:$(Version) .
43+
--tag $(SERVER)/$(OWNER)/$(IMG_NAME):$(Version) .
4144

4245
.PHONY: build
4346
build:
44-
@docker buildx create --use --name=multiarch --node multiarch && \
47+
@echo $(SERVER)/$(OWNER)/$(IMG_NAME):$(Version) && \
48+
docker buildx create --use --name=multiarch --node multiarch && \
4549
docker buildx build \
4650
--progress=plain \
4751
--build-arg Version=$(Version) --build-arg GitCommit=$(GitCommit) \
4852
--platform $(PLATFORM) \
4953
--output "type=image,push=false" \
50-
--tag inlets/inlets-operator:$(Version) .
51-
52-
.PHONY: docker-login
53-
docker-login:
54-
echo -n "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin
55-
56-
.PHONY: docker-login-ghcr
57-
docker-login-ghcr:
58-
echo -n "${GHCR_PASSWORD}" | docker login -u "${GHCR_USERNAME}" --password-stdin ghcr.io
54+
--tag $(SERVER)/$(OWNER)/$(IMG_NAME):$(Version) .
5955

6056
.PHONY: push
6157
push:
62-
@docker buildx create --use --name=multiarch --node multiarch && \
63-
docker buildx build \
64-
--progress=plain \
65-
--build-arg Version=$(Version) --build-arg GitCommit=$(GitCommit) \
66-
--platform $(PLATFORM) \
67-
--output "type=image,push=true" \
68-
--tag inlets/inlets-operator:$(Version) .
69-
70-
.PHONY: push-ghcr
71-
push-ghcr:
72-
@docker buildx create --use --name=multiarch --node multiarch && \
58+
@echo $(SERVER)/$(OWNER)/$(IMG_NAME):$(Version) && \
59+
docker buildx create --use --name=multiarch --node multiarch && \
7360
docker buildx build \
7461
--progress=plain \
7562
--build-arg Version=$(Version) --build-arg GitCommit=$(GitCommit) \
7663
--platform $(PLATFORM) \
7764
--output "type=image,push=true" \
78-
--tag ghcr.io/inlets/inlets-operator:$(Version) .
65+
--tag $(SERVER)/$(OWNER)/$(IMG_NAME):$(Version) .
7966

8067
test:
8168
go test ./...

hack/print-codegen-version.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
# This scripts exists primarily so that it can be used in the Makefile.
4+
# It is needed because the `($shell ...)` command was having issues with the pipe.
5+
# Extracting it to a script was the simplest solution.
6+
7+
grep 'k8s.io/code-generator' go.mod | awk '{print $2}'

0 commit comments

Comments
 (0)