runtime

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: Apache-2.0 Imports: 26 Imported by: 8

Documentation

Overview

Package runtime contains code of all infrastructure runtimes supported by Kusion.

Index

Constants

View Source
const (
	Kubernetes models.Type = "Kubernetes"
	Terraform  models.Type = "Terraform"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplyRequest added in v0.5.1

type ApplyRequest struct {
	// PriorResource is the last applied resource saved in state storage
	PriorResource *models.Resource

	// PlanResource is the resource we want to apply in this request
	PlanResource *models.Resource

	// DryRun means this a dry-run request and will not make any changes in actual infra
	DryRun bool
}

type ApplyResponse added in v0.5.1

type ApplyResponse struct {
	// Resource is the result returned by Runtime
	Resource *models.Resource

	// Status contains messages will show to users
	Status status.Status
}

type DeleteRequest added in v0.5.1

type DeleteRequest struct {
	// Resource represents the resource we want to delete from the actual infra
	Resource *models.Resource
}

type DeleteResponse added in v0.5.1

type DeleteResponse struct {
	// Status contains messages will show to users
	Status status.Status
}

type KubernetesRuntime

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

func (*KubernetesRuntime) Apply

func (k *KubernetesRuntime) Apply(ctx context.Context, request *ApplyRequest) *ApplyResponse

Apply kubernetes Resource by client-go

func (*KubernetesRuntime) Delete

func (k *KubernetesRuntime) Delete(ctx context.Context, request *DeleteRequest) *DeleteResponse

Delete kubernetes Resource by client-go

func (*KubernetesRuntime) Read

func (k *KubernetesRuntime) Read(ctx context.Context, request *ReadRequest) *ReadResponse

Read kubernetes Resource by client-go

func (*KubernetesRuntime) Watch

func (k *KubernetesRuntime) Watch(ctx context.Context, request *WatchRequest) *WatchResponse

Watch kubernetes resource by client-go

func (*KubernetesRuntime) WatchByRelation added in v0.7.2

func (k *KubernetesRuntime) WatchByRelation(
	ctx context.Context,
	cur *unstructured.Unstructured,
	gvk schema.GroupVersionKind,
	related func(watched, cur *unstructured.Unstructured) bool,
) (<-chan k8swatch.Event, *unstructured.Unstructured, error)

WatchByRelation watched resources by giving gvk if related() return true

func (*KubernetesRuntime) WatchBySelector added in v0.7.2

func (k *KubernetesRuntime) WatchBySelector(
	ctx context.Context,
	o *unstructured.Unstructured,
	gvk schema.GroupVersionKind,
	labelStr string,
) (<-chan k8swatch.Event, error)

WatchBySelector watch resources by gvk and filter by selector

type ReadRequest added in v0.5.1

type ReadRequest struct {
	// PriorResource is the last applied resource saved in state storage
	PriorResource *models.Resource

	// PlanResource is the resource we want to apply in this request
	PlanResource *models.Resource
}

type ReadResponse added in v0.5.1

type ReadResponse struct {
	// Resource is the result read from the actual infra
	Resource *models.Resource

	// Status contains messages will show to users
	Status status.Status
}

type Runtime

type Runtime interface {
	// Apply means modify this Resource to the desired state described in the request,
	// and it will turn into creating or updating a Resource in most scenarios.
	// If the infrastructure runtime already provides an Apply method that conform to this method's semantics meaning,
	// like the Kubernetes Runtime, you can directly invoke this method without any conversion.
	// PlanResource and priorState are given in this method for the runtime which would make a
	// three-way-merge (planState,priorState and live state) when implementing this interface
	Apply(ctx context.Context, request *ApplyRequest) *ApplyResponse

	// Read the latest state of this Resource
	Read(ctx context.Context, request *ReadRequest) *ReadResponse

	// Delete this Resource in the actual infrastructure and return success if this Resource is not exist
	Delete(ctx context.Context, request *DeleteRequest) *DeleteResponse

	// Watch the latest state or event of this Resource.
	// This is an optional method for the Runtime to implement,
	// but it will be very helpful for us to know what is happening when applying this Resource
	Watch(ctx context.Context, request *WatchRequest) *WatchResponse
}

Runtime represents an actual infrastructure runtime managed by Kusion and every runtime implements this interface can be orchestrated by Kusion like normal K8s resources. All methods in this interface are designed for manipulating one Resource at a time and will be invoked in operations like Apply, Preview, Destroy, etc.

func NewKubernetesRuntime

func NewKubernetesRuntime() (Runtime, error)

NewKubernetesRuntime create a new KubernetesRuntime

type WatchRequest added in v0.5.1

type WatchRequest struct {
	// Resource represents the resource we want to watch from the actual infra
	Resource *models.Resource
}

type WatchResponse added in v0.5.1

type WatchResponse struct {
	ResultChs []<-chan watch.Event

	// Status contains messages will show to users
	Status status.Status
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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