fetcher

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileProtocolPrefix       = `file://`
	GitProtocolPrefix        = `https://`
	LocalMountProtocolPrefix = `local://`
)

Variables

View Source
var (
	ErrUnknownProtocol = errors.New(`unknown protocol`)
)

Functions

func AddFileToTar

func AddFileToTar(tw *tar.Writer, path string, fs billy.Filesystem) error

func Fetch

func Fetch(ctx context.Context, repo, version string, logger *zap.Logger) ([]byte, error)

Fetch repo from file path , git repo file - file://path/to/repo git repo with basic auth and token - https://{user}:{pass}@github.com/s7techlab/{repo}.git git repo with token - https://{token}@github.com/s7techlab/{repo}.git

Types

type Fetcher

type Fetcher interface {
	// Fetch code by presented path and returns tar representation
	Fetch(ctx context.Context, repo, version string) ([]byte, error)
}

func Create

func Create(repo string, l *zap.Logger) (Fetcher, error)

Create returns Fetcher instance by repo scheme Scheme file:// returns FileFetcher Scheme https:// returns GitFetcher Scheme local:// returns Local mount fetcher git repo with basic auth and token - https://{user}:{pass}@github.com/s7techlab/{repo}.git git repo with token - https://{token}@github.com/s7techlab/{repo}.git Returns non-fetcher for unrecognized scheme

type File

type File struct {
	Logger *zap.Logger
}

func NewFile

func NewFile(l *zap.Logger) *File

func (*File) Fetch

func (f *File) Fetch(ctx context.Context, path, _ string) (code []byte, err error)

type Git

type Git struct {
	Logger *zap.Logger
	// contains filtered or unexported fields
}

func NewGit

func NewGit(opts ...GitOpt) *Git

func (Git) Fetch

func (g Git) Fetch(ctx context.Context, repo, version string) ([]byte, error)

type GitOpt

type GitOpt func(*Git)

func GitBasicAuth

func GitBasicAuth(username, password string) GitOpt

func GitTokenAuth

func GitTokenAuth(token string) GitOpt

func WithLogger

func WithLogger(l *zap.Logger) GitOpt

type Nope

type Nope struct {
}

Nope do nothing

func NewNope

func NewNope() *Nope

func (*Nope) Fetch

func (n *Nope) Fetch(ctx context.Context, repo, version string) ([]byte, error)

Jump to

Keyboard shortcuts

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