gitlabgoproxy

package module
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2024 License: MIT Imports: 23 Imported by: 0

README

gitlab-goproxy

codecov

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGitlabFetcher

func NewGitlabFetcher(conf GitlabFetcherConfig) goproxy.Fetcher

func Save

func Save(ctx context.Context, input io.Reader) (io.ReadSeekCloser, int64, error)

func UnzipArchiveFromGitlab

func UnzipArchiveFromGitlab(workspace string, depth int, archive string) error

Types

type Config

type Config struct {
	Masks    []GitlabFetcherConfig `json:"masks" yaml:"masks" toml:"masks"`
	Upstream UpstreamConfig        `json:"upstream" yaml:"upstream" toml:"upstream"`
}

type GitLab

type GitLab interface {
	ListTags(ctx context.Context, repository string, prefix string) ([]*Info, error)
	GetTag(ctx context.Context, repository, tag string) (*Info, error)
	GetFile(ctx context.Context, repository, path, ref string) ([]byte, error)
	Download(ctx context.Context, repository, dir, ref string) (io.Reader, error) // https://go.dev/ref/mod#zip-files, TODO: 主module的zip文件里不包含任何子module,子module的zip中只包含自身文件
	IsProject(context.Context, string) (bool, error)
}

type GitlabFetcher

type GitlabFetcher struct {
	// contains filtered or unexported fields
}

func (*GitlabFetcher) Archive

func (gh *GitlabFetcher) Archive(ctx context.Context, loc *Locator, path, version string) (io.ReadSeekCloser, error)

func (*GitlabFetcher) Download

func (gf *GitlabFetcher) Download(ctx context.Context, path, version string) (info, mod, zip io.ReadSeekCloser, err error)

Download ..

func (*GitlabFetcher) Extract

func (gf *GitlabFetcher) Extract(ctx context.Context, path, query string) (*Locator, error)

func (*GitlabFetcher) ExtractSubPath

func (gf *GitlabFetcher) ExtractSubPath(ctx context.Context, path string) (string, []string, string, error)

func (*GitlabFetcher) List

func (gf *GitlabFetcher) List(ctx context.Context, path string) ([]string, error)

List 通过Git Repository的Tag列表返回查询结果

gitlab/wongidle/foobar -> [v0.1.0, v0.1.1]
gitlab/wongidle/foobar/internal -> error
gitlab/wongidle/foobar/pkg -> [v0.2.0, v0.2.1] -> [pkg/v0.2.0, pkg/v0.2.1]

func (*GitlabFetcher) NeedFetch

func (gf *GitlabFetcher) NeedFetch(path string) bool

func (*GitlabFetcher) Query

func (gf *GitlabFetcher) Query(ctx context.Context, path, query string) (string, time.Time, error)

Query: - gitlab.com/wongidle/foobar v0.1.1 -> wongidle/foobar v0.1.1 - gitlab.com/wongidle/foobar/internal v0.1.1

  • good: wongidle/foobar | internal | internal/v0.1.1
  • bad: wongidle/foobar |

func (*GitlabFetcher) SaveGoMod

func (gf *GitlabFetcher) SaveGoMod(ctx context.Context, loc *Locator) (io.ReadSeekCloser, error)

func (*GitlabFetcher) SaveInfo

func (gf *GitlabFetcher) SaveInfo(ctx context.Context, loc *Locator) (io.ReadSeekCloser, error)

type GitlabFetcherConfig

type GitlabFetcherConfig struct {
	Endpoint    string `json:"endpoint" yaml:"endpoint" toml:"endpoint"`
	AccessToken string `json:"access_token" yaml:"access_token" toml:"access_token"`
	Mask        string `json:"mask" yaml:"mask" toml:"mask"`
}

type GitlabHost

type GitlabHost struct {
	// contains filtered or unexported fields
}

func NewGitlabHost

func NewGitlabHost(conf GitlabFetcherConfig) *GitlabHost

func (*GitlabHost) Download

func (gh *GitlabHost) Download(ctx context.Context, repo, dir, ref string) (io.Reader, error)

func (*GitlabHost) GetFile

func (gh *GitlabHost) GetFile(ctx context.Context, repo, path, ref string) ([]byte, error)

func (*GitlabHost) GetTag

func (gh *GitlabHost) GetTag(ctx context.Context, repo, tag string) (*Info, error)

func (*GitlabHost) IsProject

func (gh *GitlabHost) IsProject(ctx context.Context, repo string) (bool, error)

func (*GitlabHost) ListTags

func (gh *GitlabHost) ListTags(ctx context.Context, repo string, prefix string) ([]*Info, error)

type Info

type Info struct {
	Version string
	Time    time.Time // commit time
}

type Locator

type Locator struct {
	Repository string
	SubPath    string
	Ref        string
}

type MixedFetcher

type MixedFetcher struct {
	Masks    []*GitlabFetcher
	Upstream goproxy.Fetcher
}

func NewMixedFetcher

func NewMixedFetcher(conf Config) *MixedFetcher

func (*MixedFetcher) Download

func (*MixedFetcher) List

func (mf *MixedFetcher) List(ctx context.Context, path string) ([]string, error)

func (*MixedFetcher) Query

func (mf *MixedFetcher) Query(ctx context.Context, path string, query string) (string, time.Time, error)

type SmartFile

type SmartFile struct {
	*os.File
	Ctx context.Context
	// contains filtered or unexported fields
}

func Create

func Create(ctx context.Context) (*SmartFile, error)

func (*SmartFile) Close

func (cf *SmartFile) Close() error

type UpstreamConfig

type UpstreamConfig struct {
	Proxy string `json:"proxy" yaml:"proxy" toml:"proxy"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL