runtime

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

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

Index

Constants

View Source
const (
	Kubernetes apiv1.Type = "Kubernetes"
	Terraform  apiv1.Type = "Terraform"
)
View Source
const (
	// TFApplying means the TF resource is still being applied.
	TFApplying = TFEvent("Applying")
	// TFSucceeded means the TF resource operation has succeeded.
	TFSucceeded = TFEvent("Succeeded")
	// TFFailed means the TF resource operation has failed.
	TFFailed = TFEvent("Failed")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplyRequest

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

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

	// Stack contains info about where this command is invoked
	Stack *apiv1.Stack

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

type ApplyResponse

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

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

type DeleteRequest

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

	// Stack contains info about where this command is invoked
	Stack *apiv1.Stack
}

type DeleteResponse

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

type ImportRequest

type ImportRequest struct {
	// PlanResource is the resource we want to apply in this request
	PlanResource *apiv1.Resource

	// Stack contains info about where this command is invoked
	Stack *apiv1.Stack
}

type ImportResponse

type ImportResponse struct {
	// Resource is the result returned by Runtime
	Resource *apiv1.Resource

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

type ReadRequest

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

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

	// Stack contains info about where this command is invoked
	Stack *apiv1.Stack
}

type ReadResponse

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

	// Status contains messages will show to users
	Status v1.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

	// Import Resource that already existed in the actual infrastructure
	Import(ctx context.Context, request *ImportRequest) *ImportResponse

	// 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. Fixme: update the runtime interface definition of requests and responses.

type SequentialWatchers

type SequentialWatchers struct {
	IDs      []string
	Watchers []<-chan watch.Event
	// TFWatcher is for watching the operation event of the Terraform resources.
	TFWatcher <-chan TFEvent
}

func NewWatchers

func NewWatchers() *SequentialWatchers

func (*SequentialWatchers) Insert

func (w *SequentialWatchers) Insert(id string, watcher <-chan watch.Event)

type TFEvent

type TFEvent string

TFEvent represents the status of the Terraform resource operation event.

type WatchRequest

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

type WatchResponse

type WatchResponse struct {
	Watchers *SequentialWatchers

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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