debian-forge-composer/cmd/osbuild-upload-generic-s3/main.go
Ygal Blum 8407c97d96 Upload to HTTPS S3 - Support self signed certificate
API
---
Allow the user to pass the CA public certification or skip the verification

AWSCloud
--------
Restore the old version of newAwsFromCreds for access to AWS
Create a new method newAwsFromCredsWithEndpoint for Generic S3 which sets the endpoint and optionally overrides the CA Bundle or skips the SSL certificate verification

jobimpl-osbuild
---------------
Update with the new parameters

osbuild-upload-generic-s3
-------------------------
Add ca-bunlde and skip-ssl-verification flags

tests
-----
Split the tests into http, https with certificate and https skip certificate check
Create a new base test for S3 over HTTPS for secure and insecure
Move the generic S3 test to tools to reuse for secure and insecure connections
All S3 tests now use the aws cli tool
Update the libvirt test to be able to download over HTTPS
Update the RPM spec

Kill container with sudo
2022-05-26 13:46:00 +03:00

48 lines
1.5 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 caBundle string
var skipSSLVerification bool
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(&region, "region", "", "target region")
flag.StringVar(&endpoint, "endpoint", "", "target endpoint")
flag.StringVar(&caBundle, "ca-bundle", "", "path to CA bundle for the S3 server")
flag.BoolVar(&skipSSLVerification, "skip-ssl-verification", false, "Skip the verification of the server SSL certificate")
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, caBundle, skipSSLVerification)
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))
}