repository

package
v1.17.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrReleaseAlreadyExist = fmt.Errorf("release already exists")
	ErrReleaseTooOld       = fmt.Errorf("release is too old")
)

Functions

func GaugeEnvAppLockMetric added in v1.16.0

func GaugeEnvAppLockMetric(fs billy.Filesystem, env, app string)

func GaugeEnvLockMetric added in v1.16.0

func GaugeEnvLockMetric(fs billy.Filesystem, env string)

func GetEnvironmentApplicationLocksCount added in v1.16.0

func GetEnvironmentApplicationLocksCount(fs billy.Filesystem, environment, application string) float64

func GetEnvironmentLocksCount added in v1.16.0

func GetEnvironmentLocksCount(fs billy.Filesystem, env string) float64

func GetLastRelease

func GetLastRelease(fs billy.Filesystem, application string) (uint64, error)

func GetRepositoryStateAndUpdateMetrics added in v1.16.0

func GetRepositoryStateAndUpdateMetrics(repo Repository)

func GetTags added in v1.16.0

func GetTags(cfg RepositoryConfig, repoName string, ctx context.Context) (tags []*api.TagData, err error)

func RegularlySendDatadogMetrics added in v1.16.0

func RegularlySendDatadogMetrics(repo Repository, interval time.Duration, callBack func(repository Repository))

func UpdateDatadogMetrics added in v1.16.0

func UpdateDatadogMetrics(state *State) error

func WithTimeNow added in v1.16.0

func WithTimeNow(ctx context.Context, t time.Time) context.Context

Types

type Actor added in v1.16.0

type Actor struct {
	Name  string
	Email string
}

type AppEnv added in v1.16.0

type AppEnv struct {
	App string
	Env string
}

type ArgoWebhookData added in v1.16.0

type ArgoWebhookData struct {
	Commits []commit
	// contains filtered or unexported fields
}

type Authentication added in v1.16.0

type Authentication struct {
	RBACConfig auth.RBACConfig
}

type Certificates

type Certificates struct {
	KnownHostsFile string
}

type CleanupOldApplicationVersions

type CleanupOldApplicationVersions struct {
	Application string
}

func (*CleanupOldApplicationVersions) Transform

type CommitIds added in v1.16.0

type CommitIds struct {
	Previous *git.Oid
	Current  *git.Oid
}

type CreateApplicationVersion

type CreateApplicationVersion struct {
	Authentication
	Version        uint64
	Application    string
	Manifests      map[string]string
	SourceCommitId string
	SourceAuthor   string
	SourceMessage  string
	SourceRepoUrl  string
	Team           string
	DisplayVersion string
}

func (*CreateApplicationVersion) Transform

type CreateEnvironment

type CreateEnvironment struct {
	Authentication
	Environment string
	Config      config.EnvironmentConfig
}

func (*CreateEnvironment) Transform

func (c *CreateEnvironment) Transform(ctx context.Context, state *State) (string, *TransformerResult, error)

type CreateEnvironmentApplicationLock

type CreateEnvironmentApplicationLock struct {
	Authentication
	Environment string
	Application string
	LockId      string
	Message     string
}

func (*CreateEnvironmentApplicationLock) Transform

type CreateEnvironmentGroupLock added in v1.16.0

type CreateEnvironmentGroupLock struct {
	Authentication
	EnvironmentGroup string
	LockId           string
	Message          string
}

func (*CreateEnvironmentGroupLock) Transform added in v1.16.0

type CreateEnvironmentLock

type CreateEnvironmentLock struct {
	Authentication
	Environment string
	LockId      string
	Message     string
}

func (*CreateEnvironmentLock) Transform

func (c *CreateEnvironmentLock) Transform(ctx context.Context, state *State) (string, *TransformerResult, error)

type CreateUndeployApplicationVersion

type CreateUndeployApplicationVersion struct {
	Authentication
	Application string
}

func (*CreateUndeployApplicationVersion) Transform

type Credentials

type Credentials struct {
	SshKey string
}

type DeleteEnvFromApp added in v1.16.0

type DeleteEnvFromApp struct {
	Authentication
	Application string
	Environment string
}

func (*DeleteEnvFromApp) Transform added in v1.16.0

func (u *DeleteEnvFromApp) Transform(ctx context.Context, state *State) (string, *TransformerResult, error)

type DeleteEnvironmentApplicationLock

type DeleteEnvironmentApplicationLock struct {
	Authentication
	Environment string
	Application string
	LockId      string
}

func (*DeleteEnvironmentApplicationLock) Transform

type DeleteEnvironmentGroupLock added in v1.16.0

type DeleteEnvironmentGroupLock struct {
	Authentication
	EnvironmentGroup string
	LockId           string
}

func (*DeleteEnvironmentGroupLock) Transform added in v1.16.0

type DeleteEnvironmentLock

type DeleteEnvironmentLock struct {
	Authentication
	Environment string
	LockId      string
}

func (*DeleteEnvironmentLock) Transform

func (c *DeleteEnvironmentLock) Transform(ctx context.Context, state *State) (string, *TransformerResult, error)

type DeployApplicationVersion

type DeployApplicationVersion struct {
	Authentication
	Environment   string
	Application   string
	Version       uint64
	LockBehaviour api.LockBehavior
}

func (*DeployApplicationVersion) Transform

type InternalError

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

func (*InternalError) Error

func (i *InternalError) Error() string

func (*InternalError) String

func (i *InternalError) String() string

func (*InternalError) Unwrap

func (i *InternalError) Unwrap() error

type Lock

type Lock struct {
	Message   string
	CreatedBy Actor
	CreatedAt time.Time
}

type LockedError

type LockedError struct {
	EnvironmentApplicationLocks map[string]Lock
	EnvironmentLocks            map[string]Lock
}

func (*LockedError) Error

func (l *LockedError) Error() string

func (*LockedError) String

func (l *LockedError) String() string

type ObjectCount

type ObjectCount struct {
	Count       uint64
	Size        uint64
	InPack      uint64
	Packs       uint64
	SizePack    uint64
	Garbage     uint64
	SizeGarbage uint64
}

type PushActionCallbackFunc added in v1.16.0

type PushActionCallbackFunc func(git.PushOptions, *repository) PushActionFunc

type PushActionFunc added in v1.16.0

type PushActionFunc func() error

func DefaultPushActionCallback added in v1.16.0

func DefaultPushActionCallback(pushOptions git.PushOptions, r *repository) PushActionFunc

DefaultPushActionCallback is public for testing reasons only.

type PushUpdateFunc added in v1.16.0

type PushUpdateFunc func(string, *bool) git.PushUpdateReferenceCallback

type QueueApplicationVersion

type QueueApplicationVersion struct {
	Environment string
	Application string
	Version     uint64
}

func (*QueueApplicationVersion) Transform

type Release

type Release struct {
	Version uint64
	/**
	"UndeployVersion=true" means that this version is empty, and has no manifest that could be deployed.
	It is intended to help cleanup old services within the normal release cycle (e.g. dev->staging->production).
	*/
	UndeployVersion bool
	SourceAuthor    string
	SourceCommitId  string
	SourceMessage   string
	CreatedAt       time.Time
	DisplayVersion  string
}

type ReleaseTrain

type ReleaseTrain struct {
	Authentication
	Target string
	Team   string
}

func (*ReleaseTrain) Transform

func (c *ReleaseTrain) Transform(ctx context.Context, state *State) (string, *TransformerResult, error)

type Repository

type Repository interface {
	Apply(ctx context.Context, transformers ...Transformer) error
	Push(ctx context.Context, pushAction func() error) error
	ApplyTransformersInternal(ctx context.Context, transformers ...Transformer) ([]string, *State, []*TransformerResult, error)
	State() *State
	StateAt(oid *git.Oid) (*State, error)
	Notify() *notify.Notify
}

A Repository provides a multiple reader / single writer access to a git repository.

func New

Opens a repository. The repository is initialized and updated in the background.

func New2 added in v1.16.0

type RepositoryConfig added in v1.16.0

type RepositoryConfig struct {
	// Mandatory Config
	// the URL used for git checkout, (ssh protocol)
	URL  string
	Path string
	// Optional Config
	Credentials    Credentials
	Certificates   Certificates
	CommitterEmail string
	CommitterName  string
	// default branch is master
	Branch string
	// network timeout
	NetworkTimeout time.Duration
	//
	GcFrequency    uint
	StorageBackend StorageBackend
	// Bootstrap mode controls where configurations are read from
	// true: read from json file at EnvironmentConfigsPath
	// false: read from config files in manifest repo
	BootstrapMode          bool
	EnvironmentConfigsPath string
	ArgoInsecure           bool
	// if set, kuberpult will generate push events to argoCd whenever it writes to the manifest repo:
	ArgoWebhookUrl string
	// the url to the git repo, like the browser requires it (https protocol)
	WebURL string
}

type RootApp added in v1.16.0

type RootApp struct {
	Env string
}

type State

type State struct {
	Filesystem             billy.Filesystem
	Commit                 *git.Commit
	BootstrapMode          bool
	EnvironmentConfigsPath string
}

func (*State) DeleteAppLockIfEmpty added in v1.16.0

func (s *State) DeleteAppLockIfEmpty(ctx context.Context, environment string, application string) error

func (*State) DeleteDirIfEmpty added in v1.16.0

func (s *State) DeleteDirIfEmpty(directoryName string) (SuccessReason, error)

DeleteDirIfEmpty if it's empty. If the dir does not exist or is not empty, nothing happens. Errors are only returned if the read or delete operations fail. Returns SuccessReason for unit testing.

func (*State) DeleteEnvLockIfEmpty added in v1.16.0

