v1alpha1

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: Apache-2.0 Imports: 14 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TemplateFunctions

func TemplateFunctions() template.FuncMap

TemplateFunctions exposes a few functions as go template functions to be used for upgrade result

func UpdateTasks

func UpdateTasks(opts ...UpgradeResultForTaskOption) error

UpdateTasks is a template function exposed for updating an upgrade result instance

Types

type Builder

type Builder struct {
	*UpgradeResult
	// contains filtered or unexported fields
}

Builder enables building an instance of upgradeResult

func BuilderForYAMLObject

func BuilderForYAMLObject(object []byte) *Builder

BuilderForYAMLObject returns a new instance of Builder for a given template object

func NewBuilder

func NewBuilder() *Builder

NewBuilder returns a new instance of Builder

func (*Builder) AddCheck

func (b *Builder) AddCheck(p Predicate) *Builder

AddCheck adds the predicate as a condition to be validated against the upgrade result instance

func (*Builder) AddCheckf

func (b *Builder) AddCheckf(p Predicate, predicateMsg string, args ...interface{}) *Builder

AddCheckf adds the predicate as a condition to be validated against the upgrade result instance and format the message string according to format specifier. If only predicate and message string is provided, it will treat it as the value for the corresponding predicate.

func (*Builder) AddChecks

func (b *Builder) AddChecks(predicates ...Predicate) *Builder

AddChecks adds the provided predicates as conditions to be validated against the upgrade result instance

func (*Builder) Build

func (b *Builder) Build() (*apis.UpgradeResult, error)

Build returns the final instance of upgradeResult

func (*Builder) WithObjectMeta

func (b *Builder) WithObjectMeta(objectMeta metav1.ObjectMeta) *Builder

WithObjectMeta adds objectMeta in upgrade result instance.

func (*Builder) WithResultConfig

func (b *Builder) WithResultConfig(resource apis.ResourceDetails,
	data ...apis.DataItem) *Builder

WithResultConfig adds resource details and runtime config in upgrade result instance.

func (*Builder) WithTasks

func (b *Builder) WithTasks(tasks ...apis.UpgradeResultTask) *Builder

WithTasks adds tasks details in upgrade result instance.

func (*Builder) WithTypeMeta

func (b *Builder) WithTypeMeta(typeMeta metav1.TypeMeta) *Builder

WithTypeMeta adds typemeta in upgrade result instance.

type CoreClient

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

CoreClient holds all the properties that are required to execute a K8s API call. All of these properties can be set once in the lifetime of the application. In other words, a CoreClient instance should ideally be a singleton.

type Kubeclient

type Kubeclient struct {
	// CoreClient has all the core kubernetes client
	// related options
	*CoreClient
	// contains filtered or unexported fields
}

Kubeclient enables kubernetes API operations on upgraderesult instance

func KubeClientInstanceOrDie

func KubeClientInstanceOrDie(opts ...KubeclientBuildOption) *Kubeclient

KubeClientInstanceOrDie returns the singleton instance of Kubeclient

NOTE:

Here singleton points to CoreClient instance only since a Kubeclient

instance needs to change at runtime based on namespace. CoreClient's clientset instance is the only field that is needed to be initialized to consider Kubeclient as a singleton.

NOTE:

In order to keep this logic more caller code friendly, this function

is not named as CoreClientInstanceOrDie.

Usage:

Caller code will use syntax(-es) as shown below:

```go import (

uresult "github.com/openebs/maya/pkg/upgrade/result/v1alpha1"

)

uresult.KubeClientInstanceOrDie().WithNamespace("my_ns").Get(...) uresult.KubeClientInstanceOrDie().WithNamespace("my_ns").Create(...) uresult.KubeClientInstanceOrDie().WithNamespace("my_ns").Update(...) uresult.KubeClientInstanceOrDie().WithNamespace("my_ns").List(...) ```

func NewKubeClient

func NewKubeClient(opts ...KubeclientBuildOption) *Kubeclient

NewKubeClient returns a new instance of Kubeclient

func (*Kubeclient) Create

func (k *Kubeclient) Create(upgradeResultObj *apis.UpgradeResult) (*apis.UpgradeResult, error)

Create creates an upgrade result instance in kubernetes cluster

func (*Kubeclient) CreateRaw

func (k *Kubeclient) CreateRaw(upgradeResultObj *apis.UpgradeResult) ([]byte, error)

