dryrun

package
v1.9.11 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 35 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiffEntry

type DiffEntry struct {
	Name     string               `json:"name"`
	Kind     ManifestKind         `json:"kind"`
	DiffType DiffType             `json:"diffType,omitempty"`
	Diffs    []difflib.DiffRecord `json:"diffs,omitempty"`
	Subs     []*DiffEntry         `json:"subs,omitempty"`
}

DiffEntry records diff info of OAM object

type DiffType

type DiffType string

DiffType enums the type of diff

const (
	AddDiff    DiffType = "ADD"
	ModifyDiff DiffType = "MODIFY"
	RemoveDiff DiffType = "REMOVE"
	NoDiff     DiffType = ""
)

enum types of diff

type DryRun

type DryRun interface {
	ExecuteDryRun(ctx context.Context, app *v1beta1.Application) ([]*types.ComponentManifest, []*unstructured.Unstructured, error)
}

DryRun executes dry-run on an application

type GenerateAppFileFunc added in v1.8.0

type GenerateAppFileFunc func(ctx context.Context, app *v1beta1.Application) (*appfile.Appfile, error)

GenerateAppFileFunc generate the app file model from an application

type LiveDiffObject

type LiveDiffObject struct {
	*v1beta1.Application
	*v1beta1.ApplicationRevision
}

LiveDiffObject wraps the objects for diff

type LiveDiffOption

type LiveDiffOption struct {
	DryRun
	Parser *appfile.Parser
}

LiveDiffOption contains options for comparing an application with a living AppRevision in the cluster

func NewLiveDiffOption

NewLiveDiffOption creates a live-diff option

func (*LiveDiffOption) Diff

Diff does three phases, dry-run on input app, preparing manifest for diff, and calculating diff on manifests. TODO(wonderflow): vela live-diff don't diff for policies now.

func (*LiveDiffOption) DiffApps

func (l *LiveDiffOption) DiffApps(ctx context.Context, app *v1beta1.Application, oldApp *v1beta1.Application) (*DiffEntry, error)

DiffApps does three phases, dry-run on input app, preparing manifest for diff, and calculating diff on manifests. TODO(wonderflow): vela live-diff don't diff for policies now.

func (*LiveDiffOption) RenderlessDiff

func (l *LiveDiffOption) RenderlessDiff(ctx context.Context, base, comparor LiveDiffObject) (*DiffEntry, error)

RenderlessDiff will not compare the rendered component results but only compare the application spec and original external dependency objects such as external workflow/policies

type ManifestKind

type ManifestKind string

ManifestKind enums the kind of OAM objects

const (
	AppKind           ManifestKind = "Application"
	AppConfigCompKind ManifestKind = "AppConfigComponent"
	RawCompKind       ManifestKind = "Component"
	TraitKind         ManifestKind = "Trait"
	PolicyKind        ManifestKind = "Policy"
	WorkflowKind      ManifestKind = "Workflow"
	ReferredObject    ManifestKind = "ReferredObject"
)

enum kinds of manifest objects

type Option

type Option struct {
	Client          client.Client
	PackageDiscover *packages.PackageDiscover
	Parser          *appfile.Parser
	GenerateAppFile GenerateAppFileFunc

	// Auxiliaries are capability definitions used to parse application.
	// DryRun will use capabilities in Auxiliaries as higher priority than
	// getting one from cluster.
	Auxiliaries []*unstructured.Unstructured
	// contains filtered or unexported fields
}

Option contains options to execute dry-run

func NewDryRunOption

func NewDryRunOption(c client.Client, cfg *rest.Config, pd *packages.PackageDiscover, as []*unstructured.Unstructured, serverSideDryRun bool) *Option

NewDryRunOption creates a dry-run option

func (*Option) ExecuteDryRun

func (d *Option) ExecuteDryRun(ctx context.Context, application *v1beta1.Application) ([]*types.ComponentManifest, []*unstructured.Unstructured, error)

ExecuteDryRun simulates applying an application into cluster and returns rendered resources but not persist them into cluster.

func (*Option) ExecuteDryRunWithPolicies added in v1.7.0

func (d *Option) ExecuteDryRunWithPolicies(ctx context.Context, application *v1beta1.Application, buff *bytes.Buffer) error

ExecuteDryRunWithPolicies is similar to ExecuteDryRun func, but considers deploy workflow step and topology+override policies

func (*Option) PrintDryRun added in v1.5.0

func (d *Option) PrintDryRun(buff *bytes.Buffer, appName string, comps []*types.ComponentManifest, policies []*unstructured.Unstructured) error

PrintDryRun will print the result of dry-run

func (*Option) ValidateApp

func (d *Option) ValidateApp(ctx context.Context, filename string) error

ValidateApp will validate app with client schema check and server side dry-run

type ReportDiffOption

type ReportDiffOption struct {
	DiffMsgs map[DiffType]string
	Context  int
	To       io.Writer
}

ReportDiffOption contains options to formats and prints diff report

func NewReportDiffOption

func NewReportDiffOption(ctx int, to io.Writer) *ReportDiffOption

NewReportDiffOption creats a new ReportDiffOption that can formats and prints diff report into an io.Writer

func (*ReportDiffOption) PrintDiffReport

func (r *ReportDiffOption) PrintDiffReport(diff *DiffEntry)

PrintDiffReport formats and prints diff data into target io.Writer

Jump to

Keyboard shortcuts

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