importresources

package
v0.0.0-...-64c179a Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Imported resourceImportReportStatus = "Imported"
	Skipped  resourceImportReportStatus = "Skipped"
	Failed   resourceImportReportStatus = "Failed"
)

Variables

This section is empty.

Functions

func FindChildResourcesForResourceType

func FindChildResourcesForResourceType(resourceType string) []string

func FindGroupKindForResourceType

func FindGroupKindForResourceType(t string) (schema.GroupKind, bool)

func FindResourceTypesByScope

func FindResourceTypesByScope(scope genruntime.ResourceScope) []string

FindResourceTypesByScope returns the resource types that may be parented in the given scope

func IsExtensionType

func IsExtensionType(typeName string) bool

IsExtensionType returns true if the given type name is an extension type

func IsResourceGroupType

func IsResourceGroupType(rsrcType string) bool

Types

type ImportError

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

func MakeImportError

func MakeImportError(err error, gk schema.GroupKind, name string) ImportError

func (*ImportError) Error

func (ie *ImportError) Error() string

func (*ImportError) Unwrap

func (ie *ImportError) Unwrap() error

type ImportResourceResult

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

type ImportableResource

type ImportableResource interface {
	// GroupKind returns the GroupKind of the resource being imported.
	// (empty if the GK can't be determined)
	GroupKind() schema.GroupKind

	// Name is a human-readable identifier for this resource
	Name() string

	// ID is a unique identifier for this resource.
	// The ID of a resource must unique within the import operation; the easiest way to achieve this is
	// to make it globally unique.
	ID() string

	// Import does the actual import, updating the Spec on the wrapped resource.
	// ctx allows for cancellation of the import.
	// log allows information about progress to be reported
	Import(
		ctx context.Context,
		reporter importreporter.Interface,
		factory *importFactory,
		log logr.Logger,
	) (ImportResourceResult, error)
}

ImportableResource is an interface that wraps a Kubernetes resource that can be imported. Different implementations of this interface will be used for different types of resources.

func NewImportableARMResource

func NewImportableARMResource(
	id string,
	owner *genruntime.ResourceReference,
	client *genericarmclient.GenericClient,
) (ImportableResource, error)

NewImportableARMResource creates a new importable ARM resource id is the ARM ID of the resource to import. owner is the resource that owns this resource (if any). client is the client to use to talk to ARM.

type ImportedResource

type ImportedResource interface {
	// GroupKind returns the GroupKind of the resource that was imported
	GroupKind() schema.GroupKind

	// Name is a human-readable identifier for this resource
	Name() string

	// ID is a unique identifier for this resource.
	// The ID of a resource must unique within the import operation; the easiest way to achieve this is
	// to make it globally unique.
	ID() string

	// Resource returns the actual resource that has been imported.
	Resource() genruntime.MetaObject
}

ImportedResource is an interface that wraps a Kubernetes resource that has been imported.

type ResourceImporter

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

ResourceImporter is the entry point for importing resources. Factory methods here provide ways to instantiate importers for different kinds of resources.

func New

New creates a new factory with the scheme baked in

func (*ResourceImporter) Add

func (ri *ResourceImporter) Add(importer ImportableResource)

Add adds an importer to the list of resources to import.

func (*ResourceImporter) AddARMID

func (ri *ResourceImporter) AddARMID(armID string) error

AddARMID adds an ARM ID to the list of resources to import.

func (*ResourceImporter) Import

func (ri *ResourceImporter) Import(
	ctx context.Context,
	done chan struct{},
) (*Result, error)

Import imports all the resources that have been added to the importer. Partial results are returned even in the case of an error.

type ResourceImporterOptions

type ResourceImporterOptions struct {
	// Workers is the number of concurrent imports to run at the same time. If not specified, a default of 4 is used.
	Workers int
}

ResourceImporterOptions are optional configuration items for the importer

type Result

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

Result represents the result of an import operation

func (*Result) AddAnnotations

func (r *Result) AddAnnotations(toAdd []string) error

AddAnnotations adds the given annotations to all the resources

func (*Result) AddLabels

func (r *Result) AddLabels(toAdd []string) error

AddLabels adds the given labels to all the resources

func (*Result) Count

func (r *Result) Count() int

Count returns the number of successfully imported resources.

func (*Result) SaveToIndividualFilesInFolder

func (r *Result) SaveToIndividualFilesInFolder(folder string) error

func (*Result) SaveToSingleFile

func (r *Result) SaveToSingleFile(filepath string) error

func (*Result) SaveToWriter

func (r *Result) SaveToWriter(destination io.Writer) error

func (*Result) SetNamespace

func (r *Result) SetNamespace(namespace string)

SetNamespace sets the namespace for all the resources

type SkippedError

type SkippedError struct {
	GroupKind schema.GroupKind
	Name      string
	Because   string
	Resource  ImportableResource
}

SkippedError is an error that indicates that a resource cannot be imported for a reason we know about. This allows us to continue the import even if some expected errors occur.

func NewSkippedError

func NewSkippedError(
	groupKind schema.GroupKind,
	name string,
	because string,
	resource ImportableResource,
) *SkippedError

func (SkippedError) Error

func (e SkippedError) Error() string

Jump to

Keyboard shortcuts

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