-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add gpg store * refactor config to not use aws specific session * add local store * add ability to write to file * read and write config * implement delete many * make stage optional * remove examples * implement get command * set default db dir * refactor printing summary * refactor to set filepath in config * wip gpg store * update install script
- Loading branch information
Showing
24 changed files
with
1,147 additions
and
219 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,55 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/adikari/safebox/v2/store" | ||
"github.com/pkg/errors" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
getParam string | ||
|
||
getCmd = &cobra.Command{ | ||
Use: "get", | ||
Short: "Gets parameter", | ||
RunE: getE, | ||
} | ||
) | ||
|
||
func init() { | ||
getCmd.Flags().StringVarP(&getParam, "param", "p", "", "parameter to get") | ||
getCmd.MarkFlagRequired("param") | ||
|
||
rootCmd.AddCommand(getCmd) | ||
} | ||
|
||
func getE(_ *cobra.Command, _ []string) error { | ||
config, err := loadConfig() | ||
|
||
if err != nil { | ||
return errors.Wrap(err, "failed to load config") | ||
} | ||
|
||
st, err := store.GetStore(store.StoreConfig{ | ||
Provider: config.Provider, | ||
Region: config.Region, | ||
FilePath: config.Filepath, | ||
}) | ||
|
||
if err != nil { | ||
return errors.Wrap(err, "failed to instantiate store") | ||
} | ||
|
||
found, err := st.Get(store.ConfigInput{Name: fmt.Sprintf("%s%s", config.Prefix, getParam)}) | ||
|
||
if err != nil { | ||
return errors.Wrap(err, "failed to get param") | ||
} | ||
|
||
if found != nil { | ||
fmt.Printf("%s\n", *found.Value) | ||
} | ||
return nil | ||
} |
This file contains 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 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 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,38 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
c "github.com/adikari/safebox/v2/config" | ||
) | ||
|
||
type Summary struct { | ||
Message string | ||
Config c.Config | ||
} | ||
|
||
func PrintSummary(s Summary) { | ||
msg := "" | ||
|
||
if s.Message != "" { | ||
msg += fmt.Sprintf("%s", s.Message) | ||
} | ||
|
||
if s.Config.Service != "" && s.Config.Provider != "gpg" { | ||
msg += fmt.Sprintf(", service = %s", s.Config.Service) | ||
} | ||
|
||
if s.Config.Stage != "" { | ||
msg += fmt.Sprintf(", stage = %s", s.Config.Stage) | ||
} | ||
|
||
if s.Config.Region != "" && s.Config.Provider != "gpg" { | ||
msg += fmt.Sprintf(", region = %s", s.Config.Region) | ||
} | ||
|
||
if s.Config.Provider == "gpg" { | ||
msg += fmt.Sprintf(", file = %s", s.Config.Filepath) | ||
} | ||
|
||
fmt.Printf("%s\n", msg) | ||
} |
This file contains 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.