Support Generic S3 upload in Composer API

Use case
--------
If Endpoint is not set and Region is - upload to AWS S3
If both the Endpoint and Region are set - upload the Generic S3 via Weldr API
If neither the Endpoint and Region are set - upload the Generic S3 via Composer API (use configuration)

jobimpl-osbuild
---------------
Add configuration fields for Generic S3 upload
Support S3 upload requests coming from Weldr or Composer API to either AWS or Generic S3
Weldr API for Generic S3 requires that all connection parameters but the credentials be passed in the API call
Composer API for Generic S3 requires that all conneciton parameters are taken from the configuration
Adjust to the consolidation in Target and UploadOptions

Target and UploadOptions
------------------------
Add the fields that were specific to the Generic S3 structures to the AWS S3 one
Remove the structures for Generic S3 and always use the AWS S3 ones

Worker Main
-----------
Add Endpoint, Region, Bucket, CABundle and SkipSSLVerification to the configuration structure
Pass the values to the Server

Weldr API
---------
Keep the generic.s3 provider name to maintain the API, but unmarshel into awsS3UploadSettings

tests - api.sh
--------------
Allow the caller to specifiy either AWS or Generic S3 upload targets for specific image types
Implement the pieces required for testing upload to a Generic S3 service
In some cases generalize the AWS S3 functions for reuse

GitLab CI
---------
Add test case for api.sh tests with edge-commit and generic S3
This commit is contained in:
Ygal Blum 2022-05-24 09:25:29 +03:00
parent 335c597452
commit feb357e538
9 changed files with 325 additions and 190 deletions

View file

@ -29,13 +29,16 @@ func NewAWSTargetResult(options *AWSTargetResultOptions) *TargetResult {
}
type AWSS3TargetOptions struct {
Filename string `json:"filename"`
Region string `json:"region"`
AccessKeyID string `json:"accessKeyID"`
SecretAccessKey string `json:"secretAccessKey"`
SessionToken string `json:"sessionToken"`
Bucket string `json:"bucket"`
Key string `json:"key"`
Filename string `json:"filename"`
Region string `json:"region"`
AccessKeyID string `json:"accessKeyID"`
SecretAccessKey string `json:"secretAccessKey"`
SessionToken string `json:"sessionToken"`
Bucket string `json:"bucket"`
Key string `json:"key"`
Endpoint string `json:"endpoint"`
CABundle string `json:"ca_bundle"`
SkipSSLVerification bool `json:"skip_ssl_verification"`
}
func (AWSS3TargetOptions) isTargetOptions() {}

View file

@ -1,22 +0,0 @@
package target
type GenericS3TargetOptions struct {
AWSS3TargetOptions
Endpoint string `json:"endpoint"`
CABundle string `json:"ca_bundle"`
SkipSSLVerification bool `json:"skip_ssl_verification"`
}
func (GenericS3TargetOptions) isTargetOptions() {}
func NewGenericS3Target(options *GenericS3TargetOptions) *Target {
return newTarget("org.osbuild.generic.s3", options)
}
type GenericS3TargetResultOptions AWSS3TargetResultOptions
func (GenericS3TargetResultOptions) isTargetResultOptions() {}
func NewGenericS3TargetResult(options *GenericS3TargetResultOptions) *TargetResult {
return newTargetResult("org.osbuild.generic.s3", options)
}

View file

@ -83,8 +83,6 @@ func UnmarshalTargetOptions(targetName string, rawOptions json.RawMessage) (Targ
options = new(VMWareTargetOptions)
case "org.osbuild.oci":
options = new(OCITargetOptions)
case "org.osbuild.generic.s3":
options = new(GenericS3TargetOptions)
default:
return nil, errors.New("unexpected target name")
}

View file

@ -55,8 +55,6 @@ func UnmarshalTargetResultOptions(trName string, rawOptions json.RawMessage) (Ta
options = new(AzureImageTargetResultOptions)
case "org.osbuild.oci":
options = new(OCITargetResultOptions)
case "org.osbuild.generic.s3":
options = new(GenericS3TargetResultOptions)
default:
return nil, fmt.Errorf("unexpected target result name: %s", trName)
}