-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Secret credentials support for BackupData (#310)
* Make backupData support secret credentials for S3 * Add test case * Gofmt
- Loading branch information
1 parent
0f8fa1a
commit 02da4f8
Showing
3 changed files
with
59 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package function | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
|
||
"github.com/kanisterio/kanister/pkg/param" | ||
"github.com/kanisterio/kanister/pkg/secrets" | ||
) | ||
|
||
func ValidateCredentials(creds *param.Credential) error { | ||
if creds == nil { | ||
return errors.New("Empty credentials") | ||
} | ||
switch creds.Type { | ||
case param.CredentialTypeKeyPair: | ||
if creds.KeyPair == nil { | ||
return errors.New("Empty KeyPair field") | ||
} | ||
if len(creds.KeyPair.ID) == 0 { | ||
return errors.New("Access key ID is not set") | ||
} | ||
if len(creds.KeyPair.Secret) == 0 { | ||
return errors.New("Secret access key is not set") | ||
} | ||
return nil | ||
case param.CredentialTypeSecret: | ||
return secrets.ValidateCredentials(creds.Secret) | ||
default: | ||
return errors.Errorf("Unsupported type '%s' for credentials", creds.Type) | ||
} | ||
} |