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

Downgrade github.com/urfave/cli to v1 #1286

Merged
merged 1 commit into from
Sep 9, 2020
Merged

Conversation

yob
Copy link
Contributor

@yob yob commented Sep 9, 2020

Fixes #1285.

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:

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 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).

@yob
Copy link
Contributor Author

yob commented Sep 9, 2020

It's possible to upgrade to the latest v1 release, which uses go modules. I've held off on that fro now though, and stuck with a pure rollback.

Here's what that upgrade would look like.

$ go get github.com/urfave/cli
go: github.com/urfave/cli upgrade => v1.22.4
[jh@tak agent (rollback-ufave-cli-upgrade)]$ git diff
diff --git a/go.mod b/go.mod
index ff1dfbb3..6af3a340 100644
--- a/go.mod
+++ b/go.mod
@@ -26,7 +26,7 @@ require (
        github.com/qri-io/jsonschema v0.0.0-20180607150648-d0d3b10ec792
        github.com/sergi/go-diff v1.0.0 // indirect
        github.com/stretchr/testify v1.5.1
-       github.com/urfave/cli v0.0.0-20180226030253-8e01ec4cd3e2
+       github.com/urfave/cli v1.22.4
        golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073
        golang.org/x/oauth2 v0.0.0-20181003184128-c57b0facaced
        golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f // indirect

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).
@yob yob force-pushed the rollback-ufave-cli-upgrade branch from 3e33d6a to dc81adc Compare September 9, 2020 01:39
Copy link
Member

@pda pda left a comment

Choose a reason for hiding this comment

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

I have verified that for buildkite-agent meta-data get foo --default bar;

  • v3.22.1 returns "bar" with a warning, build success
  • v3.23.0 fails with 404 No key "foo" found, build fails
  • this branch restores v3.22.1 behaviour; returns "bar" with a warning, build success

@pda pda marked this pull request as ready for review September 9, 2020 05:19
@pda pda merged commit 5211d4d into master Sep 9, 2020
@pda pda deleted the rollback-ufave-cli-upgrade branch September 9, 2020 05:19
@pda
Copy link
Member

pda commented Sep 9, 2020

yob added a commit that referenced this pull request Sep 9, 2020
In PR #1233 we upgrade this library to v2, but then reverted it in
PR #1286 after discovering the upgrade lead to a breaking change in our
CLI.

It seems we're stuck on v1 for now, but we may as well update to the
latest v1 release. This takes us to a version with formal go mod
support.
@yob yob mentioned this pull request Apr 11, 2022
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.

Agent meta-data get "--default" not working from version 3.23.0
2 participants