-
Notifications
You must be signed in to change notification settings - Fork 170
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
base: main
Are you sure you want to change the base?
Netlify shell plugin #333
Conversation
There was a problem hiding this 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-", |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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:
shell-plugins/plugins/ngrok/credentials.go
Lines 51 to 56 in 8df60af
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", |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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": { |
There was a problem hiding this comment.
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"), |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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
?
There was a problem hiding this 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!
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? :) |
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. |
Hey @joqim - checking in again to see if there is anything that we can help with, to move this forward? 😄 |
Hey @hculea , I'm hoping to resolve this by this weekend. Will keep you posted if anything. |
Overview
Netlify 1Password shell plugin for Netlify CLI
Type of change
Related Issue(s)
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