mirror of
https://github.com/getsops/sops.git
synced 2026-02-05 12:45:21 +01:00
Make SingleValueStore extend Store instead of the other way around.
Signed-off-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
14
sops.go
14
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
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user