diff --git a/cmd/sops/main.go b/cmd/sops/main.go index 038977d14..f24606f1c 100644 --- a/cmd/sops/main.go +++ b/cmd/sops/main.go @@ -2090,7 +2090,12 @@ func getEncryptConfig(c *cli.Context, fileName string, inputStore common.Store, } } - if inputStore.IsSingleValueStore() { + isSingleValueStore := false + if svs, ok := inputStore.(sops.SingleValueStore); ok { + isSingleValueStore = svs.IsSingleValueStore() + } + + if isSingleValueStore { // Warn about settings that potentially disable encryption of the single key. if unencryptedSuffix != "" { log.Warn(fmt.Sprintf("Using an unencrypted suffix does not make sense with the input store (the %s store produces one key that should always be encrypted) and will be ignored.", inputStore.Name())) @@ -2142,7 +2147,7 @@ func getEncryptConfig(c *cli.Context, fileName string, inputStore common.Store, } // only supply the default UnencryptedSuffix when EncryptedSuffix, EncryptedRegex, and others are not provided - if cryptRuleCount == 0 && !inputStore.IsSingleValueStore() { + if cryptRuleCount == 0 && !isSingleValueStore { unencryptedSuffix = sops.DefaultUnencryptedSuffix } diff --git a/sops.go b/sops.go index 2347ec6a0..b8e824597 100644 --- a/sops.go +++ b/sops.go @@ -726,12 +726,6 @@ type CheckEncrypted interface { HasSopsTopLevelKey(TreeBranch) bool } -// SingleValueStore is the interface for determining whether a store uses only -// one single key and no comments. This is basically identifying the binary store. -type SingleValueStore interface { - IsSingleValueStore() bool -} - // Store is used to interact with files, both encrypted and unencrypted. type Store interface { EncryptedFileLoader @@ -740,10 +734,16 @@ type Store interface { PlainFileEmitter ValueEmitter CheckEncrypted - SingleValueStore Name() string } +// SingleValueStore is the interface for determining whether a store uses only +// one single key and no comments. This is basically identifying the binary store. +type SingleValueStore interface { + Store + IsSingleValueStore() bool +} + // MasterKeyCount returns the number of master keys available func (m *Metadata) MasterKeyCount() int { count := 0 diff --git a/stores/dotenv/store.go b/stores/dotenv/store.go index d30f3d8b7..d42db65c0 100644 --- a/stores/dotenv/store.go +++ b/stores/dotenv/store.go @@ -23,10 +23,6 @@ func NewStore(c *config.DotenvStoreConfig) *Store { return &Store{config: *c} } -func (store *Store) IsSingleValueStore() bool { - return false -} - func (store *Store) Name() string { return "dotenv" } diff --git a/stores/ini/store.go b/stores/ini/store.go index e98cd5543..79dd85eb3 100644 --- a/stores/ini/store.go +++ b/stores/ini/store.go @@ -21,10 +21,6 @@ func NewStore(c *config.INIStoreConfig) *Store { return &Store{config: c} } -func (store *Store) IsSingleValueStore() bool { - return false -} - func (store *Store) Name() string { return "ini" } diff --git a/stores/json/store.go b/stores/json/store.go index 3491d3e88..913a86c92 100644 --- a/stores/json/store.go +++ b/stores/json/store.go @@ -22,10 +22,6 @@ func NewStore(c *config.JSONStoreConfig) *Store { return &Store{config: *c} } -func (store *Store) IsSingleValueStore() bool { - return false -} - func (store *Store) Name() string { return "json" } diff --git a/stores/yaml/store.go b/stores/yaml/store.go index 639e6867d..27c82c541 100644 --- a/stores/yaml/store.go +++ b/stores/yaml/store.go @@ -24,10 +24,6 @@ func NewStore(c *config.YAMLStoreConfig) *Store { return &Store{config: *c} } -func (store *Store) IsSingleValueStore() bool { - return false -} - func (store *Store) Name() string { return "yaml" }