Skip to content

Commit

Permalink
Changed raids.RDS.aws to raids.rds
Browse files Browse the repository at this point in the history
Signed-off-by: Eddie Knight <[email protected]>
  • Loading branch information
eddie-knight committed Oct 29, 2023
1 parent 826d376 commit 4cea63f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 31 deletions.
31 changes: 14 additions & 17 deletions example-config.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
loglevel: Debug
WriteDirectory: test_output
raids:
RDS:
aws:
creds:
aws_access_key: access
aws_secret_key: supersecret
aws_session_key: ""
aws_region: us-east-1
config:
instance_identifier: unique-id-name
database: test
primary_region: us-east-1
host: localhost
password: password
port: 3306
user: root
# google
# azure
rds:
creds:
aws_access_key: access
aws_secret_key: supersecret
aws_session_key: ""
aws_region: us-east-1
config:
instance_identifier: unique-id-name
database: test
primary_region: us-east-1
host: localhost
password: password
port: 3306
user: root
tactics:
- CCC-Taxonomy
35 changes: 21 additions & 14 deletions strikes/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,43 @@ func (a *Strikes) SetLogger(loggerName string) {
}

func getDBConfig() (string, error) {
if viper.IsSet("raids.RDS.aws.config.host") && viper.IsSet("raids.RDS.aws.config.database") {
if viper.IsSet("raids.rds.config.host") && viper.IsSet("raids.rds.config.database") {
return "database_host_placeholder", nil
}
return "", errors.New("database url must be set in the config file")
}

func getHostDBInstanceIdentifier() (string, error) {
if viper.IsSet("raids.RDS.aws.config.instance_identifier") {
return viper.GetString("raids.RDS.aws.config.instance_identifier"), nil
if viper.IsSet("raids.rds.config.instance_identifier") {
return viper.GetString("raids.rds.config.instance_identifier"), nil
}
return "", errors.New("database instance identifier must be set in the config file")
}

func getHostRDSRegion() (string, error) {
if viper.IsSet("raids.RDS.aws.config.primary_region") {
return viper.GetString("raids.RDS.aws.config.primary_region"), nil
if viper.IsSet("raids.rds.config.primary_region") {
return viper.GetString("raids.rds.config.primary_region"), nil
}
return "", errors.New("database instance identifier must be set in the config file")
}

func getAWSConfig() (cfg aws.Config, err error) {
if viper.IsSet("raids.RDS.aws.creds") &&
viper.IsSet("raids.RDS.aws.creds.aws_access_key") &&
viper.IsSet("raids.RDS.aws.creds.aws_secret_key") &&
viper.IsSet("raids.RDS.aws.creds.aws_region") {

access_key := viper.GetString("raids.RDS.aws.creds.aws_access_key")
secret_key := viper.GetString("raids.RDS.aws.creds.aws_secret_key")
session_key := viper.GetString("raids.RDS.aws.creds.aws_session_key")
region := viper.GetString("raids.RDS.aws.creds.aws_region")
config_values = [
"raids.rds.creds.aws_access_key",

Check failure on line 52 in strikes/common.go

View workflow job for this annotation

GitHub Actions / test

syntax error: unexpected comma; expected ]
"raids.rds.creds.aws_secret_key",

Check failure on line 53 in strikes/common.go

View workflow job for this annotation

GitHub Actions / test

syntax error: unexpected literal "raids.rds.creds.aws_secret_key", expected ]
"raids.rds.creds.aws_session_key",
"raids.rds.creds.aws_region",

]

Check failure on line 57 in strikes/common.go

View workflow job for this annotation

GitHub Actions / test

syntax error: unexpected ], expected expression
if viper.IsSet("raids.rds.creds") &&
viper.IsSet("raids.rds.creds.aws_access_key") &&
viper.IsSet("raids.rds.creds.aws_secret_key") &&
viper.IsSet("raids.rds.creds.aws_region") {

access_key := viper.GetString("raids.rds.creds.aws_access_key")
secret_key := viper.GetString("raids.rds.creds.aws_secret_key")
session_key := viper.GetString("raids.rds.creds.aws_session_key")
region := viper.GetString("raids.rds.creds.aws_region")

creds := credentials.NewStaticCredentialsProvider(access_key, secret_key, session_key)
cfg, err = config.LoadDefaultConfig(context.TODO(), config.WithCredentialsProvider(creds), config.WithRegion(region))
Expand Down

0 comments on commit 4cea63f

Please sign in to comment.