-
Notifications
You must be signed in to change notification settings - Fork 31
feat: support loading a dotenv '.env' file for your app #436
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c438267
feat: load environment variables from '.env' file for hook commands
zimeg fb0cce1
Merge branch 'main' into zimeg-feat-load-hook-dotenv
zimeg 0266d17
Merge branch 'main' into zimeg-feat-load-hook-dotenv
zimeg 72828ec
test: make clear the purpose of env var hook tests
zimeg f63d0ff
refactor: use a slackdotenv package for reading variables from .env file
zimeg 4b29a23
docs: godoc slackdotenv
zimeg 2324d5f
Merge branch 'main' into zimeg-feat-load-hook-dotenv
zimeg 9160bcc
refactor: set command shell environment variables from hook options
zimeg 7dfc00d
test: assert expected cases of shell environment are parsed in order
zimeg c1382df
test: confirm inline comments are ignored
zimeg 525f693
feat: output warning for invalid .env file parsing
zimeg 6cadb2d
chore: claude errorcodes
zimeg 9e3734a
Merge branch 'main' into zimeg-feat-load-hook-dotenv
mwbrooks 64b67f6
Merge branch 'main' into zimeg-feat-load-hook-dotenv
zimeg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,24 +17,10 @@ package config | |
| import ( | ||
| "strings" | ||
|
|
||
| "github.com/joho/godotenv" | ||
| "github.com/slackapi/slack-cli/internal/version" | ||
| "github.com/spf13/afero" | ||
| ) | ||
|
|
||
| // GetDotEnvFileVariables collects only the variables in the .env file | ||
| func (c *Config) GetDotEnvFileVariables() (map[string]string, error) { | ||
| variables := map[string]string{} | ||
| file, err := afero.ReadFile(c.fs, ".env") | ||
| if err != nil && !c.os.IsNotExist(err) { | ||
| return variables, err | ||
| } | ||
| return godotenv.UnmarshalBytes(file) | ||
| } | ||
|
Comment on lines
-25
to
-33
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📦 note: This is moved to our own |
||
|
|
||
| // LoadEnvironmentVariables sets flags based on their environment variable value | ||
| // | ||
| // Note: Values are not loaded from the .env file. Use: `GetDotEnvFileVariables` | ||
| func (c *Config) LoadEnvironmentVariables() error { | ||
| // Skip when dependencies are not configured | ||
| if c.os == nil { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🔭 note: Standalone protocol setups must define
fsto access.envbut we don't error otherwise. AFAICT this is required for just thedeployandruncommands.