summaryrefslogtreecommitdiff
path: root/workhorse/internal/upload/preparer.go
blob: 4d6d8bd1189a97439e27f0c2ec9b08ec2a78bcf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package upload

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

// Preparer is a pluggable behavior that interprets a Rails API response
// and either tells Workhorse how to handle the upload, via the
// UploadOpts, or it rejects the request by returning a non-nil error.
// Its intended use is to make sure the upload gets stored in the right
// location: either a local directory, or one of several supported object
// storage backends.
type Preparer interface {
	Prepare(a *api.Response) (*destination.UploadOpts, error)
}

type DefaultPreparer struct{}

func (s *DefaultPreparer) Prepare(a *api.Response) (*destination.UploadOpts, error) {
	return destination.GetOpts(a)
}