repository

package
v1.24.1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: MIT Imports: 50 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InvalidJson = errors.New("JSON file is not valid")

Functions

func AddGeneratorToContext added in v1.22.0

func AddGeneratorToContext(ctx context.Context, gen uuid.GenerateUUIDs) context.Context

func GaugeDeploymentMetric added in v1.24.0

func GaugeDeploymentMetric(_ context.Context, env, app string, timeInMinutes float64) error

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(ctx context.Context, 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(ctx context.Context, state *State, changes *TransformerResult, now time.Time) 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
	Team 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
	WriteCommitData bool
}

func (*CreateApplicationVersion) Transform

func (c *CreateApplicationVersion) Transform(
	ctx context.Context,
	state *State,
	t TransformerContext,
) (string, error)

type CreateEnvironment

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

func (*CreateEnvironment) Transform

func (c *CreateEnvironment) Transform(
	ctx context.Context,
	state *State,
	t TransformerContext,
) (string, 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

func (c *CreateEnvironmentGroupLock) Transform(
	ctx context.Context,
	state *State,
	t TransformerContext,
) (string, error)

type CreateEnvironmentLock

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

func (*CreateEnvironmentLock) Transform

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

type CreateReleaseError added in v1.19.1

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

func GetCreateReleaseAlreadyExistsDifferent added in v1.19.1

func GetCreateReleaseAlreadyExistsDifferent(firstDifferingField api.DifferingField, diff string) *CreateReleaseError

func GetCreateReleaseAlreadyExistsSame added in v1.19.1

func GetCreateReleaseAlreadyExistsSame() *CreateReleaseError

func GetCreateReleaseAppNameTooLong added in v1.19.1

func GetCreateReleaseAppNameTooLong(appName string, regExp string, maxLen uint32) *CreateReleaseError

func GetCreateReleaseGeneralFailure added in v1.19.1

func GetCreateReleaseGeneralFailure(err error) *CreateReleaseError

func GetCreateReleaseTooOld added in v1.19.1

func GetCreateReleaseTooOld() *CreateReleaseError

func (*CreateReleaseError) Error added in v1.19.1

func (e *CreateReleaseError) Error() string

func (*CreateReleaseError) Response added in v1.19.1

type CreateUndeployApplicationVersion

type CreateUndeployApplicationVersion struct {
	Authentication
	Application string
}

func (*CreateUndeployApplicationVersion) Transform

type Credentials

type Credentials struct {
	SshKey string
}

type DefaultWebhookResolver added in v1.24.1

type DefaultWebhookResolver struct{}

func (DefaultWebhookResolver) Resolve added in v1.24.1

func (r DefaultWebhookResolver) Resolve(insecure bool, req *http.Request) (*http.Response, error)

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,
	t TransformerContext,
) (string, 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

func (c *DeleteEnvironmentGroupLock) Transform(
	ctx context.Context,
	state *State,
	t TransformerContext,
) (string, error)

type DeleteEnvironmentLock

type DeleteEnvironmentLock struct {
	Authentication
	Environment string
	LockId      string
}

func (*DeleteEnvironmentLock) Transform

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

type DeployApplicationVersion

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

func (*DeployApplicationVersion) Transform

func (c *DeployApplicationVersion) Transform(
	ctx context.Context,
	state *State,
	t TransformerContext,
) (string, error)

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 Overview added in v1.24.1

type Overview struct {
	App     string
	Version 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

func (c *QueueApplicationVersion) Transform(
	ctx context.Context,
	state *State,
	t TransformerContext,
) (string, error)

type RawNode added in v1.19.1

type RawNode struct{ *yaml3.Node }

func (*RawNode) UnmarshalYAML added in v1.19.1

func (n *RawNode) UnmarshalYAML(node *yaml3.Node) error

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
	CommitHash string
	Repo       Repository
}

func (*ReleaseTrain) Transform

func (c *ReleaseTrain) Transform(
	ctx context.Context,
	state *State,
	t TransformerContext,
) (string, 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
	DogstatsdEvents bool
	WriteCommitData bool
	WebhookResolver WebhookResolver
}

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(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) GetEnvironmentConfig added in v1.24.0

func (s *State) GetEnvironmentConfig(environmentName string) (*config.EnvironmentConfig, 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, TransformerContext) (commitMsg string, e error)
}

A Transformer updates the files in the worktree

type TransformerContext added in v1.24.0

type TransformerContext interface {
	Execute(Transformer) error
	AddAppEnv(app string, env string, team string)
	DeleteEnvFromApp(app string, env string)
}

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 RunTransformer added in v1.24.0

func RunTransformer(ctx context.Context, t Transformer, s *State) (string, *TransformerResult, error)

func (*TransformerResult) AddAppEnv added in v1.16.0

func (r *TransformerResult) AddAppEnv(app string, env string, team 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,
	t TransformerContext,
) (string, error)

type WebhookResolver added in v1.24.1

type WebhookResolver interface {
	Resolve(insecure bool, req *http.Request) (*http.Response, error)
}

Directories

Path Synopsis
This file is part of kuberpult.
This file is part of kuberpult.

Jump to

Keyboard shortcuts

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