Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1892fd9e8a | ||
|
|
aa3d497139 |
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package hmsecrets
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
@@ -20,7 +21,11 @@ var getArrCmd = &cobra.Command{
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(secret)
|
||||
secretJSON, err := json.MarshalIndent(secret, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(string(secretJSON))
|
||||
return nil
|
||||
},
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package hmsecrets
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
@@ -20,7 +21,11 @@ var getMapCmd = &cobra.Command{
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(secret)
|
||||
secretJSON, err := json.MarshalIndent(secret, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(string(secretJSON))
|
||||
return nil
|
||||
},
|
||||
}
|
||||
@@ -1,22 +1,35 @@
|
||||
package hmsecrets
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var arrValue []string
|
||||
var arrFile string
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(setArrCmd)
|
||||
|
||||
setArrCmd.Flags().StringArrayVarP(
|
||||
&arrValue,
|
||||
"array-value",
|
||||
"value",
|
||||
"v",
|
||||
nil,
|
||||
"array value to store in the secret",
|
||||
)
|
||||
setArrCmd.MarkFlagRequired("array-value")
|
||||
setArrCmd.Flags().StringVarP(
|
||||
&arrFile,
|
||||
"value-file",
|
||||
"f",
|
||||
"",
|
||||
"file that contains the secret value (in json) to set",
|
||||
)
|
||||
|
||||
setArrCmd.MarkFlagsOneRequired("value-file", "value")
|
||||
}
|
||||
|
||||
var setArrCmd = &cobra.Command{
|
||||
@@ -25,6 +38,16 @@ var setArrCmd = &cobra.Command{
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cli := getClient()
|
||||
if arrFile != "" {
|
||||
arrJSONBytes, err := os.ReadFile(arrFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("reading array value file: %w", err)
|
||||
}
|
||||
err = json.Unmarshal(arrJSONBytes, &arrValue)
|
||||
if err != nil {
|
||||
return fmt.Errorf("reading value from array file: %w", err)
|
||||
}
|
||||
}
|
||||
err := cli.PutStringArr(args[0], arrValue)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -1,22 +1,35 @@
|
||||
package hmsecrets
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var mapValue map[string]string
|
||||
var mapFile string
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(setMapCmd)
|
||||
|
||||
setMapCmd.Flags().StringToStringVarP(
|
||||
&mapValue,
|
||||
"map-value",
|
||||
"value",
|
||||
"v",
|
||||
nil,
|
||||
"map value to store in the secret",
|
||||
)
|
||||
setArrCmd.MarkFlagRequired("map-value")
|
||||
setMapCmd.Flags().StringVarP(
|
||||
&mapFile,
|
||||
"value-file",
|
||||
"f",
|
||||
"",
|
||||
"file that contains the secret value (in json) to set",
|
||||
)
|
||||
|
||||
setMapCmd.MarkFlagsOneRequired("value-file", "value")
|
||||
}
|
||||
|
||||
var setMapCmd = &cobra.Command{
|
||||
@@ -25,6 +38,16 @@ var setMapCmd = &cobra.Command{
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cli := getClient()
|
||||
if mapFile != "" {
|
||||
mapJSONBytes, err := os.ReadFile(mapFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("reading map value file: %w", err)
|
||||
}
|
||||
err = json.Unmarshal(mapJSONBytes, &mapValue)
|
||||
if err != nil {
|
||||
return fmt.Errorf("reading value from map file: %w", err)
|
||||
}
|
||||
}
|
||||
err := cli.PutStringMap(args[0], mapValue)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in new issue
Block a user