From 272dc7dfea8c5e2481ced939ffb56f00ef638575 Mon Sep 17 00:00:00 2001 From: jt-dd Date: Fri, 6 Sep 2024 10:29:20 +0200 Subject: [PATCH 1/3] hardcoding CI branch for release cycle --- Dockerfile | 20 +++++++++++--------- docker-bake.hcl | 6 +++++- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 916dab274..dab269c42 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,14 +15,14 @@ FROM golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine AS golangci-lint FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION}-alpine AS base COPY --from=xx / / RUN apk add --no-cache \ - clang \ - docker \ - file \ - findutils \ - git \ - make \ - protoc \ - protobuf-dev + clang \ + docker \ + file \ + findutils \ + git \ + make \ + protoc \ + protobuf-dev WORKDIR /src ENV CGO_ENABLED=0 @@ -49,8 +49,10 @@ RUN --mount=type=bind,target=.,rw \ FROM build-base AS build ARG BUILD_TAGS +ARG BUILD_BRANCH ARG BUILD_FLAGS ARG TARGETPLATFORM +ENV BUILD_BRANCH="${BUILD_BRANCH}" RUN --mount=type=bind,target=. \ --mount=type=cache,target=/root/.cache \ --mount=type=cache,target=/go/pkg/mod \ @@ -105,4 +107,4 @@ RUN --mount=from=binary \ cp kubehound* "/out/kubehound-${TARGETOS}-${TARGETARCH}${TARGETVARIANT}$(ls kubehound* | sed -e 's/^kubehound//')" FROM scratch AS release -COPY --from=releaser /out/ / \ No newline at end of file +COPY --from=releaser /out/ / diff --git a/docker-bake.hcl b/docker-bake.hcl index c9387026b..2f5bc2636 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -60,6 +60,10 @@ target "binary-cross" { } target "release" { + # Overrinding the branch as this target is only being used in the CI + args = { + BUILD_BRANCH = "main" + } inherits = ["binary-cross"] target = "release" output = [outdir("./bin/release")] @@ -68,4 +72,4 @@ target "release" { target "image-cross" { inherits = ["meta-helper", "binary"] output = ["type=image"] -} \ No newline at end of file +} From 5a87e840a7081a763e4bdef037930caf644f25eb Mon Sep 17 00:00:00 2001 From: jt-dd Date: Fri, 6 Sep 2024 11:08:50 +0200 Subject: [PATCH 2/3] adding symbol to binary --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index cd9515e6d..3c043de48 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ BUILD_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD) BUILD_ARCH := $(shell go env GOARCH) BUILD_OS := $(shell go env GOOS) -BUILD_FLAGS := -ldflags="-X github.com/DataDog/KubeHound/pkg/config.BuildVersion=$(BUILD_VERSION) -X github.com/DataDog/KubeHound/pkg/config.BuildBranch=$(BUILD_BRANCH) -X github.com/DataDog/KubeHound/pkg/config.BuildArch=$(BUILD_ARCH) -X github.com/DataDog/KubeHound/pkg/config.BuildOs=$(BUILD_OS) -s -w" +BUILD_FLAGS := -ldflags="-X github.com/DataDog/KubeHound/pkg/config.BuildVersion=$(BUILD_VERSION) -X github.com/DataDog/KubeHound/pkg/config.BuildBranch=$(BUILD_BRANCH) -X github.com/DataDog/KubeHound/pkg/config.BuildArch=$(BUILD_ARCH) -X github.com/DataDog/KubeHound/pkg/config.BuildOs=$(BUILD_OS)" # Need to save the MAKEFILE_LIST variable before the including the env var files HELP_MAKEFILE_LIST := $(MAKEFILE_LIST) From 1b5a68e11edcbc4746a3a784f29e339ed15c3cb5 Mon Sep 17 00:00:00 2001 From: jt-dd Date: Fri, 6 Sep 2024 11:11:47 +0200 Subject: [PATCH 3/3] revert changes --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3c043de48..cd9515e6d 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ BUILD_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD) BUILD_ARCH := $(shell go env GOARCH) BUILD_OS := $(shell go env GOOS) -BUILD_FLAGS := -ldflags="-X github.com/DataDog/KubeHound/pkg/config.BuildVersion=$(BUILD_VERSION) -X github.com/DataDog/KubeHound/pkg/config.BuildBranch=$(BUILD_BRANCH) -X github.com/DataDog/KubeHound/pkg/config.BuildArch=$(BUILD_ARCH) -X github.com/DataDog/KubeHound/pkg/config.BuildOs=$(BUILD_OS)" +BUILD_FLAGS := -ldflags="-X github.com/DataDog/KubeHound/pkg/config.BuildVersion=$(BUILD_VERSION) -X github.com/DataDog/KubeHound/pkg/config.BuildBranch=$(BUILD_BRANCH) -X github.com/DataDog/KubeHound/pkg/config.BuildArch=$(BUILD_ARCH) -X github.com/DataDog/KubeHound/pkg/config.BuildOs=$(BUILD_OS) -s -w" # Need to save the MAKEFILE_LIST variable before the including the env var files HELP_MAKEFILE_LIST := $(MAKEFILE_LIST)