Skip to content

Conversation

dwightjl
Copy link
Contributor

@dwightjl dwightjl commented Mar 7, 2019

  • Add hostname and account arguments to the argument parser.
  • Remove unnecessary argument defaults.
  • Modify main to accommodate the new arguments.

These changes allow users to run this example outside of a Compute Engine environment if they want.

- Add hostname and account arguments to the argument parser.
- Modify main to accommodate the new arguments.

These changes allow users to run this example outside of a Compute Engine environment if they want.
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Mar 7, 2019
args = parser.parse_args()

main(args.cmd, args.project, args.instance, args.zone)
main(args.cmd, args.project, args.instance, args.zone,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be instance=args.instance, zone=args.zone here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch this could fail in some situations. Thanks!

cmd, project, instance, zone, oslogin=None, account=None, hostname=None
):
def main(cmd, project, instance=None, zone=None,
oslogin=None, account=None, hostname=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

oslogin is not provided by the call from the body below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It shouldn't be necessary unless your application is initializing the API manually. service_account_ssh_test.py does this because it cannot manage SSH keys on the behalf of another service account, so it has to obtain the API key for the service account and initialize the API manually. If you don't provide an oslogin object, main() will generate one for you using whatever application default credentials it can obtain from the instance or environment variables.

Copy link
Contributor

@engelke engelke left a comment

Choose a reason for hiding this comment

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

LGTM

@engelke engelke merged commit 424a14c into GoogleCloudPlatform:master Mar 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants