git

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: Apache-2.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DefaultTimeoutKey is the configuration field name for controlling
	// the maximum duration of a resolution request for a file from git.
	DefaultTimeoutKey = "fetch-timeout"

	// DefaultURLKey is the configuration field name for controlling
	// the git url to fetch the remote resource from.
	DefaultURLKey = "default-url"

	// DefaultRevisionKey is the configuration field name for controlling
	// the revision to fetch the remote resource from.
	DefaultRevisionKey = "default-revision"

	// DefaultOrgKey is the configuration field name for setting a default organization when using the SCM API.
	DefaultOrgKey = "default-org"

	// ServerURLKey is the config map key for the SCM provider URL
	ServerURLKey = "server-url"
	// SCMTypeKey is the config map key for the SCM provider type
	SCMTypeKey = "scm-type"
	// APISecretNameKey is the config map key for the token secret's name
	APISecretNameKey = "api-token-secret-name"
	// APISecretKeyKey is the config map key for the containing the token within the token secret
	APISecretKeyKey = "api-token-secret-key"
	// APISecretNamespaceKey is the config map key for the token secret's namespace
	APISecretNamespaceKey = "api-token-secret-namespace"
)
View Source
const (
	// UrlParam is the git repo Url when using the anonymous/full clone approach
	UrlParam string = resource.ParamURL
	// OrgParam is the organization to find the repository in when using the SCM API approach
	OrgParam = "org"
	// RepoParam is the repository to use when using the SCM API approach
	RepoParam = "repo"
	// PathParam is the pathInRepo into the git repo where a file is located. This is used with both approaches.
	PathParam string = "pathInRepo"
	// RevisionParam is the git revision that a file should be fetched from. This is used with both approaches.
	RevisionParam string = "revision"
	// TokenParam is an optional reference to a secret name for SCM API authentication
	TokenParam string = "token"
	// TokenKeyParam is an optional reference to a key in the TokenParam secret for SCM API authentication
	TokenKeyParam string = "tokenKey"
	// GitTokenParam is an optional reference to a secret name when using native-git for git authentication
	GitTokenParam string = "gitToken"
	// GitTokenParam is an optional reference to a secret name when using native-git for git authentication
	GitTokenKeyParam string = "gitTokenKey"
	// DefaultTokenKeyParam is the default key in the TokenParam secret for SCM API authentication
	DefaultTokenKeyParam string = "token"
	// scmTypeParam is an optional string overriding the scm-type configuration (ie: github, gitea, gitlab etc..)
	ScmTypeParam string = "scmType"
	// serverURLParam is an optional string to the server URL for the SCM API to connect to
	ServerURLParam string = "serverURL"
	// ConfigKeyParam is an optional string to provid which scm configuration to use from git resolver configmap
	ConfigKeyParam string = "configKey"
)
View Source
const (

	// ConfigMapName is the git resolver's config map
	ConfigMapName = "git-resolver-config"
)

Variables

View Source
var (
	// AnnotationKeyRevision is the commit hash that was fetched
	// from git
	AnnotationKeyRevision = resolution.GroupName + "/revision"

	// AnnotationKeyOrg is the org used
	AnnotationKeyOrg = resolution.GroupName + "/org"
	// AnnotationKeyRepo is the repo used
	AnnotationKeyRepo = resolution.GroupName + "/repo"
	// AnnotationKeyPath is the path used
	AnnotationKeyPath = resolution.GroupName + "/path"
	// AnnotationKeyURL is the repo URL used
	AnnotationKeyURL = resolution.GroupName + "/url"
)

Functions

func IsDisabled added in v0.60.0

func IsDisabled(ctx context.Context) bool

func PopulateDefaultParams added in v0.60.0

func PopulateDefaultParams(ctx context.Context, params []pipelinev1.Param) (map[string]string, error)

func SetValidateRepoURLForTesting deprecated added in v1.0.2

func SetValidateRepoURLForTesting(fn func(string) bool) func()

