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

cmd-kola: transparently pass unknown flags to kola #1058

Merged
merged 1 commit into from
Jan 16, 2020

Conversation

jlebon
Copy link
Member

@jlebon jlebon commented Jan 15, 2020

Right now we're kind of in a messy situtation where we have some args
for cosa kola, and other args that we want to pass through to kola.
Unfortunately, argparse isn't very good for this use case. Using --
helps sometimes, but the issue arises when we want to pass flags to
both cosa and kola. The obvious --cosa-arg -- --kola-arg doesn't
work (https://bugs.python.org/issue15112).

Instead, just use parse_known_args() to tell argparse to leave the
unknown args untouched. We then pass those through as is to kola. This
also avoids us having to use -- entirely. The caveat is that it can be
confusing if we support a cosa kola arg that kola natively supports,
but let's say we're not going to do this, or if we do, it's to just pass
it through to kola as well as do some auxiliary related thing.

Right now we're kind of in a messy situtation where we have some args
for `cosa kola`, and other args that we want to pass through to `kola`.
Unfortunately, argparse isn't very good for this use case. Using `--`
helps sometimes, but the issue arises when we want to pass flags to
*both* cosa and kola. The obvious `--cosa-arg -- --kola-arg` doesn't
work (https://bugs.python.org/issue15112).

Instead, just use `parse_known_args()` to tell argparse to leave the
unknown args untouched. We then pass those through as is to `kola`. This
also avoids us having to use `--` entirely. The caveat is that it can be
confusing if we support a `cosa kola` arg that `kola` natively supports,
but let's say we're not going to do this, or if we do, it's to just pass
it through to kola as well as do some auxiliary related thing.
@jlebon
Copy link
Member Author

jlebon commented Jan 15, 2020

Another gotcha with this approach is that you want the kola command to come first. E.g. cosa kola run [--cosa-or-kola-arg...], not e.g. cosa kola --my-arg-1 run --my-arg-2. Otherwise, there's no way for argparse to know if the positional arg is actually an argument to an unknown flag.

@jlebon
Copy link
Member Author

jlebon commented Jan 15, 2020

(One related thing I've been thinking about recently though is that we should just thin out the cosa kola layer and teach kola directly about cosa concepts. That'll allow us to fold things like the install test into kola more easily.)

@cgwalters
Copy link
Member

Eventually I think we want kola to really do the right thing out of the box.
But, this is #163

@jlebon jlebon merged commit fd55367 into coreos:master Jan 16, 2020
@jlebon jlebon deleted the pr/kola-args branch January 16, 2020 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants