feat: add app secret insert
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
f9ae9c9a56
commit
d68f2f5686
2
TODO.md
2
TODO.md
@ -28,7 +28,7 @@
|
|||||||
- [ ] `rollback`
|
- [ ] `rollback`
|
||||||
- [ ] `secret` (WIP: decentral1se)
|
- [ ] `secret` (WIP: decentral1se)
|
||||||
- [ ] `generate` (WIP: decentral1se)
|
- [ ] `generate` (WIP: decentral1se)
|
||||||
- [ ] `insert` (WIP: decentral1se)
|
- [x] `insert`
|
||||||
- [x] `rm`
|
- [x] `rm`
|
||||||
- [x] `ls`
|
- [x] `ls`
|
||||||
- [x] `undeploy`
|
- [x] `undeploy`
|
||||||
|
@ -34,9 +34,46 @@ var appSecretGenerateCommand = &cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var appSecretInsertCommand = &cli.Command{
|
var appSecretInsertCommand = &cli.Command{
|
||||||
Name: "insert",
|
Name: "insert",
|
||||||
Usage: "Insert secret",
|
Usage: "Insert secret",
|
||||||
|
Flags: []cli.Flag{internal.PassFlag},
|
||||||
|
ArgsUsage: "<secret> <version> <data>",
|
||||||
Action: func(c *cli.Context) error {
|
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
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user