Skip to content

[CLI] runner-all command is bugged #593

Closed
@weakcamel

Description

@weakcamel

Description of the problem, including code/CLI snippet

There are 2 problems with runner all command in CLI; I'm not sure if they're related to each other or completely independent.

The --id argument is required - while it shouldn't be - and its value seems to be ignored.

With a workaround (added a dummy --id foobar I get the output in the "legacy" format - which is slightly better - but when trying to retrieve it in JSON, it fails again with an exception. Attaching examples below.

Expected Behavior

$ gitlab  runner all --scope active

Expected: successful list of all runners in "legacy" format (whatever it might be)

$ gitlab -o json runner all --scope active

Expected: successful list of all runners in JSON.

Actual Behavior

a) CLI usage failure:

$ gitlab  runner all --scope active
usage: gitlab runner all [-h] --id ID [--scope SCOPE]
gitlab runner all: error: the following arguments are required: --id

b) with a workaround but in JSON or YAML output format:

$ gitlab  -o yaml runner all --scope active --id foobar
Traceback (most recent call last):
  File "/Users/weakcamel/git/gitlab/scripts/venv/bin/gitlab", line 12, in <module>
    sys.exit(main())
  File "/Users/weakcamel/git/gitlab/scripts/venv/lib/python3.7/site-packages/gitlab/cli.py", line 179, in main
    cli_module.run(gl, what, action, args, verbose, output, fields)
  File "/Users/weakcamel/git/gitlab/scripts/venv/lib/python3.7/site-packages/gitlab/v4/cli.py", line 386, in run
    printer.display_list(data, fields, verbose=verbose)
  File "/Users/weakcamel/git/gitlab/scripts/venv/lib/python3.7/site-packages/gitlab/v4/cli.py", line 311, in display_list
    [get_dict(obj, fields) for obj in data],
  File "/Users/weakcamel/git/gitlab/scripts/venv/lib/python3.7/site-packages/gitlab/v4/cli.py", line 311, in <listcomp>
    [get_dict(obj, fields) for obj in data],
  File "/Users/weakcamel/git/gitlab/scripts/venv/lib/python3.7/site-packages/gitlab/v4/cli.py", line 290, in get_dict
    return obj.attributes
AttributeError: 'dict' object has no attribute 'attributes'

$ gitlab  -o json runner all --scope active --id foobar
Traceback (most recent call last):
  File "/Users/weakcamel/git/gitlab/scripts/venv/bin/gitlab", line 12, in <module>
    sys.exit(main())
  File "/Users/weakcamel/git/gitlab/scripts/venv/lib/python3.7/site-packages/gitlab/cli.py", line 179, in main
    cli_module.run(gl, what, action, args, verbose, output, fields)
  File "/Users/weakcamel/git/gitlab/scripts/venv/lib/python3.7/site-packages/gitlab/v4/cli.py", line 386, in run
    printer.display_list(data, fields, verbose=verbose)
  File "/Users/weakcamel/git/gitlab/scripts/venv/lib/python3.7/site-packages/gitlab/v4/cli.py", line 300, in display_list
    print(json.dumps([get_dict(obj, fields) for obj in data]))
  File "/Users/weakcamel/git/gitlab/scripts/venv/lib/python3.7/site-packages/gitlab/v4/cli.py", line 300, in <listcomp>
    print(json.dumps([get_dict(obj, fields) for obj in data]))
  File "/Users/weakcamel/git/gitlab/scripts/venv/lib/python3.7/site-packages/gitlab/v4/cli.py", line 290, in get_dict
    return obj.attributes
AttributeError: 'dict' object has no attribute 'attributes'

Specifications

  • python-gitlab version: 1.6.0
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com): 10.8.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions