Skip to content

Commit

Permalink
Update the builder to use a consistent binary name.
Browse files Browse the repository at this point in the history
Update the builder to consistently use "ocb" in the name of the command,
version and configuration file.

This fixes #5581.

Signed-off-by: James Peach <[email protected]>
  • Loading branch information
jpeach committed Jul 9, 2022
1 parent 58e66af commit 6bd2d58
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +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)

# 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)
Expand Down Expand Up @@ -206,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:
Expand Down Expand Up @@ -369,3 +370,7 @@ multimod-verify: install-tools
multimod-prerelease: install-tools
multimod prerelease -v ./versions.yaml -m collector-core
$(MAKE) gotidy

.PHONY: clean
clean:
test -d bin && $(RM) bin/*
3 changes: 3 additions & 0 deletions Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ GO_ACC=go-acc
LINT=golangci-lint
IMPI=impi

GOOS := $(shell $(GOCMD) env GOOS)
GOARCH := $(shell $(GOCMD) env GOARCH)

.PHONY: test
test:
$(GOTEST) $(GOTEST_OPT) ./...
Expand Down
4 changes: 4 additions & 0 deletions cmd/builder/Makefile
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
include ../../Makefile.Common

.PHONY: ocb
ocb:
GO111MODULE=on CGO_ENABLED=0 $(GOCMD) build -trimpath -o ../../bin/ocb_$(GOOS)_$(GOARCH) .
8 changes: 2 additions & 6 deletions cmd/builder/internal/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var (
// Command is the main entrypoint for this application
func Command() (*cobra.Command, error) {
cmd := &cobra.Command{
Use: "builder",
Use: "ocb",
Long: fmt.Sprintf("OpenTelemetry Collector distribution builder (%s)", version),
RunE: func(cmd *cobra.Command, args []string) error {
if err := initConfig(); err != nil {
Expand All @@ -59,7 +59,7 @@ func Command() (*cobra.Command, error) {
}

// the external config file
cmd.Flags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.otelcol-builder.yaml)")
cmd.Flags().StringVar(&cfgFile, "config", "$HOME/.ocb.yaml", "config file (default is $HOME/.ocb.yaml)")

// the distribution parameters, which we accept as CLI flags as well
cmd.Flags().BoolVar(&cfg.SkipCompilation, "skip-compilation", false, "Whether builder should only generate go code with no compile of the collector (default false)")
Expand All @@ -83,10 +83,6 @@ func Command() (*cobra.Command, error) {

func initConfig() error {
cfg.Logger.Info("OpenTelemetry Collector distribution builder", zap.String("version", version), zap.String("date", date))
// use the default path if there is no config file being specified
if cfgFile == "" {
cfgFile = "$HOME/.otelcol-builder.yaml"
}

// load the config file
if err := k.Load(file.Provider(cfgFile), yaml.Parser()); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/builder/internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ var (
func versionCommand() *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Version of opentelemetry-collector-builder",
Long: "Prints the version of opentelemetry-collector-builder binary",
Short: "Version of ocb",
Long: "Prints the version of the ocb binary",
Run: func(cmd *cobra.Command, args []string) {
cmd.Println(fmt.Sprintf("%s version %s", cmd.Parent().Name(), version))
},
Expand Down

0 comments on commit 6bd2d58

Please sign in to comment.