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 88b22583 authored by Ash McKenzie's avatar Ash McKenzie Committed by GitLab
Browse files

Merge branch 'renovate/github.com-charmbracelet-git-lfs-transfer-digest' into 'main'

Update github.com/charmbracelet/git-lfs-transfer digest to bacbfdb

See merge request https://gitlab.com/gitlab-org/gitlab-shell/-/merge_requests/1101



Merged-by: default avatarAsh McKenzie <amckenzie@gitlab.com>
Approved-by: default avatarAsh McKenzie <amckenzie@gitlab.com>
Reviewed-by: default avatarPatrick Bajao <ebajao@gitlab.com>
Reviewed-by: default avatarAsh McKenzie <amckenzie@gitlab.com>
Co-authored-by: default avatarPatrick Bajao <ebajao@gitlab.com>
Co-authored-by: default avatarGitLab Renovate Bot <gitlab-bot@gitlab.com>
parents 63477e6a 324797e8
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -5,7 +5,7 @@ go 1.21
toolchain go1.21.9
require (
github.com/charmbracelet/git-lfs-transfer v0.1.1-0.20240605133614-0ffd62e22fe2
github.com/charmbracelet/git-lfs-transfer v0.1.1-0.20240708204110-bacbfdb68d92
github.com/git-lfs/pktline v0.0.0-20230103162542-ca444d533ef1
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
Loading
Loading
Loading
Loading
@@ -9,7 +9,6 @@ import (
"errors"
"fmt"
"io"
"io/fs"
"time"
"github.com/charmbracelet/git-lfs-transfer/transfer"
Loading
Loading
@@ -213,34 +212,24 @@ func (b *GitlabBackend) parseAndCheckBatchArgs(op, oid, id, token string) (href
return idData.Href, idData.Headers, nil
}
type uploadCloser struct{}
func (c *uploadCloser) Close() error {
return nil
}
func (b *GitlabBackend) StartUpload(oid string, r io.Reader, args transfer.Args) (io.Closer, error) {
func (b *GitlabBackend) Upload(oid string, _ int64, r io.Reader, args transfer.Args) error {
href, headers, err := b.parseAndCheckBatchArgs("upload", oid, args["id"], args["token"])
if err != nil {
_, _ = io.Copy(io.Discard, r)
return nil, err
return err
}
return &uploadCloser{}, b.client.PutObject(oid, href, headers, r)
return b.client.PutObject(oid, href, headers, r)
}
func (b *GitlabBackend) FinishUpload(_ io.Closer, _ transfer.Args) error {
return nil
}
func (b *GitlabBackend) Verify(_ string, _ transfer.Args) (transfer.Status, error) {
func (b *GitlabBackend) Verify(_ string, _ int64, _ transfer.Args) (transfer.Status, error) {
// Not needed, all verification is done in upload step.
return transfer.SuccessStatus(), nil
}
func (b *GitlabBackend) Download(oid string, args transfer.Args) (fs.File, error) {
func (b *GitlabBackend) Download(oid string, args transfer.Args) (io.ReadCloser, int64, error) {
href, headers, err := b.parseAndCheckBatchArgs("download", oid, args["id"], args["token"])
if err != nil {
return nil, err
return nil, 0, err
}
return b.client.GetObject(oid, href, headers)
}
Loading
Loading
Loading
Loading
@@ -55,52 +55,6 @@ type BatchResponse struct {
HashAlgorithm string `json:"hash_algo,omitempty"`
}
type downloadedFileInfo struct {
oid string
size int64
reader io.ReadCloser
}
func (i *downloadedFileInfo) Name() string {
return i.oid
}
func (i *downloadedFileInfo) Size() int64 {
return i.size
}
func (i *downloadedFileInfo) Mode() fs.FileMode {
return 0
}
func (i *downloadedFileInfo) ModTime() time.Time {
return time.Time{}
}
func (i *downloadedFileInfo) IsDir() bool {
return false
}
func (i *downloadedFileInfo) Sys() any {
return i.reader
}
type downloadedFile struct {
downloadedFileInfo
}
func (f *downloadedFile) Read(buf []byte) (int, error) {
return f.downloadedFileInfo.reader.Read(buf)
}
func (f *downloadedFile) Close() error {
return f.downloadedFileInfo.reader.Close()
}
func (f *downloadedFile) Stat() (fs.FileInfo, error) {
return &f.downloadedFileInfo, nil
}
type lockRequest struct {
Path string `json:"path"`
Ref *batchRef `json:"ref,omitempty"`
Loading
Loading
@@ -214,7 +168,7 @@ func (c *Client) Batch(operation string, reqObjects []*BatchObject, ref string,
return response, nil
}
func (c *Client) GetObject(oid, href string, headers map[string]string) (fs.File, error) {
func (c *Client) GetObject(oid, href string, headers map[string]string) (io.ReadCloser, int64, error) {
req, _ := newHTTPRequest(http.MethodGet, href, nil)
for key, value := range headers {
req.Header.Add(key, value)
Loading
Loading
@@ -225,19 +179,13 @@ func (c *Client) GetObject(oid, href string, headers map[string]string) (fs.File
// discussion on bypassing the linter
res, err := client.Do(req) // nolint:bodyclose
if err != nil {
return nil, err
return nil, 0, err
}
if res.StatusCode < 200 || res.StatusCode > 299 {
return nil, fs.ErrNotExist
return nil, 0, fs.ErrNotExist
}
return &downloadedFile{
downloadedFileInfo{
oid: oid,
size: res.ContentLength,
reader: res.Body,
},
}, nil
return res.Body, res.ContentLength, nil
}
func (c *Client) PutObject(oid, href string, headers map[string]string, r io.Reader) error {
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