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

Skip to content

Conversation

@arunsathiya
Copy link
Contributor

This PR adds support for the Sourcegraph CLI. Fixes #144.

Couple of notes:

  • The CLI does not support config file imports. The CLI always expects the Sourcegraph instance host address and the access token to be set as environment variables.
  • The ManagementURL isn't set for now because it's dynamic depending on the Sourcegraph instance host address and the username. In my case, it is https://sourcegraph.com/users/arun/settings/tokens. This case is similar to what happened with ReadMe, so based on this advise from @SimonBarendse, I haven't included ManagementURL field. When Shell Plugins support setting of dynamic ManagementURLs, we can update this plugin.

Here's a quick visualization of the plugin flow:

➜  shell-plugins git:(add/sourcegraph) src login

❌ Problem: No access token is configured.

🛠  To fix: Create an access token at https://sourcegraph.com/user/settings/tokens, then set the following environment variables:

   SRC_ENDPOINT=https://sourcegraph.com
   SRC_ACCESS_TOKEN=(the access token you just created)

   To verify that it's working, run this command again.

➜  shell-plugins git:(add/sourcegraph) op plugin init src
############################################################################
# WARNING: 'sourcegraph' is not from the official registry.                #
# Only proceed if you are the developer of 'sourcegraph'.                  #
# Otherwise, delete the file at /Users/arun/.op/plugins/local/sourcegraph. #
############################################################################

Sourcegraph CLI [test build]
Authenticate with Sourcegraph Access Token.

? Locate your Sourcegraph Access Token: Sourcegraph Access Token (Personal)

? Configure when "Sourcegraph Access Token" will be used to authenticate: Prompt me for each new terminal session

The last step is to set up an alias for src.
You can do so by running the following command:

  source /Users/arun/.op/plugins.sh

Afterwards, run any src command to see it in action!
➜  shell-plugins git:(add/sourcegraph) source ~/.op/plugins.sh
➜  shell-plugins git:(add/sourcegraph) src login
############################################################################
# WARNING: 'sourcegraph' is not from the official registry.                #
# Only proceed if you are the developer of 'sourcegraph'.                  #
# Otherwise, delete the file at /Users/arun/.op/plugins/local/sourcegraph. #
############################################################################

✔️  Authenticated as arun on https://sourcegraph.com

Happy to address any feedback, thanks!

Copy link
Member

@hculea hculea 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 your contribution! I only left one question.

@SimonBarendse
Copy link
Member

Thanks for yet another great contribution @arunsathiya ! 🙌 I've just left a few nitpicks for your consideration

@arunsathiya
Copy link
Contributor Author

Thanks for reviewing, all of you! I have addressed your comments and welcome any other feedback.

@hculea
Copy link
Member

hculea commented Jan 18, 2023

Thanks for reviewing, all of you! I have addressed your comments and welcome any other feedback.

@arunsathiya I don't see any changes since last reviewed, is it possible that you pushed them on a different branch?

@arunsathiya
Copy link
Contributor Author

Sorry about the lack of clarity, @hculea. I meant that I have addressed your feedback verbally. The only pending change is renaming HostAddress field to Endpoint and I am waiting for a clarification on how to proceed with AccessToken vs Token. I wanted to address both suggestions in the code at the same time.

Anyway, I have updated to Endpoint for now.

@hculea
Copy link
Member

hculea commented Jan 19, 2023

Thanks for clarifying. Please, have a look over the thread I started as well: #146 (comment)

@SimonBarendse SimonBarendse merged commit d4822d5 into 1Password:main Jan 26, 2023
@arunsathiya arunsathiya deleted the add/sourcegraph branch January 26, 2023 21:41
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.

New plugin: Sourcegraph

5 participants