Welcome to mirror list, hosted at ThFree Co, Russian Federation.

object_storage_preparer.go « upload « internal « workhorse - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d237a9ca6bcce4c453d53ffef223df9ed4ef3120 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package upload

import (
	"gitlab.com/gitlab-org/gitlab/workhorse/internal/api"
	"gitlab.com/gitlab-org/gitlab/workhorse/internal/config"
	"gitlab.com/gitlab-org/gitlab/workhorse/internal/upload/destination"
)

type ObjectStoragePreparer struct {
	config      config.ObjectStorageConfig
	credentials config.ObjectStorageCredentials
}

// NewObjectStoragePreparer returns a new preparer instance which is responsible for
// setting the object storage credentials and settings needed by an uploader
// to upload to object storage.
func NewObjectStoragePreparer(c config.Config) Preparer {
	return &ObjectStoragePreparer{credentials: c.ObjectStorageCredentials, config: c.ObjectStorageConfig}
}

func (p *ObjectStoragePreparer) Prepare(a *api.Response) (*destination.UploadOpts, error) {
	opts, err := destination.GetOpts(a)
	if err != nil {
		return nil, err
	}

	opts.ObjectStorageConfig.URLMux = p.config.URLMux
	opts.ObjectStorageConfig.S3Credentials = p.credentials.S3Credentials

	return opts, nil
}