-
Notifications
You must be signed in to change notification settings - Fork 303
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
update github.com/urfave/cli to v2 #1233
Conversation
github.com/urfave/cli has started using go modules, and has released v2 with some breaking changes to the API. Nothing major, mostly just cosmetic changes. I don't think there's any change in behavior that affects us. I followed the migration guide at [1], then fixed the remaining compiler errors. [1] https://github.com/urfave/cli/blob/master/docs/migrate-v1-to-v2.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work.
Testing locally, buildkite-agent start
seems fine 👍🏼
Maybe we should merge it, get it into an edge release, and verify it with some of our builds, with artifacts etc?
This method is used to ensure Environment Variables that configure the agent process aren't automatically passed down to the child process that runs each job. We want to be very explicit about which variables end up in the job process. It's implemented using reflection on the flag structs from the ufave/cli package we use for CLI structure. It checks the EnvVar field on the flag struct, which works just fine with ufave/cli/v1. However, that field doesn't exist any more in ufave/cli/v2 and this method has started silently failing since we upgraded to v2 in #1233. I haven't added tests because no files in this package have tests and I'm not 100% sure where to start adding them. However, I'm treating this like an assertion. If the reflection doesn't work the way we expect, we hard exit with an error, like other should-never-happen errors in agent_start.go. I'll fix the method to work with ufave/cli/v2 in the following commit.
I think this actually changed a bunch of how the CLI worked, with this heading in particular being dangerous for us: https://github.com/urfave/cli/blob/master/docs/migrate-v1-to-v2.md#flags-before-args This means that, for instance, this command: buildkite-agent meta-data get my-key --default fallback doesn’t do what the user expects (the “default” flag in this is just completely ignored), and as of this patch, it is required to be written like this: buildkite-agent meta-data get --default fallback my-key which is a major, breaking change. |
yer, what a nasty change 😢 There's some discussion here too #1285 |
There’s some discussion of making it less stringent in urfave/cli#1113, but it doesn’t look like it’s moving too fast. |
In #1233 we upgraded github.com/urfave/cli from v1 to v2. There was no functional need for the upgrade, it was just about bumping our dependencies and continuing to slowly adopt go modules. However, I overlooked that v2 changed some rules for ordering of flags and arguments. From the [upgrade guide](https://github.com/urfave/cli/blob/master/docs/migrate-v1-to-v2.md): > In v2 flags must come before args. This is more POSIX-compliant. You may need to update scripts, user documentation, etc. > > This will work: > > cli hello --shout rick > > This will not: > > cli hello rick --shout We're not keen on breaking our users scripts, so let's rollback to v1. There's an [open issue upstream](urfave/cli#1113) about the new ordering rules. We'll keep an eye on that, and maybe re-try the upgrade if it becomes possible to do so in a non-breaking way This is mostly a revert of PR #1233, but with a few extra changes to things that happened after that PR (like adding the `artifact search` subcommand).
In #1233 we upgraded github.com/urfave/cli from v1 to v2. There was no functional need for the upgrade, it was just about bumping our dependencies and continuing to slowly adopt go modules. However, I overlooked that v2 changed some rules for ordering of flags and arguments. From the [upgrade guide](https://github.com/urfave/cli/blob/master/docs/migrate-v1-to-v2.md): > In v2 flags must come before args. This is more POSIX-compliant. You may need to update scripts, user documentation, etc. > > This will work: > > cli hello --shout rick > > This will not: > > cli hello rick --shout We're not keen on breaking our users scripts, so let's rollback to v1. There's an [open issue upstream](urfave/cli#1113) about the new ordering rules. We'll keep an eye on that, and maybe re-try the upgrade if it becomes possible to do so in a non-breaking way This is mostly a revert of PR #1233 and #1250, but with a few extra changes to things that happened after that PR (like adding the `artifact search` subcommand).
In #1233 we upgraded github.com/urfave/cli from v1 to v2. There was no functional need for the upgrade, it was just about bumping our dependencies and continuing to slowly adopt go modules. However, I overlooked that v2 changed some rules for ordering of flags and arguments. From the [upgrade guide](https://github.com/urfave/cli/blob/master/docs/migrate-v1-to-v2.md): > In v2 flags must come before args. This is more POSIX-compliant. You may need to update scripts, user documentation, etc. > > This will work: > > cli hello --shout rick > > This will not: > > cli hello rick --shout We're not keen on breaking our users scripts, so let's rollback to v1. There's an [open issue upstream](urfave/cli#1113) about the new ordering rules. We'll keep an eye on that, and maybe re-try the upgrade if it becomes possible to do so in a non-breaking way This is mostly a revert of PR #1233 and #1250, but with a few extra changes to things that happened after that PR (like adding the `artifact search` subcommand).
github.com/urfave/cli
has started using go modules, and has released v2 with some breaking changes to the API. Nothing major, mostly just cosmetic changes.I don't think there's any change in behavior that affects us.
I followed the migration guide, then fixed the remaining compiler errors.
I recommend reviewing the diff with whitespace changes hidden.