From 3e14ee97d8ad49b112e6df2a6a1521d7cdac4402 Mon Sep 17 00:00:00 2001 From: James Peach Date: Sat, 23 Jul 2022 00:30:52 +1000 Subject: [PATCH] Update the builder to use a consistent binary name. (#5651) Update the builder to consistently use "ocb" in the name of the command, version. Since the builder does not expand environment variables in the config file pathname, the default value for `--config` does not work, so we can make this flag required so that users don't silently build an inoperative collector. This fixes #5581. Signed-off-by: James Peach --- Makefile | 13 ++++++++----- Makefile.Common | 4 ++++ cmd/builder/Makefile | 4 ++++ cmd/builder/README.md | 17 ++++++++++------- cmd/builder/internal/command.go | 25 ++++++++++++++++--------- cmd/builder/internal/version.go | 4 ++-- 6 files changed, 44 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index a5315964189..53652d14390 100644 --- a/Makefile +++ b/Makefile @@ -17,10 +17,6 @@ ALL_MODULES := $(shell find . -type f -name "go.mod" -exec dirname {} \; | sort CMD?= TOOLS_MOD_DIR := ./internal/tools -GOOS=$(shell $(GOCMD) env GOOS) -GOARCH=$(shell $(GOCMD) env GOARCH) -GH := $(shell which gh) - # TODO: Find a way to configure this in the generated code, currently no effect. BUILD_INFO_IMPORT_PATH=go.opentelemetry.io/collector/internal/version VERSION=$(shell git describe --always --match "v[0-9]*" HEAD) @@ -207,6 +203,10 @@ otelcorecol: genotelcorecol: pushd cmd/builder/ && $(GOCMD) run ./ --skip-compilation --config ../otelcorecol/builder-config.yaml --output-path ../otelcorecol && popd +.PHONY: ocb +ocb: + $(MAKE) -C cmd/builder ocb + DEPENDABOT_PATH=".github/dependabot.yml" .PHONY: internal-gendependabot internal-gendependabot: @@ -411,5 +411,8 @@ endif echo "'gh' command not found, can't submit the PR on your behalf."; \ exit 1; \ fi - gh pr create --title "[chore] prepare release $(RELEASE_CANDIDATE)" + $(GH) pr create --title "[chore] prepare release $(RELEASE_CANDIDATE)" +.PHONY: clean +clean: + test -d bin && $(RM) bin/* diff --git a/Makefile.Common b/Makefile.Common index 2b31c5d405e..a5aa1c7dbf8 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -10,6 +10,10 @@ GO_ACC=go-acc LINT=golangci-lint IMPI=impi +GOOS := $(shell $(GOCMD) env GOOS) +GOARCH := $(shell $(GOCMD) env GOARCH) +GH := $(shell which gh) + .PHONY: test test: $(GOTEST) $(GOTEST_OPT) ./... diff --git a/cmd/builder/Makefile b/cmd/builder/Makefile index ded7a36092d..59bde934421 100644 --- a/cmd/builder/Makefile +++ b/cmd/builder/Makefile @@ -1 +1,5 @@ include ../../Makefile.Common + +.PHONY: ocb +ocb: + GO111MODULE=on CGO_ENABLED=0 $(GOCMD) build -trimpath -o ../../bin/ocb_$(GOOS)_$(GOARCH) . diff --git a/cmd/builder/README.md b/cmd/builder/README.md index 6f8eec5a7c9..efe32f3db67 100644 --- a/cmd/builder/README.md +++ b/cmd/builder/README.md @@ -1,4 +1,4 @@ -# OpenTelemetry Collector builder +# OpenTelemetry Collector Builder (ocb) [![CI](https://github.com/open-telemetry/opentelemetry-collector-builder/actions/workflows/go.yaml/badge.svg)](https://github.com/open-telemetry/opentelemetry-collector-builder/actions/workflows/go.yaml?query=branch%3Amain) This program generates a custom OpenTelemetry Collector binary based on a given configuration. @@ -7,7 +7,7 @@ This program generates a custom OpenTelemetry Collector binary based on a given ```console $ GO111MODULE=on go install go.opentelemetry.io/collector/cmd/builder@latest -$ cat > ~/.otelcol-builder.yaml < otelcol-builder.yaml < /tmp/otelcol.yaml <