Skip to content

Commit f4d2d44

Browse files
committed
fix(config): remove unused variables and align error casing
Signed-off-by: Nicklas Frahm <[email protected]>
1 parent 92651ed commit f4d2d44

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

config/config.go

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,11 @@ import (
1717
"github.com/getsops/sops/v3/gcpkms"
1818
"github.com/getsops/sops/v3/hcvault"
1919
"github.com/getsops/sops/v3/kms"
20-
"github.com/getsops/sops/v3/logging"
2120
"github.com/getsops/sops/v3/pgp"
2221
"github.com/getsops/sops/v3/publish"
23-
"github.com/sirupsen/logrus"
2422
"gopkg.in/yaml.v3"
2523
)
2624

27-
var log *logrus.Logger
28-
29-
func init() {
30-
log = logging.NewLogger("CONFIG")
31-
}
32-
3325
type fileSystem interface {
3426
Stat(name string) (os.FileInfo, error)
3527
}
@@ -165,7 +157,7 @@ func NewStoresConfig() *StoresConfig {
165157
func (f *configFile) load(bytes []byte) error {
166158
err := yaml.Unmarshal(bytes, f)
167159
if err != nil {
168-
return fmt.Errorf("Could not unmarshal config file: %s", err)
160+
return fmt.Errorf("could not unmarshal config file: %s", err)
169161
}
170162
return nil
171163
}
@@ -377,19 +369,17 @@ func parseDestinationRuleForFile(conf *configFile, filePath string, kmsEncryptio
377369
}
378370

379371
var dest publish.Destination
380-
if dRule != nil {
381-
if dRule.S3Bucket != "" && dRule.GCSBucket != "" && dRule.VaultPath != "" {
382-
return nil, fmt.Errorf("error loading config: more than one destinations were found in a single destination rule, you can only use one per rule")
383-
}
384-
if dRule.S3Bucket != "" {
385-
dest = publish.NewS3Destination(dRule.S3Bucket, dRule.S3Prefix)
386-
}
387-
if dRule.GCSBucket != "" {
388-
dest = publish.NewGCSDestination(dRule.GCSBucket, dRule.GCSPrefix)
389-
}
390-
if dRule.VaultPath != "" {
391-
dest = publish.NewVaultDestination(dRule.VaultAddress, dRule.VaultPath, dRule.VaultKVMountName, dRule.VaultKVVersion)
392-
}
372+
if dRule.S3Bucket != "" && dRule.GCSBucket != "" && dRule.VaultPath != "" {
373+
return nil, fmt.Errorf("error loading config: more than one destinations were found in a single destination rule, you can only use one per rule")
374+
}
375+
if dRule.S3Bucket != "" {
376+
dest = publish.NewS3Destination(dRule.S3Bucket, dRule.S3Prefix)
377+
}
378+
if dRule.GCSBucket != "" {
379+
dest = publish.NewGCSDestination(dRule.GCSBucket, dRule.GCSPrefix)
380+
}
381+
if dRule.VaultPath != "" {
382+
dest = publish.NewVaultDestination(dRule.VaultAddress, dRule.VaultPath, dRule.VaultKVMountName, dRule.VaultKVVersion)
393383
}
394384

395385
config, err := configFromRule(rule, kmsEncryptionContext)

0 commit comments

Comments
 (0)