gitfile

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GithubAPITemplate = "https://api.github.com/repos/%s/%s/contents/%s"
View Source
var GithubURLRegexp = regexp.MustCompile(`(?Um)^(?:https)(?:\:\/\/)github.com/(?P<repoUser>[^/]+)/(?P<repoName>[^/]+)(.git)?$`)
View Source
var GithubURLRegexpNames = GithubURLRegexp.SubexpNames()
View Source
var ScmProviders []ScmProvider

ScmProviders is the list of detectors that are tried on an SCM URL. This is also the order they're tried (index 0 is first).

Functions

This section is empty.

Types

type EnvVarTokenFetcher added in v0.2.5

type EnvVarTokenFetcher struct{}

EnvVarTokenFetcher token fetcher implementation that looks for token in the specific ENV variable.

func (*EnvVarTokenFetcher) BuildHeader added in v0.2.5

func (s *EnvVarTokenFetcher) BuildHeader(context.Context, string, string, func(ctx context.Context, url string)) (*HeaderStruct, error)

type GitFile added in v0.2.5

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

func Default added in v0.2.5

func Default() *GitFile

func New added in v0.2.5

func New(fetcher TokenFetcher) *GitFile

New creates a new *GitFile instance

func (*GitFile) GetFileContents added in v0.2.5

func (g *GitFile) GetFileContents(ctx context.Context, namespace, repoUrl, filepath, ref string, callback func(ctx context.Context, url string)) (io.ReadCloser, error)

GetFileContents is a main entry function allowing to retrieve file content from the SCM provider. It expects three file location parameters, from which the repository URL and path to the file are mandatory, and optional Git reference for the branch/tags/commitIds. Function type parameter is a callback used when user authentication is needed in order to retrieve the file, that function will be called with the URL to OAuth service, where user need to be redirected.

type GitHubScmProvider

type GitHubScmProvider struct {
}

GitHubScmProvider implements Detector to detect GitHub URLs.

type GitLabScmProvider

type GitLabScmProvider struct{}

GitLabScmProvider implements Detector to detect Gitlab URLs.

type GithubFile

type GithubFile struct {
	Name        string `json:"name"`
	Path        string `json:"path"`
	Size        int32  `json:"size"`
	Encoding    string `json:"encoding"`
	DownloadUrl string `json:"download_url"`
}

type HeaderStruct added in v0.2.5

type HeaderStruct struct {
	Authorization string `json:"Authorization"`
}

HeaderStruct is the simple struct to carry authentication string from different suppliers

type InternalError added in v0.8.3

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

func (*InternalError) Error added in v0.8.3

func (e *InternalError) Error() string

type InvalidRequestError added in v0.8.3

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

func (*InvalidRequestError) Error added in v0.8.3

func (e *InvalidRequestError) Error() string

type ScmProvider

type ScmProvider interface {
	// contains filtered or unexported methods
}

ScmProvider defines the interface that in order to determine if URL belongs to SCM provider

type SpiTokenFetcher added in v0.2.5

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

SpiTokenFetcher token fetcher implementation that looks for token in the specific ENV variable.

func NewSpiTokenFetcher added in v0.2.5

func NewSpiTokenFetcher() *SpiTokenFetcher

func (*SpiTokenFetcher) BuildHeader added in v0.2.5

func (s *SpiTokenFetcher) BuildHeader(ctx context.Context, namespace, repoUrl string, loginCallback func(ctx context.Context, url string)) (*HeaderStruct, error)

type TokenFetcher added in v0.2.5

type TokenFetcher interface {
	BuildHeader(ctx context.Context, namespace, repoUrl string, loginCallback func(ctx context.Context, url string)) (*HeaderStruct, error)
}

TokenFetcher is the interface for the authentication token suppliers which are provides tokens as a HeaderStruct instances

type UnauthorizedError added in v0.8.3

type UnauthorizedError struct {
}

func (*UnauthorizedError) Error added in v0.8.3

func (e *UnauthorizedError) Error() string

Jump to

Keyboard shortcuts

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