Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow relying on the default value of the -addr flag in config-sync #396

Merged
merged 2 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ can be found at [#317](https://github.com/grafana/agent/issues/317).

# Master (unreleased)

- [BUGFIX] Not providing an `-addr` flag for `agentctl config-sync` will no
longer report an error and will instead use the pre-existing default value.
(@rfratto)

# v0.12.0 (2021-02-05)

BREAKING CHANGES: This release has two breaking changes in the configuration
Expand Down
10 changes: 7 additions & 3 deletions cmd/agentctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,16 @@ source-of-truth directory.`,
Args: cobra.ExactArgs(1),

Run: func(_ *cobra.Command, args []string) {
logger := log.NewLogfmtLogger(log.NewSyncWriter(os.Stdout))

if agentAddr == "" {
level.Error(logger).Log("msg", "-addr must not be an empty string")
os.Exit(1)
}

directory := args[0]
cli := client.New(agentAddr)

logger := log.NewLogfmtLogger(log.NewSyncWriter(os.Stdout))

err := agentctl.ConfigSync(logger, cli.PrometheusClient, directory, dryRun)
if err != nil {
level.Error(logger).Log("msg", "failed to sync config", "err", err)
Expand All @@ -85,7 +90,6 @@ source-of-truth directory.`,

cmd.Flags().StringVarP(&agentAddr, "addr", "a", "http://localhost:12345", "address of the agent to connect to")
cmd.Flags().BoolVarP(&dryRun, "dry-run", "d", false, "use the dry run option to validate config files without attempting to upload")
must(cmd.MarkFlagRequired("addr"))
return cmd
}

Expand Down