kubeyamlutils

package module
v0.0.0-...-16fae64 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

README

kubeyamlutils

Processing kube yaml file list of tools

  • parse yaml content,file,directory to client object
  • create/update/sync client object to cluster

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manifests

type Manifests struct {
	// contains filtered or unexported fields
}

func (*Manifests) Apply

func (m *Manifests) Apply(ctx context.Context, c client.Client) error

Apply create/update object to client cluster.

func (*Manifests) Delete

func (m *Manifests) Delete(ctx context.Context, client client.Client) error

func (*Manifests) GetObjects

func (m *Manifests) GetObjects() []client.Object

func (*Manifests) MutateObject

func (m *Manifests) MutateObject(mutateFn func(unstructured2 *unstructured.Unstructured) error) error

func (*Manifests) SetLogger

func (m *Manifests) SetLogger(logger logr.Logger)

func (*Manifests) Sync

func (m *Manifests) Sync(ctx context.Context, c client.Client) error

Sync 将object create/update到目标cluster,如果已经apply过且源和目标均无修改将跳过更新,避免无意义的操作 目标集群中对象Annotation的修改将被忽略.

type ManifestsParser

type ManifestsParser struct {
	// contains filtered or unexported fields
}

func NewManifestsParser

func NewManifestsParser(bytes []byte, opts ...Option) *ManifestsParser

NewManifestsParser reads manifests from a byte array.

func NewManifestsParserFromDirectory

func NewManifestsParserFromDirectory(directory string, opts ...Option) *ManifestsParser

NewManifestsParserFromDirectory reads manifests from a directory. flow kubectl recognized file extensions are [.json .yaml .yml].

func NewManifestsParserFromFile

func NewManifestsParserFromFile(file string, opts ...Option) *ManifestsParser

NewManifestsParserFromFile reads manifests from a file.

func (*ManifestsParser) MustParse

func (p *ManifestsParser) MustParse() *Manifests

func (*ManifestsParser) Parse

func (p *ManifestsParser) Parse() (*Manifests, error)

type Option

type Option func(parse *ManifestsParser)

func ReverseSortObject

func ReverseSortObject(mapper meta.RESTMapper) Option

ReverseSortObject sorts objects in the order of namespace scoped objects, namespaces, cluster scoped objects, CRDs.

func SetNamespace

func SetNamespace(mapper meta.RESTMapper, namespace string) Option

SetNamespace sets namespace for objects.

func SortObject

func SortObject(mapper meta.RESTMapper) Option

SortObject sorts objects in the order of CRDs, cluster scoped objects, namespaces, namespace scoped objects.

func WithLogger

func WithLogger(logger logr.Logger) Option

WithLogger add logger.

Jump to

Keyboard shortcuts

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