As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Unverified Commit 6b5c1f83 authored by Joseph Snyder's avatar Joseph Snyder Committed by Ash McKenzie
Browse files

Return transfer.Args from issueBatchArgs function

Update the issueBatchArgs function to return a transfer.Args object
instead of two strings that are then put into the object.
parent dd0822a9
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -70,28 +70,33 @@ func NewGitlabBackend(ctx context.Context, config *config.Config, args *commanda
}, nil
}
func (b *GitlabBackend) issueBatchArgs(op string, oid string, href string, headers map[string]string) (id string, token string, err error) {
func (b *GitlabBackend) issueBatchArgs(op string, oid string, href string, headers map[string]string) (args transfer.Args, err error) {
data := &idData{
Operation: op,
Oid: oid,
Href: href,
Headers: headers,
}
args = transfer.Args{
"id":"",
"token":"",
}
dataBinary, err := json.Marshal(data)
if err != nil {
return "", "", err
return args, err
}
h := hmac.New(sha256.New, []byte(b.config.Secret))
_, err = h.Write(dataBinary)
if err != nil {
return "", "", err
return args, err
}
id = base64.StdEncoding.EncodeToString(dataBinary)
token = base64.StdEncoding.EncodeToString(h.Sum(nil))
args["id"] = base64.StdEncoding.EncodeToString(dataBinary)
args["token"] = base64.StdEncoding.EncodeToString(h.Sum(nil))
return id, token, nil
return args, nil
}
func (b *GitlabBackend) Batch(op string, pointers []transfer.BatchItem, args transfer.Args) ([]transfer.BatchItem, error) {
Loading
Loading
@@ -125,15 +130,10 @@ func (b *GitlabBackend) Batch(op string, pointers []transfer.BatchItem, args tra
var args transfer.Args
if action, present = retObject.Actions[op]; present {
id, token, err := b.issueBatchArgs(op, retObject.Oid, action.Href, action.Header)
args, err = b.issueBatchArgs(op, retObject.Oid, action.Href, action.Header)
if err != nil {
return nil, err
}
args = transfer.Args{
"id": id,
"token": token,
}
}
if op == "upload" {
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment