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

Default to github-app in provider enroll #3032

Merged
merged 3 commits into from
Apr 11, 2024
Merged

Conversation

dmjb
Copy link
Member

@dmjb dmjb commented Apr 10, 2024

Fixes #2898

Some additional changes have been made as well:

  1. Make the flag to specify the class of provider specific to the enroll
    command. The existing top-level provider flag is left intact, but
    marked as deprecated.
  2. The confirmation box is only shown for the legacy Github app workflow
    as requested in the ticket.
  3. The timeout duration is listed in the CLI output when the browser is
    opened.
  4. Small changes to message verbiage here and there.

Summary

Provide a brief overview of the changes and the issue being addressed.
Explain the rationale and any background necessary for understanding the changes.
List dependencies required by this change, if any.

Fixes #(related issue)

Change Type

Mark the type of change your PR introduces:

  • Bug fix (resolves an issue without affecting existing features)
  • Feature (adds new functionality without breaking changes)
  • Breaking change (may impact existing functionalities or require documentation updates)
  • Documentation (updates or additions to documentation)
  • Refactoring or test improvements (no bug fixes or new functionality)

Testing

Outline how the changes were tested, including steps to reproduce and any relevant configurations.
Attach screenshots if helpful.

Review Checklist:

  • Reviewed my own code for quality and clarity.
  • Added comments to complex or tricky code sections.
  • Updated any affected documentation.
  • Included tests that validate the fix or feature.
  • Checked that related changes are merged.

@dmjb dmjb requested a review from a team as a code owner April 10, 2024 17:42
@dmjb dmjb marked this pull request as draft April 10, 2024 17:43
@coveralls
Copy link

coveralls commented Apr 10, 2024

Coverage Status

coverage: 48.202% (-0.02%) from 48.22%
when pulling 7ed2b14 on default-enroll-github-app
into 471f6de on main.

@dmjb dmjb marked this pull request as ready for review April 10, 2024 18:40
@dmjb dmjb marked this pull request as draft April 10, 2024 18:40
ProviderCmd.PersistentFlags().StringP("project", "j", "", "ID of the project")
// TODO: get rid of this
ProviderCmd.PersistentFlags().StringP("provider", "p", "", "DEPRECATED - use `class` flag of `enroll` instead")
Copy link
Member

Choose a reason for hiding this comment

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

Since this was only useful for the provider enroll command, should it be moved there? Otherwise other commands like provider list see the deprecation message

Copy link
Member Author

@dmjb dmjb Apr 11, 2024

Choose a reason for hiding this comment

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

I left it that way for the sake of backwards compatibility. For example, in the current CLI, it is acceptable to write:

minder provider --provider=github enroll

Which would be broken if we moved that flag down to the leaf node commands as far as I can tell.

I also think that we should consider changing the name of the parameter: in some commands elsewhere in the CLI, provider might mean the name of the provider, here it means the class/type

@@ -275,8 +283,10 @@ func init() {
ProviderCmd.AddCommand(enrollCmd)
// Flags
enrollCmd.Flags().StringP("token", "t", "", "Personal Access Token (PAT) to use for enrollment")
Copy link
Member

Choose a reason for hiding this comment

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

The token is also for legacy GitHub only

Copy link
Contributor

Choose a reason for hiding this comment

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

for now. Other providers (e.g. DockerHub) will make use of this.

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is that with the current approach, this command will end up with every possible optional flag for every possible provider. In the Minder CLI proposal document, I have suggested that we move to a structure with subcommands per provider, e.g.:

minder provider enroll github-app [flags]
minder provider enroll github [flags]
minder provider enroll oci [flags]

However, since we need to maintain backwards compatibility, I am not making this change at this point.

Ria's feedback does raise the issue of whether we should avoid calling certain parts of the code if we are creating a github-app provider

Copy link
Member

Choose a reason for hiding this comment

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

Eventually, it would be nice if we could use the AuthorizationFlows for each provider to create a selection box for the user. For example the legacy github provider support the OAuth flow and the user input flow, so when they run minder provider enroll --class github we could show:

Select your authorization flow:
[] provide the token myself
[] use OAuth 2.0 authorization code flow to generate a token 

Then we remove --token from the parameters of enroll and new providers just have to define their accepted authorization flows.

internal/providers/github/oauth/oauth.go Outdated Show resolved Hide resolved
@dmjb dmjb marked this pull request as ready for review April 11, 2024 07:53
Fixes #2898

Some additional changes have been made as well:

1) Make the flag to specify the class of provider specific to the enroll
   command. The existing top-level provider flag is left intact, but
   marked as deprecated.
2) The confirmation box is only shown for the legacy Github app workflow
   as requested in the ticket.
3) The timeout duration is listed in the CLI output when the browser is
   opened.
4) Small changes to message verbiage here and there.
@dmjb dmjb force-pushed the default-enroll-github-app branch from 45b20cc to f70d601 Compare April 11, 2024 07:53
@dmjb dmjb merged commit 38f5504 into main Apr 11, 2024
20 checks passed
@dmjb dmjb deleted the default-enroll-github-app branch April 11, 2024 08:40
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.

Make GitHub App the default provider in the CLI
4 participants