Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nanjiangshu committed Dec 16, 2024
1 parent 52ca734 commit ced2be5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sda/cmd/ingest/ingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ func main() {
for _, key := range keyList {
header, err = tryDecrypt(key, readBuffer)
if err == nil {
// Decryption successful, store the successful key
successfulKey = key

break
}
log.Warnf("Decryption failed with key, trying next key. Reason: (%s)", err.Error())
Expand Down
2 changes: 2 additions & 0 deletions sda/cmd/ingest/ingest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func (suite *TestSuite) TestTryDecrypt_wrongFile() {
b, err := tryDecrypt(key, buf)
if b != nil || err == nil {
decryptionSuccessful = true

break
}
assert.EqualError(suite.T(), err, "not a Crypt4GH file")
Expand Down Expand Up @@ -134,6 +135,7 @@ func (suite *TestSuite) TestTryDecrypt() {
for _, key := range keyList {
header, err := tryDecrypt(key, buf)
if header != nil && err == nil {

break
}
assert.NoError(suite.T(), err)
Expand Down
9 changes: 6 additions & 3 deletions sda/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,13 +463,16 @@ func NewConfig(app string) (*Config, error) {
for _, s := range requiredConfVars {
if s == "c4gh.keys" {
// Check if at least one key entry has a valid filepath and passphrase
var keysConfig []map[string]string
viper.UnmarshalKey("c4gh.keys", &keysConfig)
var keyConfigs []map[string]string
if err := viper.UnmarshalKey("c4gh.keys", &keyConfigs); err != nil {
return nil, fmt.Errorf("failed to parse key configurations: %v", err)
}

atLeastOneKeySet := false
for _, key := range keysConfig {
for _, key := range keyConfigs {
if key["filepath"] != "" && key["passphrase"] != "" {
atLeastOneKeySet = true

break
}
}
Expand Down

0 comments on commit ced2be5

Please sign in to comment.