forked from coop-cloud/abra
feat: add app secret insert
This commit is contained in:
parent
f9ae9c9a56
commit
d68f2f5686
2
TODO.md
2
TODO.md
@ -28,7 +28,7 @@
|
||||
- [ ] `rollback`
|
||||
- [ ] `secret` (WIP: decentral1se)
|
||||
- [ ] `generate` (WIP: decentral1se)
|
||||
- [ ] `insert` (WIP: decentral1se)
|
||||
- [x] `insert`
|
||||
- [x] `rm`
|
||||
- [x] `ls`
|
||||
- [x] `undeploy`
|
||||
|
@ -34,9 +34,46 @@ var appSecretGenerateCommand = &cli.Command{
|
||||
}
|
||||
|
||||
var appSecretInsertCommand = &cli.Command{
|
||||
Name: "insert",
|
||||
Usage: "Insert secret",
|
||||
Name: "insert",
|
||||
Usage: "Insert secret",
|
||||
Flags: []cli.Flag{internal.PassFlag},
|
||||
ArgsUsage: "<secret> <version> <data>",
|
||||
Action: func(c *cli.Context) error {
|
||||
appName := c.Args().First()
|
||||
if appName == "" {
|
||||
internal.ShowSubcommandHelpAndError(c, errors.New("no app name provided"))
|
||||
}
|
||||
|
||||
if c.Args().Len() != 4 {
|
||||
internal.ShowSubcommandHelpAndError(c, errors.New("missing arguments?"))
|
||||
}
|
||||
|
||||
name := c.Args().Get(1)
|
||||
version := c.Args().Get(2)
|
||||
data := c.Args().Get(3)
|
||||
|
||||
appFiles, err := config.LoadAppFiles("")
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
appEnv, err := config.GetApp(appFiles, appName)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
host := appFiles[appName].Server
|
||||
secretName := fmt.Sprintf("%s_%s_%s", appEnv.StackName(), name, version)
|
||||
if err := client.StoreSecret(secretName, data, host); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if internal.Pass {
|
||||
if err := secret.PassInsertSecret(data, name, appEnv.StackName(), host); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user