utils

package
v0.117.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: Apache-2.0 Imports: 44 Imported by: 2

Documentation

Index

Constants

View Source
const (
	NoPodname      = "nopodname"
	NoPodnamespace = "nopodnamespace"

	LsHostClientBurstVar     = "LS_HOST_CLIENT_BURST"
	LsHostClientQpsVar       = "LS_HOST_CLIENT_QPS"
	LsResourceClientBurstVar = "LS_RESOURCE_CLIENT_BURST"
	LsResourceClientQpsVar   = "LS_RESOURCE_CLIENT_QPS"

	LsHostClientBurstDefault     = 30
	LsHostClientQpsDefault       = 20
	LsResourceClientBurstDefault = 60
	LsResourceClientQpsDefault   = 40
)
View Source
const (
	Version          = "v1alpha1"
	DeployItemKind   = "DeployItem"
	ExecutionKind    = "Execution"
	InstallationKind = "Installation"
)

Variables

View Source
var InstallationGVK = schema.GroupVersionKind{
	Group:   core.GroupName,
	Version: Version,
	Kind:    InstallationKind,
}

Functions

func CheckIfNewContextDeletion

func CheckIfNewContextDeletion(doList *lsv1alpha1.DataObjectList, targetList *lsv1alpha1.TargetList) bool

added 29th Jan 2024

func ClientsFromManagers

func ClientsFromManagers(lsMgr, hostMgr manager.Manager) (
	lsUncachedClient,
	lsCachedClient,
	hostUncachedClient,
	hostCachedClient client.Client,
	err error,
)

func ConvertCommonControllerConfigToControllerOptions

func ConvertCommonControllerConfigToControllerOptions(cfg config.CommonControllerConfig) controller.Options

ConvertCommonControllerConfigToControllerOptions converts the landscaper CommonControllerConfig to controller.Options.

func CopyFS

func CopyFS(src, dst vfs.FileSystem, srcPath, dstPath string) error

CopyFS copies all files and directories of a filesystem to another.

func EmptyDeployItemMetadata

func EmptyDeployItemMetadata() *metav1.PartialObjectMetadata

func EmptyExecutionMetadata

func EmptyExecutionMetadata() *metav1.PartialObjectMetadata

func EmptyInstallationMetadata

func EmptyInstallationMetadata() *metav1.PartialObjectMetadata

func EmptyPodMetadata

func EmptyPodMetadata() *metav1.PartialObjectMetadata

func EmptyPodMetadataList

func EmptyPodMetadataList() *metav1.PartialObjectMetadataList

func GetCurrentPodName

func GetCurrentPodName() string

func GetCurrentPodNamespace

func GetCurrentPodNamespace() string

func GetHostClientRequestRestrictions

func GetHostClientRequestRestrictions(log logging.Logger, hostAndResourceClusterDifferent bool) (int, int)

func GetResourceClientRequestRestrictions

func GetResourceClientRequestRestrictions(log logging.Logger) (int, int)

func GetSizeOfDirectory

func GetSizeOfDirectory(filesystem vfs.FileSystem, root string) (int64, error)

GetSizeOfDirectory returns the size of all files in a root directory.

func HandlePanics

func HandlePanics(ctx context.Context, result *reconcile.Result, hostUncachedClient client.Client)

func InitErrors

func InitErrors(deployItemStatus *lsv1alpha1.DeployItemStatus)

func IsDeployItemJobIDsIdentical

func IsDeployItemJobIDsIdentical(di *lsv1alpha1.DeployItem) bool

func IsDeployItemPhase

func IsDeployItemPhase(di *lsv1alpha1.DeployItem, phase lsv1alpha1.DeployItemPhase) bool

func IsExecutionJobIDsIdentical

func IsExecutionJobIDsIdentical(exec *lsv1alpha1.Execution) bool

func IsInstallationJobIDsIdentical

func IsInstallationJobIDsIdentical(inst *lsv1alpha1.Installation) bool

func IsInstallationPhase

func IsInstallationPhase(inst *lsv1alpha1.Installation, phase lsv1alpha1.InstallationPhase) bool

func IsRecoverableError

func IsRecoverableError(err error) bool

func JSONSerializeToGenericObject

func JSONSerializeToGenericObject(in interface{}) (interface{}, error)

JSONSerializeToGenericObject converts a typed struct to an generic interface using json serialization.

func LogMemStats added in v0.112.0

func LogMemStats(ctx context.Context, hostUncachedClient client.Client, prefix string)

func LogMemStatsPeriodically added in v0.112.0

func LogMemStatsPeriodically(ctx context.Context, interval time.Duration, hostUncachedClient client.Client, prefix string)

func MergeMaps

func MergeMaps(a, b map[string]interface{}) map[string]interface{}

MergeMaps takes two maps <a>, <b> and merges them. If <b> defines a value with a key already existing in the <a> map, the <a> value for that key will be overwritten.

func NewContextAwareWriter

