From cd6bfbb121393e0ece575926d9056a32fd91576c Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Thu, 31 Oct 2024 12:16:08 -0700 Subject: [PATCH] Remove reprecated flags from Builder (#11576) Signed-off-by: Bogdan Drutu --- .chloggen/rm-dep-flags.yaml | 26 +++++++++++ cmd/builder/internal/command.go | 70 +++++++----------------------- cmd/builder/test/core.builder.yaml | 2 + cmd/builder/test/test.sh | 9 ++-- 4 files changed, 48 insertions(+), 59 deletions(-) create mode 100644 .chloggen/rm-dep-flags.yaml diff --git a/.chloggen/rm-dep-flags.yaml b/.chloggen/rm-dep-flags.yaml new file mode 100644 index 00000000000..2e86588e38d --- /dev/null +++ b/.chloggen/rm-dep-flags.yaml @@ -0,0 +1,26 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: 'breaking' + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: 'builder' + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Remove deprecated flags from Builder + +# One or more tracking issues or pull requests related to the change +issues: [11576] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: Here is the list of flags | + --name, --description, --version, --otelcol-version, --go, --module + +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [user, api] diff --git a/cmd/builder/internal/command.go b/cmd/builder/internal/command.go index 9ca7cb7ee83..44d9b685ce7 100644 --- a/cmd/builder/internal/command.go +++ b/cmd/builder/internal/command.go @@ -20,19 +20,13 @@ import ( ) const ( - skipGenerateFlag = "skip-generate" - skipCompilationFlag = "skip-compilation" - skipGetModulesFlag = "skip-get-modules" - skipStrictVersioningFlag = "skip-strict-versioning" - ldflagsFlag = "ldflags" - distributionNameFlag = "name" - distributionDescriptionFlag = "description" - distributionVersionFlag = "version" - distributionOtelColVersionFlag = "otelcol-version" - distributionOutputPathFlag = "output-path" - distributionGoFlag = "go" - distributionModuleFlag = "module" - verboseFlag = "verbose" + skipGenerateFlag = "skip-generate" + skipCompilationFlag = "skip-compilation" + skipGetModulesFlag = "skip-get-modules" + skipStrictVersioningFlag = "skip-strict-versioning" + ldflagsFlag = "ldflags" + distributionOutputPathFlag = "output-path" + verboseFlag = "verbose" ) var ( @@ -83,34 +77,10 @@ configuration is provided, ocb will generate a default Collector. cmd.Flags().BoolVar(&cfg.SkipStrictVersioning, skipStrictVersioningFlag, true, "Whether builder should skip strictly checking the calculated versions following dependency resolution") cmd.Flags().BoolVar(&cfg.Verbose, verboseFlag, false, "Whether builder should print verbose output (default false)") cmd.Flags().StringVar(&cfg.LDFlags, ldflagsFlag, "", `ldflags to include in the "go build" command`) - cmd.Flags().StringVar(&cfg.Distribution.Name, distributionNameFlag, "otelcol-custom", "The executable name for the OpenTelemetry Collector distribution") - if err := cmd.Flags().MarkDeprecated(distributionNameFlag, "use config distribution::name"); err != nil { - return nil, err - } - cmd.Flags().StringVar(&cfg.Distribution.Description, distributionDescriptionFlag, "Custom OpenTelemetry Collector distribution", "A descriptive name for the OpenTelemetry Collector distribution") - if err := cmd.Flags().MarkDeprecated(distributionDescriptionFlag, "use config distribution::description"); err != nil { - return nil, err - } - cmd.Flags().StringVar(&cfg.Distribution.Version, distributionVersionFlag, "1.0.0", "The version for the OpenTelemetry Collector distribution") - if err := cmd.Flags().MarkDeprecated(distributionVersionFlag, "use config distribution::version"); err != nil { - return nil, err - } - cmd.Flags().StringVar(&cfg.Distribution.OtelColVersion, distributionOtelColVersionFlag, cfg.Distribution.OtelColVersion, "Which version of OpenTelemetry Collector to use as base") - if err := cmd.Flags().MarkDeprecated(distributionOtelColVersionFlag, "use config distribution::otelcol_version"); err != nil { - return nil, err - } cmd.Flags().StringVar(&cfg.Distribution.OutputPath, distributionOutputPathFlag, cfg.Distribution.OutputPath, "Where to write the resulting files") if err := cmd.Flags().MarkDeprecated(distributionOutputPathFlag, "use config distribution::output_path"); err != nil { return nil, err } - cmd.Flags().StringVar(&cfg.Distribution.Go, distributionGoFlag, "", "The Go binary to use during the compilation phase. Default: go from the PATH") - if err := cmd.Flags().MarkDeprecated(distributionGoFlag, "use config distribution::go"); err != nil { - return nil, err - } - cmd.Flags().StringVar(&cfg.Distribution.Module, distributionModuleFlag, "go.opentelemetry.io/collector/cmd/builder", "The Go module for the new distribution") - if err := cmd.Flags().MarkDeprecated(distributionModuleFlag, "use config distribution::module"); err != nil { - return nil, err - } // version of this binary cmd.AddCommand(versionCommand()) @@ -184,27 +154,17 @@ func applyCfgFromFile(flags *flag.FlagSet, cfgFromFile builder.Config) { if !flags.Changed(skipStrictVersioningFlag) && cfgFromFile.SkipStrictVersioning { cfg.SkipStrictVersioning = cfgFromFile.SkipStrictVersioning } - if !flags.Changed(distributionNameFlag) && cfgFromFile.Distribution.Name != "" { - cfg.Distribution.Name = cfgFromFile.Distribution.Name - } - if !flags.Changed(distributionDescriptionFlag) && cfgFromFile.Distribution.Description != "" { - cfg.Distribution.Description = cfgFromFile.Distribution.Description - } - if !flags.Changed(distributionVersionFlag) && cfgFromFile.Distribution.Version != "" { - cfg.Distribution.Version = cfgFromFile.Distribution.Version - } - if !flags.Changed(distributionOtelColVersionFlag) && cfgFromFile.Distribution.OtelColVersion != "" { - cfg.Distribution.OtelColVersion = cfgFromFile.Distribution.OtelColVersion - } + if !flags.Changed(distributionOutputPathFlag) && cfgFromFile.Distribution.OutputPath != "" { cfg.Distribution.OutputPath = cfgFromFile.Distribution.OutputPath } - if !flags.Changed(distributionGoFlag) && cfgFromFile.Distribution.Go != "" { - cfg.Distribution.Go = cfgFromFile.Distribution.Go - } - if !flags.Changed(distributionModuleFlag) && cfgFromFile.Distribution.Module != "" { - cfg.Distribution.Module = cfgFromFile.Distribution.Module - } + + cfg.Distribution.Name = cfgFromFile.Distribution.Name + cfg.Distribution.Description = cfgFromFile.Distribution.Description + cfg.Distribution.Version = cfgFromFile.Distribution.Version + cfg.Distribution.OtelColVersion = cfgFromFile.Distribution.OtelColVersion + cfg.Distribution.Go = cfgFromFile.Distribution.Go + cfg.Distribution.Module = cfgFromFile.Distribution.Module cfg.Distribution.BuildTags = cfgFromFile.Distribution.BuildTags cfg.Distribution.DebugCompilation = cfgFromFile.Distribution.DebugCompilation } diff --git a/cmd/builder/test/core.builder.yaml b/cmd/builder/test/core.builder.yaml index e7708b9cbf3..be41ea341f8 100644 --- a/cmd/builder/test/core.builder.yaml +++ b/cmd/builder/test/core.builder.yaml @@ -1,6 +1,8 @@ dist: + name: core module: go.opentelemetry.io/collector/builder/test/core otelcol_version: 0.112.0 + go: ${GOBIN} extensions: - gomod: go.opentelemetry.io/collector/extension/zpagesextension v0.112.0 diff --git a/cmd/builder/test/test.sh b/cmd/builder/test/test.sh index 317f1208d4d..bcedc7433f1 100755 --- a/cmd/builder/test/test.sh +++ b/cmd/builder/test/test.sh @@ -11,6 +11,7 @@ GOBIN=$(go env GOBIN) if [[ "$GO" == "" ]]; then GOBIN=$(which go) fi +export GOBIN if [[ "$GOBIN" == "" ]]; then echo "Could not determine which Go binary to use." @@ -33,15 +34,15 @@ test_build_config() { final_build_config=$(basename "${build_config}") "${WORKSPACE_DIR}/.tools/envsubst" < "$build_config" > "${out}/${final_build_config}" - if ! go run . --go "${GOBIN}" --config "${out}/${final_build_config}" --output-path "${out}" --name otelcol-built-test > "${out}/builder.log" 2>&1; then + if ! go run . --config "${out}/${final_build_config}" --output-path "${out}" > "${out}/builder.log" 2>&1; then echo "❌ FAIL ${test}. Failed to compile the test ${test}. Build logs:" cat "${out}/builder.log" failed=true return fi - if [ ! -f "${out}/otelcol-built-test" ]; then - echo "❌ FAIL ${test}. Binary not found for ${test} at '${out}/otelcol-built-test'. Build logs:" + if [ ! -f "${out}/${test}" ]; then + echo "❌ FAIL ${test}. Binary not found for ${test} at '${out}/${test}'. Build logs:" cat "${out}/builder.log" failed=true return @@ -54,7 +55,7 @@ test_build_config() { return fi - "${out}/otelcol-built-test" --config "./test/${test}.otel.yaml" > "${out}/otelcol.log" 2>&1 & + "${out}/${test}" --config "./test/${test}.otel.yaml" > "${out}/otelcol.log" 2>&1 & pid=$! retries=0