types

package
v0.4.15 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultFileNameTemplate default file name template
	DefaultFileNameTemplate = `{{default "_cluster_" .Namespace}}/{{if .Group}}{{printf "%s." .Group }}{{end}}{{.Kind}}.{{.Name}}.{{.Extension}}`
	// DefaultListFileNameTemplate default list file name template
	DefaultListFileNameTemplate = `{{default "_cluster_" .Namespace}}/{{if .Group}}{{printf "%s." .Group }}{{end}}{{.Kind}}.{{.Extension}}`
	// DefaultFormat default output format
	DefaultFormat = "yaml"
	// DefaultTarget default export target dir
	DefaultTarget = "exports"

	// ProgressBar progress bar mode
	ProgressBar = Progress("bar")
	// ProgressSimple simple progress mode
	ProgressSimple = Progress("simple")
	// ProgressNone no progress
	ProgressNone = Progress("none")

	// DefaultMaskReplacement Default Mask Replacement
	DefaultMaskReplacement = "*****"
)

Variables

View Source
var (

	// DefaultExcludedFields the default field to be excluded
	DefaultExcludedFields = [][]string{
		{"status"},
		{"metadata", "uid"},
		{"metadata", "selfLink"},
		{"metadata", "resourceVersion"},
		{"metadata", "creationTimestamp"},
		{"metadata", "generation"},
		{"metadata", "annotations", "kubectl.kubernetes.io/last-applied-configuration"},
	}
)

Functions

func Sort added in v0.0.2

func Sort(resources []*GroupResource) func(int, int) bool

Sort GroupResource

func UpdateFrom added in v0.4.1

func UpdateFrom(config *Config, path string) error

UpdateFrom the config from the file with given path

Types

type Config

type Config struct {
	Excluded             Excluded   `json:"excluded" yaml:"excluded"`
	Included             Included   `json:"included" yaml:"included"`
	Masked               *Masked    `json:"masked" yaml:"masked"`
	SortSlices           KindFields `json:"sortSlices" yaml:"sortSlices"`
	FileNameTemplate     string     `json:"fileNameTemplate" yaml:"fileNameTemplate"`
	ListFileNameTemplate string     `json:"listFileNameTemplate" yaml:"listFileNameTemplate"`
	AsLists              bool       `json:"asLists" yaml:"asLists"`
	QueryPageSize        int        `json:"queryPageSize" yaml:"queryPageSize"`
	Target               string     `json:"target" yaml:"target"`
	ClearTarget          bool       `json:"clearTarget" yaml:"clearTarget"`
	Summary              bool       `json:"summary" yaml:"summary"`
	Progress             Progress   `json:"progress" yaml:"progress"`
	Namespace            string     `json:"namespace" yaml:"namespace"`
	Worker               int        `json:"worker" yaml:"worker"`
	Archive              bool       `json:"archive" yaml:"archive"`
	ArchiveRetentionDays int        `json:"archiveRetentionDays" yaml:"archiveRetentionDays"`
	ArchiveTarget        string     `json:"archiveTarget" yaml:"archiveTarget"`
	Quiet                bool       `json:"quiet" yaml:"quiet"`
	Verbose              bool       `json:"verbose" yaml:"verbose"`
	// contains filtered or unexported fields
}

Config export config

func NewConfig added in v0.2.0

func NewConfig(configFlags *genericclioptions.ConfigFlags, printFlags *genericclioptions.PrintFlags) *Config

NewConfig create a new config

func (*Config) FileName

func (c *Config) FileName(res *GroupResource, us *unstructured.Unstructured, index int) (string, error)

FileName generate export file name

func (*Config) FilterFields added in v0.1.0

func (c *Config) FilterFields(res *GroupResource, us unstructured.Unstructured)

FilterFields filter fields for a given resource

func (*Config) IsExcluded

func (c *Config) IsExcluded(gr *GroupResource) bool

IsExcluded check if the group resource is excluded

func (*Config) IsInstanceExcluded added in v0.4.0

func (c *Config) IsInstanceExcluded(res *GroupResource, us unstructured.Unstructured) bool

IsInstanceExcluded check if the kind instance is excluded

func (*Config) ListFileName added in v0.1.0

func (c *Config) ListFileName(res *GroupResource, namespace string) (string, error)

ListFileName generate export list file name

func (*Config) Logger added in v0.1.0

func (c *Config) Logger() log.YALI

Logger get the logger

func (*Config) MaskFields added in v0.3.0

func (c *Config) MaskFields(res *GroupResource, us unstructured.Unstructured)

MaskFields mask fields for a given resource

func (*Config) OutputFormat

func (c *Config) OutputFormat() string

OutputFormat get the current output format

func (*Config) PrintObj added in v0.2.0

func (c *Config) PrintObj(ro runtime.Object, out io.Writer) error

PrintObj print the given object

func (*Config) RestConfig added in v0.2.0

func (c *Config) RestConfig() (*rest.Config, error)

RestConfig get the current rest config

func (*Config) SortSliceFields added in v0.4.0

func (c *Config) SortSliceFields(res *GroupResource, us unstructured.Unstructured)

SortSliceFields sort fields for a given resource

func (*Config) Validate

func (c *Config) Validate() error

Validate validate the config

type Excluded

type Excluded struct {
	Kinds        []string                `json:"kinds" yaml:"kinds"`
	Fields       [][]string              `json:"fields" yaml:"fields"`
	KindFields   KindFields              `json:"kindFields" yaml:"kindFields"`
	KindsByField map[string][]FieldValue `json:"kindByField" yaml:"kindByField"`
}

Excluded exclusion params

type FieldValue added in v0.4.0

type FieldValue struct {
	Field  []string `json:"field" yaml:"field"`
	Values []string `json:"values" yaml:"values"   `
}

FieldValue field with value

type GroupResource

type GroupResource struct {
	APIGroup          string
	APIGroupVersion   string
	APIResource       metav1.APIResource
	APIVersion        string
	Instances         int
	ExportedInstances int
	Pages             int
	Error             string
	QueryDuration     time.Duration
	ExportDuration    time.Duration
}

GroupResource group resource information

func (GroupResource) GroupKind

func (r GroupResource) GroupKind() string

GroupKind get concatenated group and kind

func (GroupResource) Kind added in v0.1.0

func (r GroupResource) Kind() string

Kind get the kind

func (GroupResource) Report

func (r GroupResource) Report(withError bool, withPages bool) []string

Report generate report rows

type Included added in v0.1.0

type Included struct {
	Kinds []string `json:"kinds" yaml:"kinds"`
}

Included inclusion params

type KindFields added in v0.4.0

type KindFields map[string][][]string

KindFields map kinds to fields

type Masked added in v0.3.0

type Masked struct {
	Replacement string `json:"replacement" yaml:"replacement"`
	Checksum    string `json:"checksum" yaml:"checksum"`

	KindFields KindFields `json:"kindFields" yaml:"kindFields"`
	// contains filtered or unexported fields
}

Masked masking params

func (*Masked) Setup added in v0.4.7

func (m *Masked) Setup() error

type Progress added in v0.2.3

type Progress string

Progress type

Jump to

Keyboard shortcuts

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