func NewContextAwareWriter(ctx context.Context, writer io.Writer) io.Writer

NewContextAwareWriter creates a new context aware writer.

func NewForConfig

func NewForConfig(burst, qps int, config *rest.Config) (*kubernetes.Clientset, error)

func NewTransitionTimes

func NewTransitionTimes() *lsv1alpha1.TransitionTimes

NewTransitionTimes creates a TransitionTimes structure. The status of Installations, Executions, and DeployItems contain such a structure with important timestamps. The timestamps are intended to help in the analysis of errors.

  • The TriggerTime is set when the object is triggered, i.e. when it gets a new jobID.
  • The InitTime is set when the responsible controller observes that an object has a new jobID, starts processing it, and sets its phase to Init.
  • The WaitTime is set when the controller has triggered its subobjects (resp. has done its deployment) and starts waiting for its subobjects (resp. for the readiness check).
  • The FinishedTime is set when an object gets into a final phase (Succeeded, Failed, DeleteFailed) and the jobIDFinished is set.

func NewUncached

func NewUncached(burst, qps int, config *rest.Config, options client.Options) (client.Client, error)

func NewUncachedClient

func NewUncachedClient(burst, qps int) func(config *rest.Config, options client.Options) (client.Client, error)

func NewUncachedClientFromManager

func NewUncachedClientFromManager(mgr manager.Manager) (client.Client, error)

func RestConfigWithModifiedClientRequestRestrictions

func RestConfigWithModifiedClientRequestRestrictions(log logging.Logger, restConfig *rest.Config, burst, qps int) *rest.Config

func SetExclusiveOwnerReference

func SetExclusiveOwnerReference(owner client.Object, obj client.Object) (error, error)

SetExclusiveOwnerReference is a wrapper around controllerutil.SetOwnerReference The first return value will contain an error if the object contains already an owner reference of the same kind but pointing to a different owner. The second return value is meant for unexpected errors during the process.

func SetFinishedTransitionTime

func SetFinishedTransitionTime(transitionTimes *lsv1alpha1.TransitionTimes) *lsv1alpha1.TransitionTimes

func SetInitTransitionTime

func SetInitTransitionTime(transitionTimes *lsv1alpha1.TransitionTimes) *lsv1alpha1.TransitionTimes

func SetLastError

func SetLastError(deployItemStatus *lsv1alpha1.DeployItemStatus, err *lsv1alpha1.Error)

func SetWaitTransitionTime

func SetWaitTransitionTime(transitionTimes *lsv1alpha1.TransitionTimes) *lsv1alpha1.TransitionTimes

func StringIsOneOf

func StringIsOneOf(in string, s ...string) bool

StringIsOneOf checks whether in is one of s.

func YAMLReadFromFile

func YAMLReadFromFile(fs vfs.FileSystem, path string, obj interface{}) error

YAMLReadFromFile reads a file from a filesystem and decodes it into the given obj using YAMl/JSON decoder.

Types

type ContextAwareWriter

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

ContextAwareWriter wraps a context and an io writer. When the context is cancelled, the write function will return early before calling write on the io writer.

func (*ContextAwareWriter) Write

func (w *ContextAwareWriter) Write(p []byte) (n int, err error)

Write will check the wrapping context for errors. If the context doesn't return any error, the underlying io writer is called.

type CriticalProblemsHandler

type CriticalProblemsHandler interface {
	ReportProblem(ctx context.Context, hostUncachedClient client.Client, description string)
	GetCriticalProblems(ctx context.Context, hostUncachedClient client.Client) (*v1alpha1.CriticalProblems, error)
	AccessAllowed(ctx context.Context, hostUncachedClient client.Client) error
}

func GetCriticalProblemsHandler

func GetCriticalProblemsHandler() CriticalProblemsHandler

type DeployItemBuilder

type DeployItemBuilder struct {
	ObjectKey             *lsv1alpha1.ObjectReference
	Type                  string
	ProviderConfiguration runtime.Object

	Context string
	// contains filtered or unexported fields
}

DeployItemBuilder is a helper struct to build deploy items

func NewDeployItemBuilder

func NewDeployItemBuilder(tType string) *DeployItemBuilder

NewDeployItemBuilder creates a new deploy item builder

func (*DeployItemBuilder) AddAnnotation

func (b *DeployItemBuilder) AddAnnotation(key, val string) *DeployItemBuilder

AddAnnotation sets a annotation for the deployitem

func (*DeployItemBuilder) Build

Build creates the deploy items using the given options.

func (*DeployItemBuilder) DeepCopy

func (b *DeployItemBuilder) DeepCopy() *DeployItemBuilder

DeepCopy creates a deep copy of the builder and its options. Note that the scheme is not deep copied.

func (*DeployItemBuilder) GenerateJobID

func (b *DeployItemBuilder) GenerateJobID() *DeployItemBuilder

func (*DeployItemBuilder) Key

func (b *DeployItemBuilder) Key(namespace, name string) *DeployItemBuilder

