Documentation ¶
Index ¶
- func Apply(o *ApplyOptions, storage state.Storage, planResources *apiv1.Spec, ...) error
- func NewCmdApply(ui *terminal.UI, ioStreams genericiooptions.IOStreams) *cobra.Command
- func PortForward(o *ApplyOptions, spec *apiv1.Spec) error
- func Watch(o *ApplyOptions, planResources *apiv1.Spec, changes *models.Changes) error
- type ApplyFlags
- type ApplyOptions
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 ¶
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 ¶
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.