apply

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: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(
	o *ApplyOptions,
	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 NewCmdApply

func NewCmdApply(ui *terminal.UI, ioStreams genericiooptions.IOStreams) *cobra.Command

NewCmdApply creates the `apply` command.

func PortForward added in v0.11.1

func PortForward(
	o *ApplyOptions,
	spec *apiv1.Spec,
) error

PortForward function will forward the specified port from local to the project Kubernetes Service.

Example:

o := NewApplyOptions() spec, err := generate.GenerateSpecWithSpinner(o.RefProject, o.RefStack, o.RefWorkspace, nil, o.NoStyle)

if err != nil {
	 return err
}

err = PortForward(o, spec)

if err != nil {
  return err
}

func Watch

func Watch(
	o *ApplyOptions,
	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 ApplyFlags added in v0.11.1

type ApplyFlags struct {
	*preview.PreviewFlags

	Yes         bool
	DryRun      bool
	Watch       bool
	PortForward int

	genericiooptions.IOStreams
}

ApplyFlags directly reflect the information that CLI is gathering via flags. They will be converted to ApplyOptions, which reflect the runtime requirements for the command.

This structure reduces the transformation to wiring and makes the logic itself easy to unit test.

func NewApplyFlags added in v0.11.1

func NewApplyFlags(ui *terminal.UI, streams genericiooptions.IOStreams) *ApplyFlags

NewApplyFlags returns a default ApplyFlags

func (*ApplyFlags) AddFlags added in v0.11.1

func (f *ApplyFlags) AddFlags(cmd *cobra.Command)

AddFlags registers flags for a cli.

func (*ApplyFlags) ToOptions added in v0.11.1

func (f *ApplyFlags) ToOptions() (*ApplyOptions, error)

ToOptions converts from CLI inputs to runtime inputs.

type ApplyOptions

type ApplyOptions struct {
	*preview.PreviewOptions

	Yes         bool
	DryRun      bool
	Watch       bool
	PortForward int

	genericiooptions.IOStreams
}

ApplyOptions defines flags and other configuration parameters for the `apply` command.

func (*ApplyOptions) Run

func (o *ApplyOptions) Run() error

Run executes the `apply` command.

func (*ApplyOptions) Validate

func (o *ApplyOptions) Validate(cmd *cobra.Command, args []string) error

Validate verifies if ApplyOptions are valid and without conflicts.

Jump to

Keyboard shortcuts

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