CreateRaw creates an upgrade result instance and returns raw upgradeResult instance

func (*Kubeclient) Get

func (k *Kubeclient) Get(name string, opts metav1.GetOptions) (*apis.UpgradeResult, error)

Get returns an upgrade result instance from kubernetes cluster

func (*Kubeclient) List

List returns a list of upgrade result instances present in kubernetes cluster

func (*Kubeclient) Patch

func (k *Kubeclient) Patch(name string, pt types.PatchType,
	patchObj []byte) (*apis.UpgradeResult, error)

Patch returns the patched upgrade result instance

func (*Kubeclient) Update

func (k *Kubeclient) Update(updateObj *apis.UpgradeResult) (*apis.UpgradeResult, error)

Update returns the updated upgrade result instance

func (*Kubeclient) WithNamespace

func (k *Kubeclient) WithNamespace(namespace string) *Kubeclient

WithNamespace sets namespace that should be used during kuberenets API calls against upgradeResult resource

type KubeclientBuildOption

type KubeclientBuildOption func(*Kubeclient)

KubeclientBuildOption is a typed function that abstracts building an instance of Kubeclient

func WithClientset

func WithClientset(c *clientset.Clientset) KubeclientBuildOption

WithClientset sets the kubernetes clientset against the kubeclient instance

func WithKubeConfigPath

func WithKubeConfigPath(path string) KubeclientBuildOption

WithKubeConfigPath sets the kubeConfig path against client instance

type ListBuilder

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

ListBuilder enables building an instance of upgradeResultList

func NewListBuilder

func NewListBuilder() *ListBuilder

NewListBuilder returns a new instance of ListBuilder

func (*ListBuilder) List

func (b *ListBuilder) List() *UpgradeResultList

List returns the list of ur instances that was built by this Builder

func (*ListBuilder) WithAPIList

func (b *ListBuilder) WithAPIList(list *apis.UpgradeResultList) *ListBuilder

WithAPIList builds the list of ur instances based on the provided ur api instances

type Predicate

type Predicate func(*UpgradeResult) bool

Predicate abstracts conditional logic w.r.t the upgradeResult instance

NOTE: Predicate is a functional approach versus traditional approach to mix conditions such as *if-else* within blocks of business logic

NOTE: Predicate approach enables clear separation of conditionals from imperatives i.e. actions that form the business logic

type UpgradeResult

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

UpgradeResult holds the apis upgraderesult object

type UpgradeResultForTask

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

UpgradeResultForTask enables update operation on upgrade result task instance

func NewUpgradeResultForTask

func NewUpgradeResultForTask(opts ...UpgradeResultForTaskOption) *UpgradeResultForTask

NewUpgradeResultForTask returns a new instance of updateUpgradeResult meant for updating an upgrade result instance

type UpgradeResultForTaskOption

type UpgradeResultForTaskOption func(*UpgradeResultForTask)

UpgradeResultForTaskOption defines the abstraction to build an update instance for upgrade result's task

func WithTaskEndTime

func WithTaskEndTime(endTime time.Time) UpgradeResultForTaskOption

WithTaskEndTime sets the time when the task finished execution

func WithTaskMessage

func WithTaskMessage(message string) UpgradeResultForTaskOption

WithTaskMessage sets the message for a particular task i.e. the message about its successful completion or failure

func WithTaskName

func WithTaskName(name string) UpgradeResultForTaskOption

WithTaskName sets the name of the task to be updated

func WithTaskOwnerName

func WithTaskOwnerName(name string) UpgradeResultForTaskOption

WithTaskOwnerName sets the name of the upgrade result

func WithTaskOwnerNamespace

func WithTaskOwnerNamespace(namespace string) UpgradeResultForTaskOption

WithTaskOwnerNamespace sets namespace where upgrade result is present

func WithTaskRetries

func WithTaskRetries(retries int) UpgradeResultForTaskOption

WithTaskRetries sets the no of times that a runtask has retried executing a particular task

func WithTaskStartTime

func WithTaskStartTime(startTime time.Time) UpgradeResultForTaskOption

WithTaskStartTime sets the time when the task started to execute

func WithTaskStatus

func WithTaskStatus(status string) UpgradeResultForTaskOption

WithTaskStatus sets the current status of the task i.e. whether it has successfully completed or not

type UpgradeResultList

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

UpgradeResultList is the list of upgradeResults

Jump to

Keyboard shortcuts

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