Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@bsamseth
Copy link
Contributor

This adds support for the Databricks CLI.

This CLI needs to know a "host" URL to the instance of Databricks you're working with, as well as your credentials that are specific to that instance. Personal access tokens are they primary way to authenticate, while username+password is possible but discouraged.

I've tested this on my own config, and both import and usage seems to work just fine 💯 Please let me know if you'd like to see more test cases or anything else before accepting.

import

A couple notes:

  • I've opted for the "Person Access Token" credentials type, despite username+password being an option. The code here handles both cases, but the label of "Personal Access Token" isn't quite right in both cases. I still think it should be as I've proposed here to encourage the recommended flow, but an alternative would be to use a more generic "Configuration" label. A second opinion here would be nice 🙂
  • When doing op plugin list, this plugin shows up with REQUIRED FIELDS: host. This is because while you do need to provide either a token or a username and password, neither of them can be marked as required on their own. Probably not a big deal, but resolving it can't really be done without making some changes to schema.CredentialField and related code.
  • The config files at the moment typically also includes a jobs-api-version = 2.x line. This is ignored by the plugin with the following reasoning:
    1. Unlike the other config options, the CLI does not accept setting the API version with an environment variable. In order to support this the plugin would have to make use of the file-based provisioning variant, as well as add a highly specific field definition to the SDK. While possible, I don't believe it is justified given the next two points.
    2. The version can be set with a command line flag, and is only relevant for the databricks jobs subcommand.
    3. Perhaps most importantly, this version flag is temporary, and future versions of the CLI will default to the newer API version.

@AndyTitu AndyTitu self-requested a review January 16, 2023 09:59
@AndyTitu
Copy link
Contributor

@DCKcode @SimonBarendse for sec review.

@SimonBarendse
Copy link
Member

SimonBarendse commented Jan 16, 2023

I've opted for the "Person Access Token" credentials type, despite username+password being an option. The code here handles both cases, but the label of "Personal Access Token" isn't quite right in both cases. I still think it should be as I've proposed here to encourage the recommended flow, but an alternative would be to use a more generic "Configuration" label. A second opinion here would be nice 🙂

I agree that the product can be opinionated towards the desired option. This also provides the best experience for the most common case of following Databricks recommended method of authentication (more closely matching wording).

I'd like to consider if we can even go one step further and choose to not support username+password at all. This will allow us to set the personal access token as required, which has the following advantages:

  • op plugin init currently only prompts the user to set required fields. For this plugin, we'll definitely want to prompt for the personal access token during initialization.
  • Simpler documentation, as we can omit username+password specifics. So the user does not need to consider which to use. They just have the single option.
  • We help the user towards Databricks recommended form of authentication.
  • op plugin list outputs the correct requirements, as you already pointed out.

Copy link
Member

@SimonBarendse SimonBarendse left a comment

Choose a reason for hiding this comment

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

Thank you for an excellent contribution @bsamseth! Really appreciate your notes, makes it easier for us to think along and discuss. 🙌

I've also commented a small suggestion based on code review.

@SimonBarendse SimonBarendse requested a review from DCKcode January 16, 2023 10:36
@florisvdg
Copy link
Contributor

I'd indeed remove the username and password fields and make the token field required. If we want to support both credential types, then we should create separate CredentialType structs for them.

@bsamseth
Copy link
Contributor Author

bsamseth commented Jan 17, 2023

I've removed username+password and made the token field required. Let me know if there's anything else you would want changed 👍🏻

(👇🏻 I meant to re-request the review, but apparently that removes the other pending review requests, and I can't re-add. Sorry about that @DCKcode and @AndyTitu )

@bsamseth bsamseth requested review from SimonBarendse and removed request for AndyTitu and DCKcode January 17, 2023 07:42
Copy link
Member

@SimonBarendse SimonBarendse left a comment

Choose a reason for hiding this comment

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

Thanks again! 💚

@AndyTitu AndyTitu merged commit 8a0e1bf into 1Password:main Jan 18, 2023
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.

5 participants