worker/aws: prefer bucket from TargetOptions if provided
Flip the logic when deciding if to use the Bucket from the job or worker configuration. Previously, the Bucket from the worker configuration was always preferred if it was set, even if it was provided in the job itself. This made it impossible to override the configuration. Change the logic to use the Bucket from the worker configuration only if it was not set in the job. Report an error if no bucket name was provided with the job and there is also none specified in the configuration.
This commit is contained in:
parent
3933c37f46
commit
565b8d41c8
1 changed files with 9 additions and 2 deletions
|
|
@ -121,8 +121,11 @@ func (impl *OSBuildJobImpl) getAWSForS3Target(options *target.AWSS3TargetOptions
|
|||
// Endpoint == "" && Region != "" => AWS (Weldr and Composer)
|
||||
if options.Endpoint == "" && options.Region != "" {
|
||||
aws, err = impl.getAWS(options.Region, options.AccessKeyID, options.SecretAccessKey, options.SessionToken)
|
||||
if impl.AWSBucket != "" {
|
||||
if bucket == "" {
|
||||
bucket = impl.AWSBucket
|
||||
if bucket == "" {
|
||||
err = fmt.Errorf("No AWS bucket provided")
|
||||
}
|
||||
}
|
||||
} else if options.Endpoint != "" && options.Region != "" { // Endpoint != "" && Region != "" => Generic S3 Weldr API
|
||||
aws, err = impl.getAWSForS3TargetFromOptions(options)
|
||||
|
|
@ -471,8 +474,12 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
}
|
||||
|
||||
bucket := targetOptions.Bucket
|
||||
if impl.AWSBucket != "" {
|
||||
if bucket == "" {
|
||||
bucket = impl.AWSBucket
|
||||
if bucket == "" {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "No AWS bucket provided", nil)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Remove this once multiple exports will be supported and used by image definitions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue