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

Configuration file validation subcommand for agentctl #336

Merged
merged 2 commits into from
Jan 20, 2021
Merged

Conversation

56quarters
Copy link
Contributor

@56quarters 56quarters commented Jan 19, 2021

Perform basic YAML and type checking for an Agent configuration file
and exit with 1 if there are any errors loading, parsing, or validating
the file.

Fixes #329

PR Checklist

  • CHANGELOG updated
  • Documentation added
  • Tests updated

@56quarters 56quarters marked this pull request as ready for review January 19, 2021 18:49
@rfratto
Copy link
Member

rfratto commented Jan 19, 2021

Thanks for working on this! I won't have time to review this until tomorrow, but I'll look at it as soon as I can

Perform basic YAML and type checking for an Agent configuration file
and exit with `1` if there are any errors loading, parsing, or validating
the file.

Fixes #329
Copy link
Member

@rfratto rfratto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Really straightforward. Just two small comments.

cfg := config.Config{}
err := config.LoadFile(file, expandEnv, &cfg)
if err != nil {
level.Error(logger).Log("msg", "failed to validate config", "err", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'll be easier to read this if we just print normally:

fmt.Fprintf(os.Stderr, "failed to validate config: %s", err)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good

cmd/agentctl/main.go Show resolved Hide resolved
Copy link
Member

@rfratto rfratto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'll merge in a few, but feel free to merge yourself if you see the CI goes green before I'm back at my desk

@rfratto rfratto merged commit 11993da into master Jan 20, 2021
@rfratto rfratto deleted the config-check branch January 20, 2021 14:48
@mattdurham mattdurham mentioned this pull request Sep 7, 2021
3 tasks
mattdurham pushed a commit that referenced this pull request Nov 11, 2021
* Configuration file validation subcommand for agentctl

Perform basic YAML and type checking for an Agent configuration file
and exit with `1` if there are any errors loading, parsing, or validating
the file.

Fixes #329

* CR feedback
@github-actions github-actions bot added the frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed. label Apr 21, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Configuration validation
2 participants