func (s *State) DeleteEnvLockIfEmpty(ctx context.Context, environment string) error

func (*State) DeleteQueuedVersion

func (s *State) DeleteQueuedVersion(environment string, application string) error

func (*State) DeleteQueuedVersionIfExists

func (s *State) DeleteQueuedVersionIfExists(environment string, application string) error

func (*State) GetAppLocksDir added in v1.16.0

func (s *State) GetAppLocksDir(environment string, application string) string

func (*State) GetApplicationRelease

func (s *State) GetApplicationRelease(application string, version uint64) (*Release, error)

func (*State) GetApplicationReleases

func (s *State) GetApplicationReleases(application string) ([]uint64, error)

func (*State) GetApplicationSourceRepoUrl added in v1.16.0

func (s *State) GetApplicationSourceRepoUrl(application string) (string, error)

func (*State) GetApplicationTeamOwner added in v1.16.0

func (s *State) GetApplicationTeamOwner(application string) (string, error)

func (*State) GetApplications

func (s *State) GetApplications() ([]string, error)

func (*State) GetDeploymentMetaData added in v1.16.0

func (s *State) GetDeploymentMetaData(ctx context.Context, environment, application string) (string, time.Time, error)

func (*State) GetEnvLockDir added in v1.16.0

func (s *State) GetEnvLockDir(environment string, lockId string) string

func (*State) GetEnvLocksDir added in v1.16.0

func (s *State) GetEnvLocksDir(environment string) string

func (*State) GetEnvironmentApplicationLocks

func (s *State) GetEnvironmentApplicationLocks(environment, application string) (map[string]Lock, error)

func (*State) GetEnvironmentApplicationVersion

func (s *State) GetEnvironmentApplicationVersion(environment, application string) (*uint64, error)

func (*State) GetEnvironmentApplications

func (s *State) GetEnvironmentApplications(environment string) ([]string, error)

func (*State) GetEnvironmentConfigs

func (s *State) GetEnvironmentConfigs() (map[string]config.EnvironmentConfig, error)

func (*State) GetEnvironmentConfigsAndValidate added in v1.16.0

func (s *State) GetEnvironmentConfigsAndValidate(ctx context.Context) (map[string]config.EnvironmentConfig, error)

func (*State) GetEnvironmentConfigsForGroup added in v1.16.0

func (s *State) GetEnvironmentConfigsForGroup(envGroup string) ([]string, error)

func (*State) GetEnvironmentLocks

func (s *State) GetEnvironmentLocks(environment string) (map[string]Lock, error)

func (*State) GetQueuedVersion

func (s *State) GetQueuedVersion(environment string, application string) (*uint64, error)

func (*State) IsUndeployVersion

func (s *State) IsUndeployVersion(application string, version uint64) (bool, error)

func (*State) ProcessQueue

func (s *State) ProcessQueue(ctx context.Context, fs billy.Filesystem, environment string, application string) (string, error)

ProcessQueue checks if there is something in the queue deploys if necessary deletes the queue

func (*State) ReleaseManifests

func (s *State) ReleaseManifests(application string, release uint64) (map[string]string, error)

func (*State) Releases

func (s *State) Releases(application string) ([]uint64, error)

type StorageBackend added in v1.16.0

type StorageBackend int
const (
	DefaultBackend StorageBackend = 0
	GitBackend     StorageBackend = iota
	SqliteBackend  StorageBackend = iota
)

type SuccessReason added in v1.16.0

type SuccessReason int64
const (
	NoReason SuccessReason = iota
	DirDoesNotExist
	DirNotEmpty
)

type Transformer

type Transformer interface {
	Transform(context.Context, *State) (commitMsg string, changes *TransformerResult, e error)
}

A Transformer updates the files in the worktree

type TransformerFunc

type TransformerFunc func(context.Context, *State) (string, *TransformerResult, error)

func (TransformerFunc) Transform

func (t TransformerFunc) Transform(ctx context.Context, state *State) (string, *TransformerResult, error)

type TransformerResult added in v1.16.0

type TransformerResult struct {
	ChangedApps     []AppEnv
	DeletedRootApps []RootApp
	Commits         *CommitIds
}

func CombineArray added in v1.16.0

func CombineArray(others []*TransformerResult) *TransformerResult

func (*TransformerResult) AddAppEnv added in v1.16.0

func (r *TransformerResult) AddAppEnv(app string, env string)

func (*TransformerResult) AddRootApp added in v1.16.0

func (r *TransformerResult) AddRootApp(env string)

func (*TransformerResult) Combine added in v1.16.0

func (r *TransformerResult) Combine(other *TransformerResult)

type UndeployApplication added in v1.16.0

type UndeployApplication struct {
	Authentication
	Application string
}

func (*UndeployApplication) Transform added in v1.16.0

func (u *UndeployApplication) Transform(ctx context.Context, state *State) (string, *TransformerResult, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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