Skip to content

Commit

Permalink
Consistent config member name with configuration keys
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu committed Nov 4, 2021
1 parent 7e8cc96 commit cd31743
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions cmd/builder/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ func Execute() error {

// 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)")
cmd.Flags().StringVar(&cfg.Distribution.ExeName, "name", "otelcol-custom", "The executable name for the OpenTelemetry Collector distribution")
cmd.Flags().StringVar(&cfg.Distribution.LongName, "description", "Custom OpenTelemetry Collector distribution", "A descriptive name for the OpenTelemetry Collector distribution")
cmd.Flags().StringVar(&cfg.Distribution.Name, "name", "otelcol-custom", "The executable name for the OpenTelemetry Collector distribution")
cmd.Flags().StringVar(&cfg.Distribution.Description, "description", "Custom OpenTelemetry Collector distribution", "A descriptive name for the OpenTelemetry Collector distribution")
cmd.Flags().StringVar(&cfg.Distribution.Version, "version", "1.0.0", "The version for the OpenTelemetry Collector distribution")
cmd.Flags().BoolVar(&cfg.Distribution.IncludeCore, "include-core", true, "Whether the core components should be included in the distribution")
cmd.Flags().StringVar(&cfg.Distribution.OtelColVersion, "otelcol-version", cfg.Distribution.OtelColVersion, "Which version of OpenTelemetry Collector to use as base")
Expand Down
4 changes: 2 additions & 2 deletions cmd/builder/internal/builder/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ type Config struct {
// Distribution holds the parameters for the final binary
type Distribution struct {
Module string `mapstructure:"module"`
ExeName string `mapstructure:"name"`
Name string `mapstructure:"name"`
Go string `mapstructure:"go"`
LongName string `mapstructure:"description"`
Description string `mapstructure:"description"`
OtelColVersion string `mapstructure:"otelcol_version"`
IncludeCore bool `mapstructure:"include_core"`
OutputPath string `mapstructure:"output_path"`
Expand Down
4 changes: 2 additions & 2 deletions cmd/builder/internal/builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ func Compile(cfg Config) error {

cfg.Logger.Info("Compiling")
// #nosec G204
cmd := exec.Command(cfg.Distribution.Go, "build", "-ldflags=-s -w", "-trimpath", "-o", cfg.Distribution.ExeName)
cmd := exec.Command(cfg.Distribution.Go, "build", "-ldflags=-s -w", "-trimpath", "-o", cfg.Distribution.Name)
cmd.Dir = cfg.Distribution.OutputPath
if out, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("failed to compile the OpenTelemetry Collector distribution: %w. Output: %q", err, out)
}
cfg.Logger.Info("Compiled", zap.String("binary", fmt.Sprintf("%s/%s", cfg.Distribution.OutputPath, cfg.Distribution.ExeName)))
cfg.Logger.Info("Compiled", zap.String("binary", fmt.Sprintf("%s/%s", cfg.Distribution.OutputPath, cfg.Distribution.Name)))

return nil
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/builder/internal/scaffold/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func main() {
}
info := component.BuildInfo{
Command: "{{ .Distribution.ExeName }}",
Description: "{{ .Distribution.LongName }}",
Command: "{{ .Distribution.Name }}",
Description: "{{ .Distribution.Description }}",
Version: "{{ .Distribution.Version }}",
}
Expand Down

0 comments on commit cd31743

Please sign in to comment.