Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
prevents aws errors when not using aws
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitropoulos committed Mar 8, 2019
1 parent 1360f9b commit bb395cf
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions cmd/fluxd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,23 +334,37 @@ func main() {

// Wrap the procedure for collecting images to scan
{
awsConf := registry.AWSRegistryConfig{
Regions: *registryAWSRegions,
AccountIDs: *registryAWSAccountIDs,
BlockIDs: *registryAWSBlockAccountIDs,
awsOptions := []string{
"registry-ecr-region",
"registry-ecr-include-id",
"registry-ecr-exclude-id",
}
credsWithAWSAuth, err := registry.ImageCredsWithAWSAuth(imageCreds, log.With(logger, "component", "aws"), awsConf)
if err != nil {
logger.Log("warning", "AWS authorization not used; pre-flight check failed")
} else {
imageCreds = credsWithAWSAuth
usingAWS := false
for _, awsOption := range awsOptions {
if fs.Changed(awsOption) {
usingAWS = true
break
}
}
if *dockerConfig != "" {
credsWithDefaults, err := registry.ImageCredsWithDefaults(imageCreds, *dockerConfig)
if usingAWS {
awsConf := registry.AWSRegistryConfig{
Regions: *registryAWSRegions,
AccountIDs: *registryAWSAccountIDs,
BlockIDs: *registryAWSBlockAccountIDs,
}
credsWithAWSAuth, err := registry.ImageCredsWithAWSAuth(imageCreds, log.With(logger, "component", "aws"), awsConf)
if err != nil {
logger.Log("warning", "--docker-config not used; pre-flight check failed", "err", err)
logger.Log("warning", "AWS authorization not used; pre-flight check failed")
} else {
imageCreds = credsWithDefaults
imageCreds = credsWithAWSAuth
}
if *dockerConfig != "" {
credsWithDefaults, err := registry.ImageCredsWithDefaults(imageCreds, *dockerConfig)
if err != nil {
logger.Log("warning", "--docker-config not used; pre-flight check failed", "err", err)
} else {
imageCreds = credsWithDefaults
}
}
}
}
Expand Down

0 comments on commit bb395cf

Please sign in to comment.