-
Notifications
You must be signed in to change notification settings - Fork 0
Add config search and creation order and set default to ~/.config/lstk/config.toml
#43
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 all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c7cdf7e
Change config search and creation
silv-io 0ca0caf
Change config init definition
silv-io 9a6327b
Add Configuration details to readme
silv-io 824c3a5
Change config path cmd help text
silv-io 684eed0
Remove hardcoded keyring envvar key
silv-io cc8bc0d
Unexport resolved config path
silv-io 89aea35
Split up config file into logical parts
silv-io 08a6bd8
Fix linter error
silv-io b418c4c
Add config initialization to logs prerun
silv-io 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 |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/localstack/lstk/internal/config" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| var configCmd = &cobra.Command{ | ||
| Use: "config", | ||
| Short: "Manage lstk configuration", | ||
| } | ||
|
|
||
| var configPathCmd = &cobra.Command{ | ||
| Use: "path", | ||
| Short: "Print the configuration file path", | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| configPath, err := config.ConfigFilePath() | ||
| if err != nil { | ||
| return err | ||
| } | ||
| _, err = fmt.Fprintln(cmd.OutOrStdout(), configPath) | ||
| return err | ||
| }, | ||
| } | ||
|
|
||
| func init() { | ||
| configCmd.AddCommand(configPathCmd) | ||
| rootCmd.AddCommand(configCmd) | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| package config | ||
|
|
||
| import "fmt" | ||
|
|
||
| type EmulatorType string | ||
|
|
||
| const ( | ||
| EmulatorAWS EmulatorType = "aws" | ||
| EmulatorSnowflake EmulatorType = "snowflake" | ||
| EmulatorAzure EmulatorType = "azure" | ||
|
|
||
| dockerRegistry = "localstack" | ||
| localConfigFileName = "lstk.toml" | ||
| userConfigFileName = "config.toml" | ||
| ) | ||
|
|
||
| var emulatorImages = map[EmulatorType]string{ | ||
| EmulatorAWS: "localstack-pro", | ||
| } | ||
|
|
||
| var emulatorHealthPaths = map[EmulatorType]string{ | ||
| EmulatorAWS: "/_localstack/health", | ||
| } | ||
|
|
||
| type ContainerConfig struct { | ||
| Type EmulatorType `mapstructure:"type"` | ||
| Tag string `mapstructure:"tag"` | ||
| Port string `mapstructure:"port"` | ||
| Env []string `mapstructure:"env"` | ||
| } | ||
|
|
||
| func (c *ContainerConfig) Image() (string, error) { | ||
| productName, err := c.ProductName() | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
| tag := c.Tag | ||
| if tag == "" { | ||
| tag = "latest" | ||
| } | ||
| return fmt.Sprintf("%s/%s:%s", dockerRegistry, productName, tag), nil | ||
| } | ||
|
|
||
| // Name returns the container name: "localstack-{type}" or "localstack-{type}-{tag}" if tag != latest | ||
silv-io marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| func (c *ContainerConfig) Name() string { | ||
| tag := c.Tag | ||
| if tag == "" || tag == "latest" { | ||
| return fmt.Sprintf("localstack-%s", c.Type) | ||
| } | ||
| return fmt.Sprintf("localstack-%s-%s", c.Type, tag) | ||
| } | ||
|
|
||
| func (c *ContainerConfig) HealthPath() (string, error) { | ||
| path, ok := emulatorHealthPaths[c.Type] | ||
| if !ok { | ||
| return "", fmt.Errorf("%s emulator not supported yet by lstk", c.Type) | ||
| } | ||
| return path, nil | ||
| } | ||
|
|
||
| func (c *ContainerConfig) ProductName() (string, error) { | ||
| productName, ok := emulatorImages[c.Type] | ||
| if !ok { | ||
| return "", fmt.Errorf("%s emulator not supported yet by lstk", c.Type) | ||
| } | ||
| return productName, nil | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.