feat: add gitlab source for gitlab package registry

cleanup http source
This commit is contained in:
Technofab 2023-09-25 14:40:39 +02:00
parent 8ffad5a3ea
commit d655269156
No known key found for this signature in database
GPG key ID: A0AA746B951C8830
7 changed files with 180 additions and 70 deletions

View file

@ -17,8 +17,6 @@ package pkg
import (
"bytes"
"context"
"crypto/sha256"
"encoding/hex"
"fmt"
"io"
"io/ioutil"
@ -97,11 +95,9 @@ func remoteResolveRef(ctx context.Context, remote string, ref string) (string, e
func (p *GitPackage) Install(ctx context.Context, name, dir, version string) (string, error) {
destPath := path.Join(dir, name)
pkgh := sha256.Sum256([]byte(fmt.Sprintf("jsonnetpkg-%s-%s", strings.Replace(name, "/", "-", -1), strings.Replace(version, "/", "-", -1))))
// using 16 bytes should be a good middle ground between length and collision resistance
tmpDir, err := ioutil.TempDir(filepath.Join(dir, ".tmp"), hex.EncodeToString(pkgh[:16]))
tmpDir, err := CreateTempDir(name, dir, version)
if err != nil {
return "", errors.Wrap(err, "failed to create tmp dir")
return "", err
}
defer os.RemoveAll(tmpDir)