Skip to content

Commit

Permalink
umoci config: disable flag argument re-ordering
Browse files Browse the repository at this point in the history
It turns out that urfave/cli hasn't been happy with parsing
command-lines like [--config.cmd -c] for quite some time, and only just
exposed the issue in a test-case[1]. There are loads of more subtle
cases where you could see this happened even in the version of
urfave/cli we have vendored.

Until it's fixed upstream (which might not happen), we have to work
around this by disabling argument reordering for 'umoci config' (which
is the only command that usually has to deal with such flag arguments,
and luckily doesn't take any positional arguments).

[1]: urfave/cli#1152

Signed-off-by: Aleksa Sarai <asarai@suse.de>
  • Loading branch information
cyphar committed Jun 20, 2020
1 parent 9734388 commit fce76f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Expand Up @@ -13,8 +13,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased] ##
### Fixed ###
- Suppress repeated xattr warnings on destination filesystems that do not
support xattrs.
support xattrs. opencontainers/umoci#311
- Work around a long-standing issue in our command-line parsing library (see
urfave/cli#1152) by disabling argument re-ordering for `umoci config`, which
often takes `-`-prefixed flag arguments. opencontainers/umoci#328

## [0.4.5] - 2019-12-04 ##
### Added ###
Expand Down
12 changes: 12 additions & 0 deletions cmd/umoci/config.go
Expand Up @@ -59,6 +59,18 @@ image.`,
return nil
},

// Do not re-order arguments.
//
// It turns out that urfave/cli incorrectly handles cases like
// [--config.cmd -c] during argument re-ordering for subcommands, causing
// us a fair number of issues when users are trying to pass a flag an
// argument that starts with a dash. Luckily 'umoci config' doesn't take
// positional arguments, so disabling argument re-ordering has no other
// real effect.
//
// See <https://github.com/urfave/cli/issues/1152> for more details.
SkipArgReorder: true,

Flags: []cli.Flag{
cli.StringFlag{Name: "config.user"},
cli.StringSliceFlag{Name: "config.exposedports"},
Expand Down

0 comments on commit fce76f4

Please sign in to comment.