diff --git a/Makefile b/Makefile index c05f41912a4..3035d38c5a6 100644 --- a/Makefile +++ b/Makefile @@ -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) @@ -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: @@ -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/* diff --git a/Makefile.Common b/Makefile.Common index 2b31c5d405e..f78d9c138f3 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -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) ./... 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/internal/command.go b/cmd/builder/internal/command.go index 3dee3a6e586..e6bc4a86bdf 100644 --- a/cmd/builder/internal/command.go +++ b/cmd/builder/internal/command.go @@ -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 { @@ -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)") @@ -83,10 +83,8 @@ 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" - } + + cfg.Logger.Info("Using config file", zap.String("path", cfgFile)) // load the config file if err := k.Load(file.Provider(cfgFile), yaml.Parser()); err != nil { @@ -105,6 +103,5 @@ func initConfig() error { return err } - cfg.Logger.Info("Using config file", zap.String("path", cfgFile)) return nil } diff --git a/cmd/builder/internal/version.go b/cmd/builder/internal/version.go index e2ee5887ff8..78a00c549fd 100644 --- a/cmd/builder/internal/version.go +++ b/cmd/builder/internal/version.go @@ -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)) },