vcs

package
v0.26.4 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	K8sSecretDataAuthType    = "auth"
	K8sSecretDataAuthTypeSSH = "ssh"
	SSHKey                   = "identity"
	SSHPubKey                = "identity.pub"
	Token                    = "token"
)
View Source
const (
	GitHub  = "github"
	GitLab  = "gitlab"
	Generic = "generic"
)
View Source
const DefaultRepoID = "none/none"

Variables

View Source
var (
	ErrPRAlreadyExists = errors.New("Pull-Request already exists")
)
View Source
var ErrPullRequestNotSupported = errors.New("Pull-Request not supported")
View Source
var (
	ErrRepositoryID = errors.New("Unknown repository id")
)
View Source
var (
	ErrUnknownURLFormat = errors.New("Unknown git url format")
)

Functions

func Duplicate

func Duplicate(src, dst string) error

func NewGithubClient

func NewGithubClient(httpClient *http.Client, token string) *githubClient

func NewGitlabClient

func NewGitlabClient(httpClient *http.Client, token string) (*gitlabClient, error)

func SecretName

func SecretName(projectName string) string

func WithAuth

func WithAuth(auth Auth) repositoryOption

func WithHTTPClient

func WithHTTPClient(client *http.Client) repositoryOption

func WithProvider

func WithProvider(provider Provider) repositoryOption

Types

type Auth

type Auth struct {
	Method transport.AuthMethod

	// Personal Access Token with access rights to the VCS repository.
	// When empty, features like PR creation won't be possible.
	Token string
}

Auth methods for repository access.

func GetAuth

func GetAuth(
	ctx context.Context,
	kubeClient kube.Client[unstructured.Unstructured, unstructured.Unstructured],
	controllerNamespace string,
	projectName string,
) (*Auth, error)

type GenericProviderClient

type GenericProviderClient struct{}

func (*GenericProviderClient) CreateDeployKey

func (*GenericProviderClient) CreateDeployKey(
	ctx context.Context,
	repoID string,
	opts ...deployKeyOption,
) (*deployKey, error)

func (*GenericProviderClient) CreatePullRequest

func (g *GenericProviderClient) CreatePullRequest(
	ctx context.Context,
	req PullRequestRequest,
) error

func (*GenericProviderClient) GetHostPublicSSHKey

func (*GenericProviderClient) GetHostPublicSSHKey() string

type GenericRepository

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

func (*GenericRepository) Commit

func (g *GenericRepository) Commit(file string, message string) (string, error)

func (*GenericRepository) CreatePullRequest

func (g *GenericRepository) CreatePullRequest(title string, desc, src string, dst string) error

func (*GenericRepository) CurrentBranch

func (g *GenericRepository) CurrentBranch() (string, error)

func (*GenericRepository) DeleteLocalBranch

func (g *GenericRepository) DeleteLocalBranch(branch string) error

func (*GenericRepository) Path

func (g *GenericRepository) Path() string

func (*GenericRepository) Pull

func (g *GenericRepository) Pull() (string, error)

func (*GenericRepository) Push

func (g *GenericRepository) Push(src, dst string) error

func (*GenericRepository) RepoID

func (g *GenericRepository) RepoID() string

func (*GenericRepository) SwitchBranch

func (g *GenericRepository) SwitchBranch(branch string, create bool) error

type GithubRepository

type GithubRepository struct {
	GenericRepository
	// contains filtered or unexported fields
}

func (*GithubRepository) CreatePullRequest

func (g *GithubRepository) CreatePullRequest(title, desc, branch, targetBranch string) error

type GitlabRepository

type GitlabRepository struct {
	GenericRepository
	// contains filtered or unexported fields
}

func (*GitlabRepository) CreatePullRequest

func (g *GitlabRepository) CreatePullRequest(title, desc, branch, targetBranch string) error

type Provider

type Provider string

func ParseURL

func ParseURL(url string) (Provider, string, error)

type PullRequestRequest

type PullRequestRequest struct {
	RepoID      string
	Title       string
	Description string
	Branch      string
	BaseBranch  string
}

type Repository

type Repository interface {
	Path() string
	RepoID() string
	Pull() (string, error)
	Commit(file, message string) (string, error)
	SwitchBranch(branch string, create bool) error
	CurrentBranch() (string, error)
	DeleteLocalBranch(branch string) error
	Push(src, dst string) error
	CreatePullRequest(title, desc, src, dst string) error
}

func NewRepository

func NewRepository(
	localTargetPath string,
	gitRepository *git.Repository,
	opts ...repositoryOption,
) (Repository, error)

func Open

func Open(
	path string,
	opts ...repositoryOption,
) (Repository, error)

type RepositoryConfigurator

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

RepositoryConfigurator is capable of setting up Navecd with a Git provider.

func NewRepositoryConfigurator

func NewRepositoryConfigurator(
	controllerNamespace string,
	kubeClient kube.Client[unstructured.Unstructured, unstructured.Unstructured],
	httpClient *http.Client,
	url string,
	token string,
) (*RepositoryConfigurator, error)

func (RepositoryConfigurator) CreateDeployKeyIfNotExists

func (config RepositoryConfigurator) CreateDeployKeyIfNotExists(
	ctx context.Context,
	fieldManager string,
	projectName string,
	persistToken bool,
) error

type RepositoryManager

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

RepositoryManager clones a remote vcs repository to a local path.

func NewRepositoryManager

func NewRepositoryManager(
	controllerNamespace string,
	kubeClient kube.Client[unstructured.Unstructured, unstructured.Unstructured],
	log logr.Logger,
) RepositoryManager

func (*RepositoryManager) Load

func (manager *RepositoryManager) Load(
	ctx context.Context,
	remoteURL string,
	branch string,
	targetPath string,
	projectName string,
) (Repository, error)

Load clones a remote vcs repository to a local path or opens it if it exists.

func (*RepositoryManager) LoadLocally

func (manager *RepositoryManager) LoadLocally(
	ctx context.Context,
	srcRepoPath string,
	targetPath string,
	projectName string,
) (Repository, error)

type WithKeySuffix

type WithKeySuffix string

Jump to

Keyboard shortcuts

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