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

Add support for pass-through of aws flags #6

Open
zstumgoren opened this issue Feb 24, 2017 · 0 comments
Open

Add support for pass-through of aws flags #6

zstumgoren opened this issue Feb 24, 2017 · 0 comments
Assignees
Milestone

Comments

@zstumgoren
Copy link
Contributor

zstumgoren commented Feb 24, 2017

The initial implementation of the push and pull commands supports pass-through of boolean commands.

Would be nice to also add support for passing through aws s3 sync command flags that accept values, in particular --include and --exclude.

A convention for passing in sync flags is required because their native format (using leading double dashes such as in --delete) causes errors in argparse at the datakit layer, which interprets such commands as missing arguments for its own parser.

A proposed syntax for pass-through arguments is below.

Implementation

Will likely need a custom argument parser class to properly parse and escape incoming command-line arguments, based on our custom convention (see below).

The argparser for the datakit-data commands (push and pull) will use the argparse.REMAINDER strategy, as below, to gather all pass-through flags:

  class Push(ProjectMixin, CommandHelpers, Command):

      "Push local data to S3"

      def get_parser(self, prog_name):
          parser = super(Push, self).get_parser(prog_name)
          parser.add_argument('args', nargs=argparse.REMAINDER)
          return parser

Custom pass-through args syntax

Below is a first pass at syntax for passing through cli flags for the aws s3 sync command. Basically, it involves:

  • dropping the leading -- on boolean arguments
  • for args that accept values, using an = sign to separate flag from values (This will require some careful handling in the arg parser because the --grants flag accepts values that include the equals sign
  • for args that accept multiple values, use commas to separate the values (--grants is potentially multivalue option)

We'll need to ensure proper escaping/handling of matching patterns for --include and --exclude

# Boolean flags
datakit data:push dryrun # => --dry-run

# Flags with values
datakit data:push include=.* # => --include .*
@zstumgoren zstumgoren self-assigned this Feb 24, 2017
@zstumgoren zstumgoren modified the milestone: 0.2 Feb 24, 2017
zstumgoren added a commit that referenced this issue Jan 17, 2018
- Sub spaces for colons in command entry_points
- Update docs to reflect removal of colons from command names
- Update tests to reflect removal of colons from command names
- Bump plugin version to 0.2.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant