api

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const JSONOutput = "json"

Variables

This section is empty.

Functions

func Apply

func Apply(
	o *APIOptions,
	storage state.Storage,
	planResources *apiv1.Spec,
	changes *models.Changes,
	out io.Writer,
) error

The Apply function will apply the resources changes through the execution Kusion Engine, and will save the state to specified storage.

You can customize the runtime of engine and the state storage through `runtime` and `storage` parameters.

Example:

o := NewApplyOptions()
stateStorage := &states.FileSystemState{
    Path: filepath.Join(o.WorkDir, states.KusionState)
}
kubernetesRuntime, err := runtime.NewKubernetesRuntime()
if err != nil {
    return err
}

err = Apply(o, kubernetesRuntime, stateStorage, planResources, changes, os.Stdout)
if err != nil {
    return err
}

func Destroy

func Destroy(
	o *APIOptions,
	planResources *apiv1.Spec,
	changes *models.Changes,
	stateStorage state.Storage,
) error

func DestroyPreview

func DestroyPreview(
	o *APIOptions,
	planResources *apiv1.Spec,
	proj *apiv1.Project,
	stack *apiv1.Stack,
	stateStorage state.Storage,
) (*models.Changes, error)

func GenerateSpecWithSpinner

func GenerateSpecWithSpinner(project *v1.Project, stack *v1.Stack, workspace *v1.Workspace, noStyle bool) (*v1.Spec, error)

GenerateSpecWithSpinner calls generator to generate versioned Spec. Add a method wrapper for testing purposes.

func Preview

func Preview(
	o *APIOptions,
	storage state.Storage,
	planResources *apiv1.Spec,
	proj *apiv1.Project,
	stack *apiv1.Stack,
) (*opsmodels.Changes, error)

The Preview function calculates the upcoming actions of each resource through the execution Kusion Engine, and you can customize the runtime of engine and the state storage through `runtime` and `storage` parameters.

Example:

o := NewPreviewOptions()
stateStorage := &states.FileSystemState{
    Path: filepath.Join(o.WorkDir, states.KusionState)
}
kubernetesRuntime, err := runtime.NewKubernetesRuntime()
if err != nil {
    return err
}

changes, err := Preview(o, kubernetesRuntime, stateStorage,
    planResources, project, stack, os.Stdout)
if err != nil {
    return err
}

func SpecFromFile

func SpecFromFile(filePath string) (*v1.Spec, error)

func Watch

func Watch(
	o *APIOptions,
	planResources *apiv1.Spec,
	changes *models.Changes,
) error

Watch function will observe the changes of each resource by the execution engine.

Example:

o := NewApplyOptions()
kubernetesRuntime, err := runtime.NewKubernetesRuntime()
if err != nil {
    return err
}

Watch(o, kubernetesRuntime, planResources, changes, os.Stdout)
if err != nil {
    return err
}

Types

type APIOptions

type APIOptions struct {
	Operator     string
	Cluster      string
	IgnoreFields []string
	DryRun       bool
}

func NewAPIOptions

func NewAPIOptions() APIOptions

Directories

Path Synopsis
generate
run

Jump to

Keyboard shortcuts

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