upload/azure: move UploadImage under a new StorageClient struct
We will soon introduce new methods to the storage client. Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
parent
f67ca8b616
commit
478f69e092
4 changed files with 71 additions and 51 deletions
|
|
@ -37,13 +37,20 @@ func main() {
|
|||
|
||||
fmt.Println("Image to upload is:", fileName)
|
||||
|
||||
err := azure.UploadImage(azure.Credentials{
|
||||
StorageAccount: storageAccount,
|
||||
StorageAccessKey: storageAccessKey,
|
||||
}, azure.ImageMetadata{
|
||||
ImageName: path.Base(fileName),
|
||||
ContainerName: containerName,
|
||||
}, fileName, threads)
|
||||
c, err := azure.NewStorageClient(storageAccount, storageAccessKey)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
err = c.UploadImage(
|
||||
azure.ImageMetadata{
|
||||
ImageName: path.Base(fileName),
|
||||
ContainerName: containerName,
|
||||
},
|
||||
fileName,
|
||||
threads,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("Error: ", err)
|
||||
|
|
|
|||
|
|
@ -227,18 +227,20 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
if !osbuildOutput.Success {
|
||||
continue
|
||||
}
|
||||
credentials := azure.Credentials{
|
||||
StorageAccount: options.StorageAccount,
|
||||
StorageAccessKey: options.StorageAccessKey,
|
||||
|
||||
azureStorageClient, err := azure.NewStorageClient(options.StorageAccount, options.StorageAccessKey)
|
||||
if err != nil {
|
||||
r = append(r, err)
|
||||
continue
|
||||
}
|
||||
|
||||
metadata := azure.ImageMetadata{
|
||||
ContainerName: options.Container,
|
||||
ImageName: t.ImageName,
|
||||
}
|
||||
|
||||
const azureMaxUploadGoroutines = 4
|
||||
err := azure.UploadImage(
|
||||
credentials,
|
||||
err = azureStorageClient.UploadImage(
|
||||
metadata,
|
||||
path.Join(outputDirectory, options.Filename),
|
||||
azureMaxUploadGoroutines,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue