Commit d78f0997 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'object_store_rename' into 'master'

More consistent API naming. ObjectStore -> RemoteObject

See merge request gitlab-org/gitlab-workhorse!240
parents 948e94fb 2c2e57ac
...@@ -67,16 +67,15 @@ func NewAPI(myURL *url.URL, version string, roundTripper *badgateway.RoundTrippe ...@@ -67,16 +67,15 @@ func NewAPI(myURL *url.URL, version string, roundTripper *badgateway.RoundTrippe
type HandleFunc func(http.ResponseWriter, *http.Request, *Response) type HandleFunc func(http.ResponseWriter, *http.Request, *Response)
type RemoteObjectStore struct { type RemoteObject struct {
// GetURL is not used in gitlab-workhorse. We pass it back to gitlab-rails // GetURL is an S3 GetObject URL
// later for symmetry with the 'store upload in tempfile' approach.
GetURL string GetURL string
// DeleteURL is a presigned S3 RemoveObject URL // DeleteURL is a presigned S3 RemoveObject URL
DeleteURL string DeleteURL string
// StoreURL is the temporary presigned S3 PutObject URL to which upload the first found file // StoreURL is the temporary presigned S3 PutObject URL to which upload the first found file
StoreURL string StoreURL string
// ObjectID is a unique identifier of object storage upload // ID is a unique identifier of object storage upload
ObjectID string ID string
// Timeout is a number that represents timeout in seconds for sending data to StoreURL // Timeout is a number that represents timeout in seconds for sending data to StoreURL
Timeout int Timeout int
} }
...@@ -105,9 +104,9 @@ type Response struct { ...@@ -105,9 +104,9 @@ type Response struct {
// TmpPath is the path where we should store temporary files // TmpPath is the path where we should store temporary files
// This is set by authorization middleware // This is set by authorization middleware
TempPath string TempPath string
// ObjectStore is provided by the GitLab Rails application // RemoteObject is provided by the GitLab Rails application
// and defines a way to store object on remote storage // and defines a way to store object on remote storage
ObjectStore RemoteObjectStore RemoteObject RemoteObject
// Archive is the path where the artifacts archive is stored // Archive is the path where the artifacts archive is stored
Archive string `json:"archive"` Archive string `json:"archive"`
// Entry is a filename inside the archive point to file that needs to be extracted // Entry is a filename inside the archive point to file that needs to be extracted
......
...@@ -74,8 +74,8 @@ func TestUploadHandlerSendingToExternalStorage(t *testing.T) { ...@@ -74,8 +74,8 @@ func TestUploadHandlerSendingToExternalStorage(t *testing.T) {
responseProcessorCalled := 0 responseProcessorCalled := 0
responseProcessor := func(w http.ResponseWriter, r *http.Request) { responseProcessor := func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, "store-id", r.FormValue("file.object_id")) assert.Equal(t, "store-id", r.FormValue("file.remote_id"))
assert.NotEmpty(t, r.FormValue("file.store_url")) assert.NotEmpty(t, r.FormValue("file.remote_url"))
w.WriteHeader(200) w.WriteHeader(200)
responseProcessorCalled++ responseProcessorCalled++
} }
...@@ -85,9 +85,9 @@ func TestUploadHandlerSendingToExternalStorage(t *testing.T) { ...@@ -85,9 +85,9 @@ func TestUploadHandlerSendingToExternalStorage(t *testing.T) {
authResponse := api.Response{ authResponse := api.Response{
TempPath: tempPath, TempPath: tempPath,
ObjectStore: api.RemoteObjectStore{ RemoteObject: api.RemoteObject{
StoreURL: storeServer.URL + "/url/put", StoreURL: storeServer.URL + "/url/put",
ObjectID: "store-id", ID: "store-id",
GetURL: storeServer.URL + "/store-id", GetURL: storeServer.URL + "/store-id",
}, },
} }
...@@ -114,9 +114,9 @@ func TestUploadHandlerSendingToExternalStorageAndStorageServerUnreachable(t *tes ...@@ -114,9 +114,9 @@ func TestUploadHandlerSendingToExternalStorageAndStorageServerUnreachable(t *tes
authResponse := api.Response{ authResponse := api.Response{
TempPath: tempPath, TempPath: tempPath,
ObjectStore: api.RemoteObjectStore{ RemoteObject: api.RemoteObject{
StoreURL: "http://localhost:12323/invalid/url", StoreURL: "http://localhost:12323/invalid/url",
ObjectID: "store-id", ID: "store-id",
}, },
} }
...@@ -143,9 +143,9 @@ func TestUploadHandlerSendingToExternalStorageAndInvalidURLIsUsed(t *testing.T) ...@@ -143,9 +143,9 @@ func TestUploadHandlerSendingToExternalStorageAndInvalidURLIsUsed(t *testing.T)
authResponse := api.Response{ authResponse := api.Response{
TempPath: tempPath, TempPath: tempPath,
ObjectStore: api.RemoteObjectStore{ RemoteObject: api.RemoteObject{
StoreURL: "htt:////invalid-url", StoreURL: "htt:////invalid-url",
ObjectID: "store-id", ID: "store-id",
}, },
} }
...@@ -184,9 +184,9 @@ func TestUploadHandlerSendingToExternalStorageAndItReturnsAnError(t *testing.T) ...@@ -184,9 +184,9 @@ func TestUploadHandlerSendingToExternalStorageAndItReturnsAnError(t *testing.T)
authResponse := api.Response{ authResponse := api.Response{
TempPath: tempPath, TempPath: tempPath,
ObjectStore: api.RemoteObjectStore{ RemoteObject: api.RemoteObject{
StoreURL: storeServer.URL + "/url/put", StoreURL: storeServer.URL + "/url/put",
ObjectID: "store-id", ID: "store-id",
}, },
} }
...@@ -227,9 +227,9 @@ func TestUploadHandlerSendingToExternalStorageAndSupportRequestTimeout(t *testin ...@@ -227,9 +227,9 @@ func TestUploadHandlerSendingToExternalStorageAndSupportRequestTimeout(t *testin
authResponse := api.Response{ authResponse := api.Response{
TempPath: tempPath, TempPath: tempPath,
ObjectStore: api.RemoteObjectStore{ RemoteObject: api.RemoteObject{
StoreURL: storeServer.URL + "/url/put", StoreURL: storeServer.URL + "/url/put",
ObjectID: "store-id", ID: "store-id",
Timeout: 1, Timeout: 1,
}, },
} }
......
...@@ -65,10 +65,10 @@ func (fh *FileHandler) GitLabFinalizeFields(prefix string) map[string]string { ...@@ -65,10 +65,10 @@ func (fh *FileHandler) GitLabFinalizeFields(prefix string) map[string]string {
data[key("path")] = fh.LocalPath data[key("path")] = fh.LocalPath
} }
if fh.RemoteURL != "" { if fh.RemoteURL != "" {
data[key("store_url")] = fh.RemoteURL data[key("remote_url")] = fh.RemoteURL
} }
if fh.RemoteID != "" { if fh.RemoteID != "" {
data[key("object_id")] = fh.RemoteID data[key("remote_id")] = fh.RemoteID
} }
data[key("size")] = strconv.FormatInt(fh.Size, 10) data[key("size")] = strconv.FormatInt(fh.Size, 10)
for hashName, hash := range fh.hashes { for hashName, hash := range fh.hashes {
......
...@@ -213,8 +213,8 @@ func TestSaveFile(t *testing.T) { ...@@ -213,8 +213,8 @@ func TestSaveFile(t *testing.T) {
assert.Equal(fh.Name, fields["file.name"]) assert.Equal(fh.Name, fields["file.name"])
assert.Equal(fh.LocalPath, fields["file.path"]) assert.Equal(fh.LocalPath, fields["file.path"])
assert.Equal(fh.RemoteURL, fields["file.store_url"]) assert.Equal(fh.RemoteURL, fields["file.remote_url"])
assert.Equal(fh.RemoteID, fields["file.object_id"]) assert.Equal(fh.RemoteID, fields["file.remote_id"])
assert.Equal(strconv.FormatInt(test.ObjectSize, 10), fields["file.size"]) assert.Equal(strconv.FormatInt(test.ObjectSize, 10), fields["file.size"])
assert.Equal(test.ObjectMD5, fields["file.md5"]) assert.Equal(test.ObjectMD5, fields["file.md5"])
assert.Equal(test.ObjectSHA1, fields["file.sha1"]) assert.Equal(test.ObjectSHA1, fields["file.sha1"])
......
...@@ -51,17 +51,17 @@ func (s *SaveFileOpts) isGoogleCloudStorage() bool { ...@@ -51,17 +51,17 @@ func (s *SaveFileOpts) isGoogleCloudStorage() bool {
// GetOpts converts GitLab api.Response to a proper SaveFileOpts // GetOpts converts GitLab api.Response to a proper SaveFileOpts
func GetOpts(apiResponse *api.Response) *SaveFileOpts { func GetOpts(apiResponse *api.Response) *SaveFileOpts {
timeout := time.Duration(apiResponse.ObjectStore.Timeout) * time.Second timeout := time.Duration(apiResponse.RemoteObject.Timeout) * time.Second
if timeout == 0 { if timeout == 0 {
timeout = objectstore.DefaultObjectStoreTimeout timeout = objectstore.DefaultObjectStoreTimeout
} }
return &SaveFileOpts{ return &SaveFileOpts{
LocalTempPath: apiResponse.TempPath, LocalTempPath: apiResponse.TempPath,
RemoteID: apiResponse.ObjectStore.ObjectID, RemoteID: apiResponse.RemoteObject.ID,
RemoteURL: apiResponse.ObjectStore.GetURL, RemoteURL: apiResponse.RemoteObject.GetURL,
PresignedPut: apiResponse.ObjectStore.StoreURL, PresignedPut: apiResponse.RemoteObject.StoreURL,
PresignedDelete: apiResponse.ObjectStore.DeleteURL, PresignedDelete: apiResponse.RemoteObject.DeleteURL,
Timeout: timeout, Timeout: timeout,
} }
} }
...@@ -62,9 +62,9 @@ func TestGetOpts(t *testing.T) { ...@@ -62,9 +62,9 @@ func TestGetOpts(t *testing.T) {
assert := assert.New(t) assert := assert.New(t)
apiResponse := &api.Response{ apiResponse := &api.Response{
TempPath: "/tmp", TempPath: "/tmp",
ObjectStore: api.RemoteObjectStore{ RemoteObject: api.RemoteObject{
Timeout: 10, Timeout: 10,
ObjectID: "id", ID: "id",
GetURL: "http://get", GetURL: "http://get",
StoreURL: "http://store", StoreURL: "http://store",
DeleteURL: "http://delete", DeleteURL: "http://delete",
...@@ -74,11 +74,11 @@ func TestGetOpts(t *testing.T) { ...@@ -74,11 +74,11 @@ func TestGetOpts(t *testing.T) {
opts := filestore.GetOpts(apiResponse) opts := filestore.GetOpts(apiResponse)
assert.Equal(apiResponse.TempPath, opts.LocalTempPath) assert.Equal(apiResponse.TempPath, opts.LocalTempPath)
assert.Equal(time.Duration(apiResponse.ObjectStore.Timeout)*time.Second, opts.Timeout) assert.Equal(time.Duration(apiResponse.RemoteObject.Timeout)*time.Second, opts.Timeout)
assert.Equal(apiResponse.ObjectStore.ObjectID, opts.RemoteID) assert.Equal(apiResponse.RemoteObject.ID, opts.RemoteID)
assert.Equal(apiResponse.ObjectStore.GetURL, opts.RemoteURL) assert.Equal(apiResponse.RemoteObject.GetURL, opts.RemoteURL)
assert.Equal(apiResponse.ObjectStore.StoreURL, opts.PresignedPut) assert.Equal(apiResponse.RemoteObject.StoreURL, opts.PresignedPut)
assert.Equal(apiResponse.ObjectStore.DeleteURL, opts.PresignedDelete) assert.Equal(apiResponse.RemoteObject.DeleteURL, opts.PresignedDelete)
} }
func TestGetOptsDefaultTimeout(t *testing.T) { func TestGetOptsDefaultTimeout(t *testing.T) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment