engine

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2022 License: Apache-2.0 Imports: 9 Imported by: 5

Documentation

Overview

Package engine holds code that drive the engine of Kusion.

Kusion Engine is a middle layer between Spec and the actual infrastructure. The major function of this engine is to parse the Spec and to turn all actual infra resources into the desired state described in the Spec and almost all operations from the command line will invoke this engine to finish their jobs.

It consists of 3 parts:

1. Operation Engine: this part is the entrypoint of the whole Kusion Engine and is responsible for kusion basic operations like Preview, Apply, Destroy, etc. The main workflow of this part is to parse resources in the Spec, figure out which resource should be modified according to specified operation type, and execute this operation to the real infra resources. During this workflow, the following two parts will be involved.

2. Runtime: it is an interface between the actual infrastructure and Kusion. All operations that trying to manipulate a resource should be delegated to one Runtime to make this operation effect in the actual infrastructure

3. State: state is a record of an operation's result. It is often used as a datasource for 3-way merge/diff in operations like Apply or Preview

Let's get operation Preview as an example to demonstrate how the three parts cooperate in an actual operation.

                 +-------------+
                 |  Operation  |
                 |  Preview    |
                 +-------------+
                        |
                        |
                 +-------------+
                 |  Operation  |
       +---------|  Engine     |----------+
       |         +-------------+          |
       |                                  |
+-------------+                    +-------------+
|   State     |                    |   Runtime   |
+-------------+                    +-------------+

1. parse resources in the Spec and convert into a DAG

  1. Walk this DAG: a) get the latest state from the actual infra by the Runtime b) get last operation state from the State

3. Diff the two states(live state and prior state) and return the details of these diffs to cmd

Index

Constants

View Source
const MaxLogLength = 3751
View Source
const (
	Separator = ":"
)

Variables

This section is empty.

Functions

func BuildIDForKubernetes

func BuildIDForKubernetes(apiVersion, kind, namespace, name string) string

func ConvertKCLResult2Resources

func ConvertKCLResult2Resources(resourceYAMLs []kcl.KCLResult) (*models.Spec, error)

func NewRequestResourceForKubernetes

func NewRequestResourceForKubernetes(r kcl.KCLResult) (*models.Resource, string, error)

Types

This section is empty.

Directories

Path Synopsis
dal
Package operation contains code for basic operations like Apply, Preview and Destroy
Package operation contains code for basic operations like Apply, Preview and Destroy
models
Package models contains internal models of operations todo CLI imports this package directly.
Package models contains internal models of operations todo CLI imports this package directly.
Package runtime contains code of all infrastructure runtimes supported by Kusion.
Package runtime contains code of all infrastructure runtimes supported by Kusion.
Package states contains code for all storage medium supported by Kusion.
Package states contains code for all storage medium supported by Kusion.

Jump to

Keyboard shortcuts

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