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

Netlify shell plugin #333

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Netlify shell plugin #333

wants to merge 1 commit into from

Conversation

joqim
Copy link
Contributor

@joqim joqim commented Jun 29, 2023

Overview

Netlify 1Password shell plugin for Netlify CLI

Type of change

  • Created a new plugin
  • Improved an existing plugin
  • Fixed a bug in an existing plugin
  • Improved contributor utilities or experience

Related Issue(s)

  • Resolves: #
  • Relates: #

How To Test

netlify login

Changelog

The shell plugin looks for the Netlify CLI's environment variables and imports them into 1Password.
If there are no environment variables in the current shell session, 1Password prompts the user to manually enter them.
Provisions the shell plugin for every "netlify" command (except help and version commands) with the environment variables.

Additional information

@arunsathiya arunsathiya self-requested a review June 29, 2023 19:33
@arunsathiya arunsathiya added waiting-on-reviewer signals that a certain PR is waiting for a review from a 1Password team member hashnode hackathon Ideas and inspiration for the hackathon running from June 1st - June 30th labels Jun 29, 2023
@joqim joqim mentioned this pull request Jun 29, 2023
5 tasks
@arunsathiya arunsathiya mentioned this pull request Jul 5, 2023
3 tasks
Copy link
Contributor

@arunsathiya arunsathiya left a comment

Choose a reason for hiding this comment

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

This looks like a good start, thanks for your contribution @joqim!

Importer and provisioner functionally work.

There are a couple of minor things, and a major-ish thing (config file importer's test) to address. Could you give it a try and let us know how things look? We're happy to help if you are stuck.

Secret: true,
Composition: &schema.ValueComposition{
Length: 43,
Prefix: "tGtp-",
Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't look like tGtp- is an actual prefix. I have an entirely different token. Could we remove this?

}

func TryNetlifyConfigFile() sdk.Importer {
return importer.TryFile("~/Library/Preferences/netlify/config.json", func(ctx context.Context, contents importer.FileContents, in sdk.ImportInput, out *sdk.ImportAttempt) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The location varies by the operating system:

https://docs.netlify.com/cli/get-started/#config-json-location

Could we update the importer to support OS-specific locations? importer.MacOnly and importer.LinuxOnly can help, there are some references of them in ngrok shell plugin:

importer.MacOnly(
TryngrokConfigFile("~/Library/Application Support/ngrok/ngrok.yml"),
),
importer.LinuxOnly(
TryngrokConfigFile("~/.config/ngrok/ngrok.yml"),
),

},
ExpectedOutput: sdk.ProvisionOutput{
Environment: map[string]string{
"NETLIFY_TOKEN": "tGtp-IMFGyRcoLdK40zQ4ENKfvDeIOASs1ilEXAMPLE",
Copy link
Contributor

Choose a reason for hiding this comment

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

After removing the prefix (addressed on another comment above), could we run make netlify/example-secrets again and use the new example secret?

func TestPersonalAccessTokenProvisioner(t *testing.T) {
plugintest.TestProvisioner(t, PersonalAccessToken().DefaultProvisioner, map[string]plugintest.ProvisionCase{
"default": {
ItemFields: map[sdk.FieldName]string{ // TODO: Check if this is correct
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove this TODO.

},
},
},
// TODO: If you implemented a config file importer, add a test file example in netlify/test-fixtures
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove this todo and make sure to add a sample file to netlify/test-fixtures folder. ngrok's test-fixtures is a good example again, but we'll use a json file for Netlify.

},
// TODO: If you implemented a config file importer, add a test file example in netlify/test-fixtures
// and fill the necessary details in the test template below.
"config file": {
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that the config file importer is not completed yet. Can we help you with anything here, @joqim?

NeedsAuth: needsauth.IfAll(
needsauth.NotForHelpOrVersion(),
needsauth.NotWithoutArgs(),
needsauth.NotForExactArgs("config"),
Copy link
Contributor

Choose a reason for hiding this comment

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

I am sure I see a config subcommand for netlify. Is there a reason why this is listed? Not seeing it as a command line flag either. 🤔

Name: "Netlify CLI",
Runs: []string{"netlify"},
DocsURL: sdk.URL("https://netlify.com/docs/cli"),
NeedsAuth: needsauth.IfAll(
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we also skip authentication for login and logout?

@arunsathiya arunsathiya self-requested a review July 6, 2023 01:25
@arunsathiya arunsathiya added in-progress this PR is being worked on/comments are in the process of being addressed by the contributor and removed waiting-on-reviewer signals that a certain PR is waiting for a review from a 1Password team member labels Jul 6, 2023
Copy link
Contributor

@arunsathiya arunsathiya left a comment

Choose a reason for hiding this comment

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

Hi @joqim, wondering if you had a chance to review my comments and if there's anything we can help with? Netlify is a fantastic platform, and I am personally a fan -- I'd like to help you get this over to the finish line!

@joqim
Copy link
Contributor Author

joqim commented Jul 11, 2023

Hey @arunsathiya, I apologize as I was occupied until recently. I will get to addressing these changes soon.

@techcraver
Copy link
Contributor

Hey @arunsathiya, I apologize as I was occupied until recently. I will get to addressing these changes soon.

Hey @joqim - curious to know if we can pick this back up? :)

@joqim
Copy link
Contributor Author

joqim commented Aug 9, 2023

Hi @techcraver, thank you for following up. I temporarily don't have access to a Linux instance. I'll be picking up this PR soon.

@hculea
Copy link
Member

hculea commented Sep 19, 2023

Hey @joqim - checking in again to see if there is anything that we can help with, to move this forward? 😄

@joqim
Copy link
Contributor Author

joqim commented Sep 19, 2023

Hey @hculea , I'm hoping to resolve this by this weekend. Will keep you posted if anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hashnode hackathon Ideas and inspiration for the hackathon running from June 1st - June 30th in-progress this PR is being worked on/comments are in the process of being addressed by the contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants