jobimpl-osbuild --------------- Add GenericS3Creds to struct Add method to create AWS with Endpoint for Generic S3 (with its own credentials file) Move uploading to S3 and result handling to a separate method (along with the special VMDK handling) adjust the AWS S3 case to the new method Implement a new case for uploading to a generic S3 service awscloud -------- Add wrapper methods for endpoint support Set the endpoint to the AWS session Set s3ForcePathStyle to true if endpoint was set Target ------ Define a new target type for the GenericS3Target and Options Handle unmarshaling of the target options and result for the Generic S3 Weldr ----- Add support for only uploading to AWS S3 Define new structures for AWS S3 and Generic S3 (based on AWS S3) Handle unmarshaling of the providers settings' upload settings main ---- Add a section in the main config for the Generic S3 service for credentials If provided pass the credentials file name to the osbuild job implementation Upload Utility -------------- Add upload-generic-s3 utility Makefile ------ Do not fail if the bin directory already exists Tests ----- Add test cases for both AWS and a generic S3 server Add a generic s3_test.sh file for both test cases and add it to the tests RPM spec Adjust the libvirt test case script to support already created images GitLabCI - Extend the libvirt test case to include the two new tests
44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
|
|
"github.com/aws/aws-sdk-go/aws"
|
|
|
|
"github.com/osbuild/osbuild-composer/internal/cloud/awscloud"
|
|
)
|
|
|
|
func main() {
|
|
var accessKeyID string
|
|
var secretAccessKey string
|
|
var sessionToken string
|
|
var region string
|
|
var endpoint string
|
|
var bucketName string
|
|
var keyName string
|
|
var filename string
|
|
flag.StringVar(&accessKeyID, "access-key-id", "", "access key ID")
|
|
flag.StringVar(&secretAccessKey, "secret-access-key", "", "secret access key")
|
|
flag.StringVar(&sessionToken, "session-token", "", "session token")
|
|
flag.StringVar(®ion, "region", "", "target region")
|
|
flag.StringVar(&endpoint, "endpoint", "", "target endpoint")
|
|
flag.StringVar(&bucketName, "bucket", "", "target S3 bucket name")
|
|
flag.StringVar(&keyName, "key", "", "target S3 key name")
|
|
flag.StringVar(&filename, "image", "", "image file to upload")
|
|
flag.Parse()
|
|
|
|
a, err := awscloud.NewForEndpoint(endpoint, region, accessKeyID, secretAccessKey, sessionToken)
|
|
if err != nil {
|
|
println(err.Error())
|
|
return
|
|
}
|
|
|
|
uploadOutput, err := a.Upload(filename, bucketName, keyName)
|
|
if err != nil {
|
|
println(err.Error())
|
|
return
|
|
}
|
|
|
|
fmt.Printf("file uploaded to %s\n", aws.StringValue(&uploadOutput.Location))
|
|
}
|