1
0
mirror of https://github.com/getsops/sops.git synced 2026-02-05 12:45:21 +01:00

Implement feedback

Co-authored-by: Felix Fontein <felix@fontein.de>
Signed-off-by: Bastien Wermeille <bastien.wermeille@gmail.com>
This commit is contained in:
Bastien Wermeille
2023-09-09 17:42:08 +02:00
parent 303fdd8f37
commit d2ee8df5de
6 changed files with 7 additions and 31 deletions

View File

@@ -30,15 +30,10 @@ type ExampleFileEmitter interface {
EmitExample() []byte EmitExample() []byte
} }
type Configurable interface {
Configure(*config.Config)
}
// Store handles marshaling and unmarshaling from SOPS files // Store handles marshaling and unmarshaling from SOPS files
type Store interface { type Store interface {
sops.Store sops.Store
ExampleFileEmitter ExampleFileEmitter
Configurable
} }
type storeConstructor = func(*config.StoresConfig) Store type storeConstructor = func(*config.StoresConfig) Store

View File

@@ -706,7 +706,7 @@ func main() {
}, },
cli.IntFlag{ cli.IntFlag{
Name: "indent", Name: "indent",
Usage: "the number of space to indent yaml encoded file for encryption", Usage: "the number of space to indent YAML encoded file for encryption",
}, },
cli.BoolFlag{ cli.BoolFlag{
Name: "verbose", Name: "verbose",
@@ -1069,7 +1069,7 @@ func keyservices(c *cli.Context) (svcs []keyservice.KeyServiceClient) {
return return
} }
func inputStore(context *cli.Context, path string) common.Store { func loadStoresConfig(context *cli.Context, path string) (*config.StoresConfig, error) {
var configPath string var configPath string
if context.String("config") != "" { if context.String("config") != "" {
configPath = context.String("config") configPath = context.String("config")
@@ -1077,20 +1077,16 @@ func inputStore(context *cli.Context, path string) common.Store {
// Ignore config not found errors returned from FindConfigFile since the config file is not mandatory // Ignore config not found errors returned from FindConfigFile since the config file is not mandatory
configPath, _ = config.FindConfigFile(".") configPath, _ = config.FindConfigFile(".")
} }
storesConf, _ := config.LoadStoresConfig(configPath) return config.LoadStoresConfig(configPath)
}
func inputStore(context *cli.Context, path string) common.Store {
storesConf, _ := loadStoresConfig(context, path)
return common.DefaultStoreForPathOrFormat(storesConf, path, context.String("input-type")) return common.DefaultStoreForPathOrFormat(storesConf, path, context.String("input-type"))
} }
func outputStore(context *cli.Context, path string) common.Store { func outputStore(context *cli.Context, path string) common.Store {
var configPath string storesConf, _ := loadStoresConfig(context, path)
if context.String("config") != "" {
configPath = context.String("config")
} else {
// Ignore config not found errors returned from FindConfigFile since the config file is not mandatory
configPath, _ = config.FindConfigFile(".")
}
storesConf, _ := config.LoadStoresConfig(configPath)
if context.Int("indent") != 0 { if context.Int("indent") != 0 {
storesConf.YAML.Indent = context.Int("indent") storesConf.YAML.Indent = context.Int("indent")
} }

View File

@@ -202,6 +202,3 @@ func isComplexValue(v interface{}) bool {
} }
return false return false
} }
func (store *Store) Configure(c *config.Config) {
}

View File

@@ -288,6 +288,3 @@ func (store *Store) EmitExample() []byte {
} }
return bytes return bytes
} }
func (store *Store) Configure(c *config.Config) {
}

View File

@@ -348,9 +348,3 @@ func (store *Store) EmitExample() []byte {
} }
return bytes return bytes
} }
func (store *Store) Configure(c *config.Config) {
}
func (store *BinaryStore) Configure(c *config.Config) {
}

View File

@@ -407,6 +407,3 @@ func (store *Store) EmitExample() []byte {
} }
return bytes return bytes
} }
func (store *Store) Configure(c *config.Config) {
}