Key sets the deployitem's namespace and name.

func (*DeployItemBuilder) ProviderConfig

func (b *DeployItemBuilder) ProviderConfig(obj runtime.Object) *DeployItemBuilder

ProviderConfig sets the deployitem provider configuration.

func (*DeployItemBuilder) Scheme

func (b *DeployItemBuilder) Scheme(scheme *runtime.Scheme) *DeployItemBuilder

Scheme sets the deployitem scheme that is used for the provider config

func (*DeployItemBuilder) Target

func (b *DeployItemBuilder) Target(namespace, name string) *DeployItemBuilder

Target sets the deployitem's target from a name and namespace

func (*DeployItemBuilder) TargetFromObjectKey

func (b *DeployItemBuilder) TargetFromObjectKey(tgt client.ObjectKey) *DeployItemBuilder

TargetFromObjectKey sets the deployitem's target from a client key.

func (*DeployItemBuilder) TargetFromObjectRef

func (b *DeployItemBuilder) TargetFromObjectRef(tgt *lsv1alpha1.ObjectReference) *DeployItemBuilder

TargetFromObjectRef sets the deployitem's target.

func (*DeployItemBuilder) Validate

func (b *DeployItemBuilder) Validate() error

func (*DeployItemBuilder) WithContext

func (b *DeployItemBuilder) WithContext(name string) *DeployItemBuilder

WithContext sets the Landscaper Context to use for the deployitem. If not set explicitly, the default context will be used.

func (*DeployItemBuilder) WithTimeout

func (b *DeployItemBuilder) WithTimeout(timeout time.Duration) *DeployItemBuilder

type FinishedObjectCache

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

func NewFinishedObjectCache

func NewFinishedObjectCache() *FinishedObjectCache

func (*FinishedObjectCache) Add

func (*FinishedObjectCache) AddSynchonized

func (c *FinishedObjectCache) AddSynchonized(m *metav1.ObjectMeta)

func (*FinishedObjectCache) IsContained

func (c *FinishedObjectCache) IsContained(req reconcile.Request) bool

func (*FinishedObjectCache) IsFinishedOrRemove

func (c *FinishedObjectCache) IsFinishedOrRemove(m *metav1.PartialObjectMetadata) bool

type LogHelper

type LogHelper struct {
}

func (LogHelper) LogErrorAndGetReconcileResult

func (LogHelper) LogErrorAndGetReconcileResult(ctx context.Context, lsError lserrors.LsError) (reconcile.Result, error)

func (LogHelper) LogErrorButNotFoundAsInfo

func (LogHelper) LogErrorButNotFoundAsInfo(ctx context.Context, err error, message string)

func (LogHelper) LogStandardErrorAndGetReconcileResult

func (LogHelper) LogStandardErrorAndGetReconcileResult(ctx context.Context, err error) (reconcile.Result, error)

type PerformanceMeasurement

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

func StartPerformanceMeasurement

func StartPerformanceMeasurement(log *logging.Logger, description string) *PerformanceMeasurement

func (*PerformanceMeasurement) Stop

func (p *PerformanceMeasurement) Stop()

func (*PerformanceMeasurement) StopDebug added in v0.105.0

func (p *PerformanceMeasurement) StopDebug()

type TargetBuilder

type TargetBuilder struct {
	Type          string
	ObjectKey     *lsv1alpha1.ObjectReference
	Configuration interface{}
	Ref           *lsv1alpha1.LocalSecretReference
	// contains filtered or unexported fields
}

TargetBuilder is a helper struct to build targets

func NewTargetBuilder

func NewTargetBuilder(tType string) *TargetBuilder

NewTargetBuilder creates a new target builder

func (*TargetBuilder) AddAnnotation

func (b *TargetBuilder) AddAnnotation(key, val string) *TargetBuilder

AddAnnotation sets a annotation for the deployitem

func (*TargetBuilder) Build

func (b *TargetBuilder) Build() (*lsv1alpha1.Target, error)

Build creates the target using the given options.

func (*TargetBuilder) Config

func (b *TargetBuilder) Config(obj interface{}) *TargetBuilder

Config sets the target config that is used for the provider config

func (*TargetBuilder) Key

func (b *TargetBuilder) Key(namespace, name string) *TargetBuilder

Key sets the deployitem's namespace and name.

func (*TargetBuilder) SecretRef

func (b *TargetBuilder) SecretRef(secretRef *lsv1alpha1.LocalSecretReference) *TargetBuilder

type WorkerCounter

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

func NewWorkerCounter

func NewWorkerCounter(maxNumOfWorker int) *WorkerCounter

func (*WorkerCounter) Enter

func (r *WorkerCounter) Enter() int

func (*WorkerCounter) EnterWithLog

func (r *WorkerCounter) EnterWithLog(log logging.Logger, percentageBorder int, callerName string) int

func (*WorkerCounter) Exit

func (r *WorkerCounter) Exit() int

Jump to

Keyboard shortcuts

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