preview

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: 19 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCmdPreview

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

NewCmdPreview creates the `preview` command.

func Preview

func Preview(
	opts *PreviewOptions,
	storage state.Storage,
	planResources *apiv1.Spec,
	project *apiv1.Project,
	stack *apiv1.Stack,
) (*models.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
}

Types

type PreviewFlags

type PreviewFlags struct {
	MetaFlags *meta.MetaFlags

	Operator     string
	Detail       bool
	All          bool
	NoStyle      bool
	Output       string
	IgnoreFields []string

	UI *terminal.UI

	genericiooptions.IOStreams
}

PreviewFlags directly reflect the information that CLI is gathering via flags. They will be converted to PreviewOptions, 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 NewPreviewFlags added in v0.11.1

func NewPreviewFlags(ui *terminal.UI, streams genericiooptions.IOStreams) *PreviewFlags

NewPreviewFlags returns a default PreviewFlags

func (*PreviewFlags) AddFlags added in v0.11.1

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

AddFlags registers flags for a cli.

func (*PreviewFlags) ToOptions added in v0.11.1

func (f *PreviewFlags) ToOptions() (*PreviewOptions, error)

ToOptions converts from CLI inputs to runtime inputs.

type PreviewOptions

type PreviewOptions struct {
	*meta.MetaOptions

	Operator     string
	Detail       bool
	All          bool
	NoStyle      bool
	Output       string
	IgnoreFields []string

	UI *terminal.UI

	genericiooptions.IOStreams
}

PreviewOptions defines flags and other configuration parameters for the `preview` command.

func (*PreviewOptions) Run

func (o *PreviewOptions) Run() error

Run executes the `preview` command.

func (*PreviewOptions) Validate

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

Validate verifies if PreviewOptions are valid and without conflicts.

Jump to

Keyboard shortcuts

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