types

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2025 License: Apache-2.0 Imports: 32 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")
	// ProgressBarBubbles bubbles progress bar mode.
	ProgressBarBubbles = Progress("bubbles")
	// ProgressSimple simple progress mode.
	ProgressSimple = Progress("simple")
	// ProgressNone no progress.
	ProgressNone = Progress("none")

	// DefaultMaskReplacement Default Mask Replacement.
	DefaultMaskReplacement = "*****"
)
View Source
const (
	EnvAesKey = "KUBEXPORTER_AES_KEY"
)

Variables

View Source
var (

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

Functions

func Decrypt added in v0.5.5

func Decrypt(printFlags *genericclioptions.PrintFlags, aesKey string, files ...string) error

func Encrypt added in v0.7.0

func Encrypt(printFlags *genericclioptions.PrintFlags, aesKey string, files ...string) error

Encrypt encrypts secrets in exported resource files.

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"`
	CreatedWithin           time.Duration `json:"createdWithin"           yaml:"createdWithin"`
	ConsiderOwnerReferences bool          `json:"considerOwnerReferences" yaml:"considerOwnerReferences"`
	Masked                  *Masked       `json:"masked"                  yaml:"masked"`
	Encrypted               *Encrypted    `json:"encrypted"               yaml:"encrypted"`
	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"`
	S3Config                *S3Config     `json:"s3"                      yaml:"s3"`
	GCSConfig               *GCSConfig    `json:"gcs"                     yaml:"gcs"`
	Quiet                   bool          `json:"quiet"                   yaml:"quiet"`
	Verbose                 bool          `json:"verbose"                 yaml:"verbose"`
	PrintSize               bool          `json:"printSize"               yaml:"printSize"`

	PrintFlags *genericclioptions.PrintFlags `json:"-" yaml:"-"`
	// 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) EncryptFields added in v0.5.5

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

EncryptFields encrypts fields for a given resource.

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) MaxArchiveAge added in v0.6.0

func (c *Config) MaxArchiveAge() time.Time

func (*Config) OutputFormat

func (c *Config) OutputFormat() string

OutputFormat get the current output format.

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 Encrypted added in v0.5.5

type Encrypted struct {
	AesKey     string     `json:"aesKey"     yaml:"aesKey"`
	KindFields KindFields `json:"kindFields" yaml:"kindFields"`
	// contains filtered or unexported fields
}

func (*Encrypted) Setup added in v0.5.5

func (e *Encrypted) Setup() (err error)

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"`
	PreservedFields PreservedFields         `json:"preservedFields" yaml:"preservedFields"`
}

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 GCSConfig added in v0.8.0

type GCSConfig struct {
	Bucket string `json:"bucket" yaml:"bucket"`
}

type GroupResource

type GroupResource struct {
	APIGroup          string
	APIGroupVersion   string
	APIResource       metav1.APIResource
	APIVersion        string
	Instances         int
	ExportedInstances int
	Pages             int
	ExportedSize      int64
	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(withSize, withError, withPages bool) []string

Report generates 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.

func (KindFields) Diff added in v0.5.5

func (f KindFields) Diff(other KindFields) KindFields

Diff returns new KindFields with values that are only in the provided argument and not in this.

func (KindFields) String added in v0.5.5

func (f KindFields) String() string

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 PreservedFields added in v0.7.0

type PreservedFields struct {
	Fields [][]string `json:"fields" yaml:"fields"` // Global preserved fields
}

PreservedFields defines fields that should be preserved when their parent field is excluded.

type Progress added in v0.2.3

type Progress string

Progress type.

type S3Config added in v0.6.0

type S3Config struct {
	Endpoint        string `json:"endpoint"        yaml:"endpoint"`
	AccessKeyID     string `json:"accessKeyID"     yaml:"accessKeyID"`
	SecretAccessKey string `json:"secretAccessKey" yaml:"secretAccessKey"`
	Token           string `json:"token"           yaml:"token"`
	Secure          bool   `json:"secure"          yaml:"secure"`
	Bucket          string `json:"bucket"          yaml:"bucket"`
}

Jump to

Keyboard shortcuts

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