manager

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SecretTokenName is the name of the secret entry containing the token
	SecretTokenName = "token"
	// SecretHostKeysName is the name of the secret entry containing the SSH host keys
	SecretHostKeysName = "hostKeys"
	// SecretEndpointName is the name of the secret entry containing the api endpoint
	SecretEndpointName = "endpoint"
	// DeletionMagicString defines when a file should be deleted from the repository
	//TODO it will be replaced with something better in the future TODO
	DeletionMagicString = "{delete}"
)

Variables

This section is empty.

Functions

func Register

func Register(i Implementation)

Register adds a type to the list of supported Git implementations.

Types

type CommitFile

type CommitFile struct {
	FileName string
	Content  string
	Delete   bool
}

CommitFile contains all information about a file that should be committed to git TODO migrate to the CRDs in the future.

type Credentials

type Credentials struct {
	Token string
}

Credentials holds the authentication information for the API. Most of the times this is just a token.

type Implementation

type Implementation interface {
	// IsType returns true, if the given URL is handleable by the given implementation (Github,Gitlab, etc.)
	IsType(URL *url.URL) (bool, error)
	// New returns a clean new Repo implementation with the given URL
	New(options RepoOptions) (Repo, error)
}

Implementation is a set of functions needed to get the right git implementation for the given URL.

type Repo

type Repo interface {
	// Type returns the type of the repo
	Type() string
	// FullURL returns the full url to the repository for ssh pulling
	FullURL() *url.URL
	Create() error
	// Update will enforce the defined keys to be deployed to the repository, it will return true if an actual change
	// happened
	Update() (bool, error)
	// Read will read the repository and populate it with the deployed keys. It will throw an
	// error if the repo is not found on the server.
	Read() error
	// Remove will remove the git project according to the recycle policy
	Remove() error
	Connect() error
	// CommitTemplateFiles uploads given files to the repository.
	// files that contain exactly the deletion magic string should be removed
	// when calling this function. TODO: will be replaced with something better in the future.
	CommitTemplateFiles() error
}

Repo represents a repository that lives on some git server

func GetGitClient

func GetGitClient(ctx context.Context, instance *synv1alpha1.GitRepoTemplate, namespace string, reqLogger logr.Logger, client client.Client) (Repo, string, error)

GetGitClient will return a git client from a provided template. This does a lot more plumbing than the simple NewClient() call. If you're needing a git client from a reconcile function, this is the way to go.

func NewRepo

func NewRepo(opts RepoOptions) (Repo, error)

NewRepo returns a Repo object that can handle the specific URL

type RepoOptions

type RepoOptions struct {
	Credentials    Credentials
	DeployKeys     map[string]synv1alpha1.DeployKey
	Logger         logr.Logger
	URL            *url.URL
	Path           string
	RepoName       string
	DisplayName    string
	TemplateFiles  map[string]string
	DeletionPolicy synv1alpha1.DeletionPolicy
}

RepoOptions hold the options for creating a repository. The credentials are required to work. The deploykeys are optional but desired. If not provided DeletionPolicy will default to archive.

Jump to

Keyboard shortcuts

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