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

Feature: Interactive Role Finder #87

Merged
merged 24 commits into from
Aug 28, 2021

Conversation

nsiow
Copy link
Contributor

@nsiow nsiow commented Aug 27, 2021

Overview

This PR implements an interactive role finder in the terminal, built on top of the existing promptui dependency. The goal of this feature is to allow the user to browse available roles and search for roles in the instance where they know roughly what the desired role is, but do not have the entire role ARN on hand.

Dependencies

#86

Implementation

For weep commands that expect a role argument (export + file), the required role argument is now optional. If the role is not provided, an interactive prompt will be displayed with all roles available to the user. This prompt uses a fuzzy-search that allows users to use approximate text searches to filter the role list in realtime.

The prompt is disabled in two cases:

  • weep is being run from a source other than an interactive terminal (where prompting for input is not helpful)
  • The user specifies WEEP_DISABLE_INTERACTIVE_PROMPTS=1 in their shell environment

In the event that a role is not supplied and the prompt is not generated, weep will fail with an error as it did previously.

Notes to Reviewers

  • At the moment, prompting is enabled by default as I believe it will be the most configuration for new and existing weep users. If we would like to keep behavior more consistent with the current implementation, we could have prompts disabled by default and have some options such as (a) adding a separate command-line flag to prompt (b) adding a separate environment variable that must be set by the user to enable prompts

  • This feature was omitted from weep serve since it already has a valid zero-argument form. Open to ideas on how we might be able to intelligently determine if the user wants this zero-argument form vs would like to be prompted, but nothing I thought of felt intuitive

  • This feature was omitted from weep open since it has many other valid types of input other than IAM roles, and so we would not be sure what to prompt in this case

  • Code for this feature was kept out of prompt.go since it uses the ConsoleMe API functionality directly and introduces a circular dependency between those modules and util. I put it in a helpers.go file in cmd/ instead since it only would be used in the context of the CLI, but open to other ideas

Demo

weep_pr

Copy link
Contributor

@patricksanders patricksanders left a comment

Choose a reason for hiding this comment

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

Love this

@patricksanders patricksanders merged commit 5ef5b4a into Netflix:master Aug 28, 2021
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.

2 participants