preview

package
v0.12.1-rc.3 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 23 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 release.Storage,
	planResources *apiv1.Spec,
	priorResources *apiv1.State,
	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

	Detail       bool
	All          bool
	NoStyle      bool
	Output       string
	SpecFile     string
	IgnoreFields []string
	Values       []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

	Detail       bool
	All          bool
	NoStyle      bool
	Output       string
	SpecFile     string
	IgnoreFields []string
	Values       []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