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

chore: Audit and normalize CLI options for providing configuration files #12242

Open
spencergilbert opened this issue Apr 15, 2022 · 4 comments
Labels
domain: cli Anything related to Vector's CLI domain: config Anything related to configuring Vector

Comments

@spencergilbert
Copy link
Contributor

The variety of Vector's commands and sub-commands don't share a common experience for providing configuration files to the invoked command. Non exhaustive examples:

vector:

OPTIONS:
    -c, --config <config>
            Read configuration from one or more files. Wildcard paths are supported. File format is
            detected from the file name. If zero files are specified the default config path
            `/etc/vector/vector.toml` will be targeted

            [env: VECTOR_CONFIG=]

    -C, --config-dir <config-dir>
            Read configuration from files in one or more directories. File format is detected from
            the file name.

            Files not ending in .toml, .json, .yaml, or .yml will be ignored.

            [env: VECTOR_CONFIG_DIR=]

        --config-toml <config-toml>
            Read configuration from one or more files. Wildcard paths are supported. TOML file
            format is expected

            [env: VECTOR_CONFIG_TOML=]

        --config-json <config-json>
            Read configuration from one or more files. Wildcard paths are supported. JSON file
            format is expected

            [env: VECTOR_CONFIG_JSON=]

        --config-yaml <config-yaml>
            Read configuration from one or more files. Wildcard paths are supported. YAML file
            format is expected

            [env: VECTOR_CONFIG_YAML=]

vector validate

OPTIONS:
        --config-toml <config-toml>
            Vector config files in TOML format to validate

            [env: VECTOR_CONFIG_TOML=]

        --config-json <config-json>
            Vector config files in JSON format to validate

            [env: VECTOR_CONFIG_JSON=]

        --config-yaml <config-yaml>
            Vector config files in YAML format to validate

            [env: VECTOR_CONFIG_YAML=]

    -C, --config-dir <config-dir>
            Read configuration from files in one or more directories. File format is detected from
            the file name.

            Files not ending in .toml, .json, .yaml, or .yml will be ignored.

            [env: VECTOR_CONFIG_DIR=]

vector config

# No options, does accept ENV VAR based options?

vector graph

OPTIONS:
    -c, --config <config>
            Read configuration from one or more files. Wildcard paths are supported. File format is
            detected from the file name. If zero files are specified the default config path
            `/etc/vector/vector.toml` will be targeted

            [env: VECTOR_CONFIG=]

        --config-toml <config-toml>
            Vector config files in TOML format

        --config-json <config-json>
            Vector config files in JSON format

        --config-yaml <config-yaml>
            Vector config files in YAML format

    -C, --config-dir <config-dir>
            Read configuration from files in one or more directories. File format is detected from
            the file name.

            Files not ending in .toml, .json, .yaml, or .yml will be ignored.

            [env: VECTOR_CONFIG_DIR=]

Proposal:
Move config options into a separate module such that all commands and sub-commands can share a unified set of options when configurations are needed.

@spencergilbert spencergilbert added domain: cli Anything related to Vector's CLI domain: config Anything related to configuring Vector labels Apr 15, 2022
@jszwedko
Copy link
Member

Also vector test which takes the configuration as an argument rather than a flag.

@spencergilbert
Copy link
Contributor Author

Oh I missed that, just looking at the options - it takes them as both ARGS and OPTIONS

vector test

ARGS:
    <PATHS>...
            Any number of Vector config files to test. If none are specified the default config path
            `/etc/vector/vector.toml` will be targeted

OPTIONS:
        --config-toml <config-toml>
            Vector config files in TOML format to test

        --config-json <config-json>
            Vector config files in JSON format to test

        --config-yaml <config-yaml>
            Vector config files in YAML format to test

    -C, --config-dir <config-dir>
            Read configuration from files in one or more directories. File format is detected from
            the file name.

            Files not ending in .toml, .json, .yaml, or .yml will be ignored.

            [env: VECTOR_CONFIG_DIR=]

@jszwedko
Copy link
Member

Just noting that most subcommands that have the same --config flags defined don't actually read the global --config flags (though they could). I believe those global flags primarily exist to run vector with no subcommand. I'm wondering if we may want to think about moving the default command to vector run as not all subcommands take --config flags (like vector generate, vector top, vector tap) and so it's a bit weird that they are global.

jszwedko added a commit that referenced this issue Apr 20, 2022
To match other subcommands that take configuration.

Ref: #12324
Ref: #12242

Signed-off-by: Jesse Szwedko <jesse@szwedko.me>
jszwedko added a commit that referenced this issue Apr 21, 2022
* chore: Mark `vector config` as experimental

This wasn't intended to be publicly released but I don't see a great way
to hide it from `-h` output without some significant refactoring.
Instead, just mark as experimental.

We'll want a bit more QA around this subcommand before marking it
stable. For example, it lacks support for the normal `--config` flags or
an output format.

Signed-off-by: Jesse Szwedko <jesse@szwedko.me>

* fix(config): Add support for flags to `vector config`

To match other subcommands that take configuration.

Ref: #12324
Ref: #12242

Signed-off-by: Jesse Szwedko <jesse@szwedko.me>
jszwedko added a commit that referenced this issue Apr 21, 2022
* chore: Mark `vector config` as experimental

This wasn't intended to be publicly released but I don't see a great way
to hide it from `-h` output without some significant refactoring.
Instead, just mark as experimental.

We'll want a bit more QA around this subcommand before marking it
stable. For example, it lacks support for the normal `--config` flags or
an output format.

Signed-off-by: Jesse Szwedko <jesse@szwedko.me>

* fix(config): Add support for flags to `vector config`

To match other subcommands that take configuration.

Ref: #12324
Ref: #12242

Signed-off-by: Jesse Szwedko <jesse@szwedko.me>
@jszwedko
Copy link
Member

jszwedko commented Oct 4, 2022

See #14688 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: cli Anything related to Vector's CLI domain: config Anything related to configuring Vector
Projects
None yet
Development

No branches or pull requests

2 participants