Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultRetriable(info *resource.Info, err error) error
- func FindAllCanonicalResources(d discovery.DiscoveryInterface, m meta.RESTMapper) ([]schema.GroupResource, error)
- func NewCommandMigrate(name, fullName string, f cmdutil.Factory, out, errOut io.Writer, ...) *cobra.Command
- type Builder
- type ErrNotRetriable
- type ErrRetriable
- type MigrateActionFunc
- type MigrateError
- type MigrateFilterFunc
- type MigrateVisitFunc
- type Reporter
- type ReporterBool
- type ResourceOptions
- type ResourceVisitor
- type TemporaryError
Constants ¶
const MigrateRecommendedName = "migrate"
Variables ¶
var ErrRecalculate = fmt.Errorf("recalculate migration")
ErrRecalculate may be returned by MigrateActionFunc to indicate that the object has changed and needs to have its information recalculated prior to being saved. Use when a resource requires multiple API operations to persist (for instance, both status and spec must be changed).
var ErrUnchanged = fmt.Errorf("migration was not necessary")
ErrUnchanged may be returned by MigrateActionFunc to indicate that the object did not need migration (but that could only be determined when the action was taken).
Functions ¶
func DefaultRetriable ¶
DefaultRetriable adds retry information to the provided error, and will refresh the info if the client info is stale. If the refresh fails the error is made fatal. All other errors are left in their natural state - they will not be retried unless they define a Temporary() method that returns true.
func FindAllCanonicalResources ¶
func FindAllCanonicalResources(d discovery.DiscoveryInterface, m meta.RESTMapper) ([]schema.GroupResource, error)
FindAllCanonicalResources returns all resource names that map directly to their kind (Kind -> Resource -> Kind) and are not subresources. This is the closest mapping possible from the client side to resources that can be listed and updated. Note that this may return some virtual resources (like imagestreamtags) that can be otherwise represented. TODO: add a field to APIResources for "virtual" (or that points to the canonical resource). TODO: fallback to the scheme when discovery is not possible.
Types ¶
type Builder ¶
type Builder interface { // Visitor returns a resource.Visitor that ignores errors that match the given resource.ErrMatchFuncs Visitor(fns ...resource.ErrMatchFunc) (resource.Visitor, error) }
Builder allows for mocking of resource.Builder
type ErrNotRetriable ¶
type ErrNotRetriable struct {
MigrateError
}
ErrNotRetriable is a wrapper for an error that a migrator may use to indicate the specific error cannot be retried.
func (ErrNotRetriable) Temporary ¶
func (ErrNotRetriable) Temporary() bool
type ErrRetriable ¶
type ErrRetriable struct {
MigrateError
}
ErrRetriable is a wrapper for an error that a migrator may use to indicate the specific error can be retried.
func (ErrRetriable) Temporary ¶
func (ErrRetriable) Temporary() bool
type MigrateActionFunc ¶
MigrateActionFunc is expected to persist the altered info.Object. The Reporter returned from Visit is passed to this function and may be used to carry additional information about what to save on an object.
type MigrateError ¶
type MigrateError error
MigrateError is an exported alias to error to allow external packages to use ErrRetriable and ErrNotRetriable
type MigrateFilterFunc ¶
MigrateFilterFunc can return false to skip an item, or an error.
type MigrateVisitFunc ¶
MigrateVisitFunc is invoked for each returned object, and may return a Reporter that can contain info to be used by save.
type Reporter ¶
type Reporter interface { // Changed returns true if the resource requires migration. Changed() bool }
Reporter indicates whether a resource requires migration.
type ReporterBool ¶
type ReporterBool bool
ReporterBool implements the Reporter interface for a boolean.
func (ReporterBool) Changed ¶
func (r ReporterBool) Changed() bool
type ResourceOptions ¶
type ResourceOptions struct {
// To prevent any issues with multiple workers trying
// to read from this, the field was simply removed
// In io.Reader
Out, ErrOut io.Writer
Unstructured bool
AllNamespaces bool
Include []string
Filenames []string
Confirm bool
Output string
FromKey string
ToKey string
OverlappingResources []sets.String
DefaultExcludes []schema.GroupResource
Builder *resource.Builder
SaveFn MigrateActionFunc
PrintFn MigrateActionFunc
FilterFn MigrateFilterFunc
DryRun bool
Summarize bool
// Number of parallel workers to use.
// Any migrate command that sets this must make sure that
// its SaveFn, PrintFn and FilterFn are goroutine safe.
// If multiple workers may attempt to write to Out or ErrOut
// at the same time, SyncOut must also be set to true.
// This should not be exposed as a CLI flag. Instead it
// should have a fixed value that is high enough to saturate
// the desired bandwidth when parallel processing is desired.
Workers int
// If true, Out and ErrOut will be wrapped to make them goroutine safe.
SyncOut bool
}
ResourceOptions assists in performing migrations on any object that can be retrieved via the API.
func (*ResourceOptions) Bind ¶
func (o *ResourceOptions) Bind(c *cobra.Command)
func (*ResourceOptions) Validate ¶
func (o *ResourceOptions) Validate() error
func (*ResourceOptions) Visitor ¶
func (o *ResourceOptions) Visitor() *ResourceVisitor
type ResourceVisitor ¶
type ResourceVisitor struct { Out io.Writer Builder Builder SaveFn MigrateActionFunc PrintFn MigrateActionFunc FilterFn MigrateFilterFunc DryRun bool Workers int }
func (*ResourceVisitor) Visit ¶
func (o *ResourceVisitor) Visit(fn MigrateVisitFunc) error
type TemporaryError ¶
type TemporaryError interface { error // Temporary should return true if this is a temporary error Temporary() bool }
TemporaryError is a wrapper interface that is used to determine if an error can be retried.