Deprecated: SetValidateRepoURLForTesting is test-only infrastructure. It replaces the URL validation function and returns a restore function that must be called (e.g. via t.Cleanup) to reset the original validator. Do not depend on this in production code.

func ValidateParams added in v0.60.0

func ValidateParams(ctx context.Context, params []pipelinev1.Param) error

Types

type GitResolver added in v1.0.0

type GitResolver struct {
	KubeClient kubernetes.Interface
	Logger     *zap.SugaredLogger
	Cache      *cache.LRUExpireCache
	TTL        time.Duration
	Params     map[string]string

	// Function variables for mocking in tests
	ResolveGitCloneFunc func(ctx context.Context) (framework.ResolvedResource, error)
	ResolveAPIGitFunc   func(ctx context.Context, clientFunc func(string, string, string, ...factory.ClientOptionFunc) (*scm.Client, error)) (framework.ResolvedResource, error)
}

func (*GitResolver) ResolveAPIGit added in v1.0.0

func (g *GitResolver) ResolveAPIGit(ctx context.Context, clientFunc func(string, string, string, ...factory.ClientOptionFunc) (*scm.Client, error)) (framework.ResolvedResource, error)

ResolveAPIGit resolves a git resource using the SCM API.

func (*GitResolver) ResolveGitClone added in v1.0.0

func (g *GitResolver) ResolveGitClone(ctx context.Context) (framework.ResolvedResource, error)

ResolveGitClone resolves a git resource using git clone.

type GitResolverConfig added in v0.65.0

type GitResolverConfig map[string]ScmConfig

func GetGitResolverConfig added in v0.65.0

func GetGitResolverConfig(ctx context.Context) (GitResolverConfig, error)

type Resolver deprecated

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

Resolver implements a framework.Resolver that can fetch files from git.

Deprecated: Use github.com/tektoncd/pipeline/pkg/remoteresolution/resolver/git.Resolver instead.

func (*Resolver) GetConfigName

func (r *Resolver) GetConfigName(context.Context) string

GetConfigName returns the name of the git resolver's configmap.

func (*Resolver) GetName

func (r *Resolver) GetName(_ context.Context) string

GetName returns the string name that the gitresolver should be associated with.

func (*Resolver) GetResolutionTimeout

func (r *Resolver) GetResolutionTimeout(ctx context.Context, defaultTimeout time.Duration, params map[string]string) (time.Duration, error)

GetResolutionTimeout returns a time.Duration for the amount of time a single git fetch may take. This can be configured with the fetch-timeout field in the git-resolver-config configmap.

func (*Resolver) GetSelector

func (r *Resolver) GetSelector(_ context.Context) map[string]string

GetSelector returns the labels that resource requests are required to have for the gitresolver to process them.

func (*Resolver) Initialize

func (r *Resolver) Initialize(ctx context.Context) error

Initialize performs any setup required by the gitresolver.

func (*Resolver) Resolve

func (r *Resolver) Resolve(ctx context.Context, origParams []pipelinev1.Param) (framework.ResolvedResource, error)

Resolve performs the work of fetching a file from git given a map of parameters.

func (*Resolver) ValidateParams

func (r *Resolver) ValidateParams(ctx context.Context, params []pipelinev1.Param) error

ValidateParams returns an error if the given parameter map is not valid for a resource request targeting the gitresolver.

type ScmConfig added in v0.65.0

type ScmConfig struct {
	Timeout            string `json:"fetch-timeout"`
	URL                string `json:"default-url"`
	Revision           string `json:"default-revision"`
	Org                string `json:"default-org"`
	ServerURL          string `json:"server-url"`
	SCMType            string `json:"scm-type"`
	GitToken           string `json:"git-token"`
	APISecretName      string `json:"api-token-secret-name"`
	APISecretKey       string `json:"api-token-secret-key"`
	APISecretNamespace string `json:"api-token-secret-namespace"`
}

func GetScmConfigForParamConfigKey added in v0.65.0

func GetScmConfigForParamConfigKey(ctx context.Context, params map[string]string) (ScmConfig, error)

Jump to

Keyboard shortcuts

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