kubernetes: k8s.io/kubernetes/pkg/kubectl/apply Index | Files | Directories

package apply

import "k8s.io/kubernetes/pkg/kubectl/apply"

Index

Package Files

doc.go element.go empty_element.go error.go list_element.go map_element.go primitive_element.go type_element.go visitor.go

Constants

const (
    // MergeStrategy is the strategy to merge the local and remote values
    MergeStrategy = "merge"

    // RetainKeysStrategy is the strategy to merge the local and remote values, but drop any fields not defined locally
    RetainKeysStrategy = "retainKeys"

    // ReplaceStrategy is the strategy to replace the remote value with the local value
    ReplaceStrategy = "replace"
)

func IsAdd Uses

func IsAdd(e Element) bool

IsAdd returns true if the field represented by e should have the local value directly added to the merged object instead of merging the recorded, local and remote values

func IsDrop Uses

func IsDrop(e Element) bool

IsDrop returns true if the field represented by e should be dropped from the merged object

type CombinedMapSlice Uses

type CombinedMapSlice struct {
    Items []*ListItem
}

CombinedMapSlice is a slice of maps or types with merge keys

func (*CombinedMapSlice) UpsertLocal Uses

func (s *CombinedMapSlice) UpsertLocal(key MergeKeys, l interface{}) error

UpsertLocal adds l to the slice. If there is already a value of l sharing l's merge key in the slice for either the recorded or remote, set l the local value Otherwise append a new item to the list with the local value.

func (*CombinedMapSlice) UpsertRecorded Uses

func (s *CombinedMapSlice) UpsertRecorded(key MergeKeys, l interface{}) error

UpsertRecorded adds l to the slice. If there is already a value of l sharing l's merge key in the slice for either the local or remote, set l the recorded value Otherwise append a new item to the list with the recorded value.

func (*CombinedMapSlice) UpsertRemote Uses

func (s *CombinedMapSlice) UpsertRemote(key MergeKeys, l interface{}) error

UpsertRemote adds l to the slice. If there is already a value of l sharing l's merge key in the slice for either the recorded or local, set l the remote value Otherwise append a new item to the list with the remote value.

type CombinedPrimitiveSlice Uses

type CombinedPrimitiveSlice struct {
    Items []*PrimitiveListItem
}

CombinedPrimitiveSlice implements a slice of primitives

func (*CombinedPrimitiveSlice) UpsertLocal Uses

func (s *CombinedPrimitiveSlice) UpsertLocal(l interface{})

UpsertLocal adds l to the slice. If there is already a value of l in the slice for either the recorded or remote, set on that value as the local value Otherwise append a new item to the list with the local value.

func (*CombinedPrimitiveSlice) UpsertRecorded Uses

func (s *CombinedPrimitiveSlice) UpsertRecorded(l interface{})

UpsertRecorded adds l to the slice. If there is already a value of l in the slice for either the local or remote, set on that value as the recorded value Otherwise append a new item to the list with the recorded value.

func (*CombinedPrimitiveSlice) UpsertRemote Uses

func (s *CombinedPrimitiveSlice) UpsertRemote(l interface{})

UpsertRemote adds l to the slice. If there is already a value of l in the slice for either the local or recorded, set on that value as the remote value Otherwise append a new item to the list with the remote value.

type ConflictDetector Uses

type ConflictDetector interface {
    HasConflict() error
}

ConflictDetector defines the capability to detect conflict. An element can examine remote/recorded value to detect conflict.

type ConflictError Uses

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

ConflictError represents a conflict error occurred during the merge operation.

func NewConflictError Uses

func NewConflictError(e PrimitiveElement) *ConflictError

NewConflictError returns a ConflictError with detailed conflict information in element

func (*ConflictError) Error Uses

func (c *ConflictError) Error() string

Error implements error

type Element Uses

type Element interface {
    // FieldMeta specifies which merge strategy to use for this element
    FieldMeta

    // Merge merges the recorded, local and remote values in the element using the Strategy
    // provided as an argument.  Calls the type specific method on the Strategy - following the
    // "Accept" method from the "Visitor" pattern.
    // e.g. Merge on a ListElement will call Strategy.MergeList(self)
    // Returns the Result of the merged elements
    Merge(Strategy) (Result, error)

    // HasRecorded returns true if the field was explicitly
    // present in the recorded source.  This is to differentiate between
    // undefined and set to null
    HasRecorded() bool

    // GetRecorded returns the field value from the recorded source of the object
    GetRecorded() interface{}

    // HasLocal returns true if the field was explicitly
    // present in the local source.  This is to differentiate between
    // undefined and set to null
    HasLocal() bool

    // GetLocal returns the field value from the local source of the object
    GetLocal() interface{}

    // HasRemote returns true if the field was explicitly
    // present in the remote source.  This is to differentiate between
    // undefined and set to null
    HasRemote() bool

    // GetRemote returns the field value from the remote source of the object
    GetRemote() interface{}
}

Element contains the record, local, and remote value for a field in an object and metadata about the field read from openapi. Calling Merge on an element will apply the passed in strategy to Element - e.g. either replacing the whole element with the local copy or merging each of the recorded, local and remote fields of the element.

type EmptyElement Uses

type EmptyElement struct {
    // FieldMetaImpl contains metadata about the field from openapi
    FieldMetaImpl
}

EmptyElement is a placeholder for when no value is set for a field so its type is unknown

func (EmptyElement) GetLocal Uses

func (e EmptyElement) GetLocal() interface{}

GetLocal implements Element.GetLocal

func (EmptyElement) GetRecorded Uses

func (e EmptyElement) GetRecorded() interface{}

GetRecorded implements Element.GetRecorded

func (EmptyElement) GetRemote Uses

func (e EmptyElement) GetRemote() interface{}

GetRemote implements Element.GetRemote

func (EmptyElement) HasLocal Uses

func (e EmptyElement) HasLocal() bool

HasLocal implements Element.HasLocal

func (EmptyElement) HasRecorded Uses

func (e EmptyElement) HasRecorded() bool

HasRecorded implements Element.HasRecorded

func (EmptyElement) HasRemote Uses

func (e EmptyElement) HasRemote() bool

HasRemote implements Element.IsAdd

func (EmptyElement) IsAdd Uses

func (e EmptyElement) IsAdd() bool

IsAdd implements Element.IsAdd

func (EmptyElement) IsDelete Uses

func (e EmptyElement) IsDelete() bool

IsDelete implements Element.IsDelete

func (EmptyElement) Merge Uses

func (e EmptyElement) Merge(v Strategy) (Result, error)

Merge implements Element.Merge

type FieldMeta Uses

type FieldMeta interface {
    // GetFieldMergeType returns the type of merge strategy to use for this field
    // maybe "merge", "replace" or "retainkeys"
    // TODO: There maybe multiple strategies, so this may need to be a slice, map, or struct
    // Address this in a follow up in the PR to introduce retainkeys strategy
    GetFieldMergeType() string

    // GetFieldMergeKeys returns the merge key to use when the MergeType is "merge" and underlying type is a list
    GetFieldMergeKeys() MergeKeys

    // GetFieldType returns the openapi field type - e.g. primitive, array, map, type, reference
    GetFieldType() string
}

FieldMeta defines the strategy used to apply a Patch for an element

type FieldMetaImpl Uses

type FieldMetaImpl struct {
    // MergeType is the type of merge strategy to use for this field
    // maybe "merge", "replace" or "retainkeys"
    MergeType string

    // MergeKeys are the merge keys to use when the MergeType is "merge" and underlying type is a list
    MergeKeys MergeKeys

    // Type is the openapi type of the field - "list", "primitive", "map"
    Type string

    // Name contains name of the field
    Name string
}

FieldMetaImpl implements FieldMeta

func (FieldMetaImpl) GetFieldMergeKeys Uses

func (s FieldMetaImpl) GetFieldMergeKeys() MergeKeys

GetFieldMergeKeys implements FieldMeta.GetFieldMergeKeys

func (FieldMetaImpl) GetFieldMergeType Uses

func (s FieldMetaImpl) GetFieldMergeType() string

GetFieldMergeType implements FieldMeta.GetFieldMergeType

func (FieldMetaImpl) GetFieldType Uses

func (s FieldMetaImpl) GetFieldType() string

GetFieldType implements FieldMeta.GetFieldType

type HasElementData Uses

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

HasElementData contains whether a field was set in the recorded, local and remote sources

func (HasElementData) HasLocal Uses

func (e HasElementData) HasLocal() bool

HasLocal implements Element.HasLocal

func (HasElementData) HasRecorded Uses

func (e HasElementData) HasRecorded() bool

HasRecorded implements Element.HasRecorded

func (HasElementData) HasRemote Uses

func (e HasElementData) HasRemote() bool

HasRemote implements Element.HasRemote

type ListElement Uses

type ListElement struct {
    // FieldMetaImpl contains metadata about the field from openapi
    FieldMetaImpl

    ListElementData

    // Values contains the combined recorded-local-remote value of each item in the list
    // Present for lists that can be merged only.  Contains the items
    // from each of the 3 lists merged into single Elements using
    // the merge-key.
    Values []Element
}

ListElement contains the recorded, local and remote values for a field of type list

func (ListElement) HasConflict Uses

func (e ListElement) HasConflict() error

HasConflict returns ConflictError if fields in recorded and remote of ListElement conflict

func (ListElement) Merge Uses

func (e ListElement) Merge(v Strategy) (Result, error)

Merge implements Element.Merge

type ListElementData Uses

type ListElementData struct {
    RawElementData
}

ListElementData contains the recorded, local and remote data for a list

func (ListElementData) GetLocalList Uses

func (e ListElementData) GetLocalList() []interface{}

GetLocalList returns the Local value as a list

func (ListElementData) GetRecordedList Uses

func (e ListElementData) GetRecordedList() []interface{}

GetRecordedList returns the Recorded value as a list

func (ListElementData) GetRemoteList Uses

func (e ListElementData) GetRemoteList() []interface{}

GetRemoteList returns the Remote value as a list

type ListItem Uses

type ListItem struct {
    // KeyValue is the merge key value of the item
    KeyValue MergeKeyValue

    // RawElementData contains the field values
    RawElementData
}

ListItem represents a single value in a slice of maps or types

type MapElement Uses

type MapElement struct {
    // FieldMetaImpl contains metadata about the field from openapi
    FieldMetaImpl

    // MapElementData contains the value a field was set to
    MapElementData

    // Values contains the combined recorded-local-remote value of each item in the map
    // Values contains the values in mapElement.  Element must contain
    // a Name matching its key in Values
    Values map[string]Element
}

MapElement contains the recorded, local and remote values for a field of type map

func (MapElement) GetValues Uses

func (e MapElement) GetValues() map[string]Element

GetValues implements Element.GetValues

func (MapElement) HasConflict Uses

func (e MapElement) HasConflict() error

HasConflict returns ConflictError if some elements in map conflict.

func (MapElement) Merge Uses

func (e MapElement) Merge(v Strategy) (Result, error)

Merge implements Element.Merge

type MapElementData Uses

type MapElementData struct {
    RawElementData
}

MapElementData contains the recorded, local and remote data for a map or type

func (MapElementData) GetLocalMap Uses

func (e MapElementData) GetLocalMap() map[string]interface{}

GetLocalMap returns the Local value as a map

func (MapElementData) GetRecordedMap Uses

func (e MapElementData) GetRecordedMap() map[string]interface{}

GetRecordedMap returns the Recorded value as a map

func (MapElementData) GetRemoteMap Uses

func (e MapElementData) GetRemoteMap() map[string]interface{}

GetRemoteMap returns the Remote value as a map

type MergeKeyValue Uses

type MergeKeyValue map[string]string

MergeKeyValue records the value of the mergekey for an item in a list

func (MergeKeyValue) Equal Uses

func (v MergeKeyValue) Equal(o MergeKeyValue) bool

Equal returns true if the MergeKeyValues share the same value, representing the same item in a list

type MergeKeys Uses

type MergeKeys []string

MergeKeys is the set of fields on an object that uniquely identify and is used when merging lists to identify the "same" object independent of the ordering of the objects

func (MergeKeys) GetMergeKeyValue Uses

func (mk MergeKeys) GetMergeKeyValue(i interface{}) (MergeKeyValue, error)

GetMergeKeyValue parses the MergeKeyValue from an item in a list

type Operation Uses

type Operation int

Operation records whether a field should be set or dropped

const (
    // ERROR is an error during merge
    ERROR Operation = iota
    // SET sets the field on an object
    SET
    // DROP drops the field from an object
    DROP
)

type PrimitiveElement Uses

type PrimitiveElement struct {
    // FieldMetaImpl contains metadata about the field from openapi
    FieldMetaImpl

    // RawElementData contains the values the field was set to
    RawElementData
}

PrimitiveElement contains the recorded, local and remote values for a field of type primitive

func (PrimitiveElement) HasConflict Uses

func (e PrimitiveElement) HasConflict() error

HasConflict returns ConflictError if primitive element has conflict field. Conflicts happen when either of the following conditions: 1. A field is specified in both recorded and remote values, but does not match. 2. A field is specified in recorded values, but missing in remote values.

func (PrimitiveElement) Merge Uses

func (e PrimitiveElement) Merge(v Strategy) (Result, error)

Merge implements Element.Merge

type PrimitiveListItem Uses

type PrimitiveListItem struct {
    // Value is the value of the primitive, should match recorded, local and remote
    Value interface{}

    RawElementData
}

PrimitiveListItem represents a single value in a slice of primitives

type RawElementData Uses

type RawElementData struct {
    HasElementData
    // contains filtered or unexported fields
}

RawElementData contains the raw recorded, local and remote data and metadata about whethere or not each was set

func NewRawElementData Uses

func NewRawElementData(recorded, local, remote interface{}) RawElementData

NewRawElementData returns a new RawElementData, setting IsSet to true for non-nil values, and leaving IsSet false for nil values. Note: use this only when you want a nil-value to be considered "unspecified" (ignore) and not "unset" (deleted).

func (RawElementData) GetLocal Uses

func (b RawElementData) GetLocal() interface{}

GetLocal implements Element.GetLocal

func (RawElementData) GetRecorded Uses

func (b RawElementData) GetRecorded() interface{}

GetRecorded implements Element.GetRecorded

func (RawElementData) GetRemote Uses

func (b RawElementData) GetRemote() interface{}

GetRemote implements Element.GetRemote

func (*RawElementData) SetLocal Uses

func (b *RawElementData) SetLocal(value interface{})

SetLocal sets the local value

func (*RawElementData) SetRecorded Uses

func (b *RawElementData) SetRecorded(value interface{})

SetRecorded sets the recorded value

func (*RawElementData) SetRemote Uses

func (b *RawElementData) SetRemote(value interface{})

SetRemote sets the remote value

type Result Uses

type Result struct {
    // Operation is the operation that should be performed for the merged field
    Operation Operation
    // MergedResult is the new merged value
    MergedResult interface{}
}

Result is the result of merging fields

type Strategy Uses

type Strategy interface {
    // MergeList is invoked by ListElements when Merge is called
    MergeList(ListElement) (Result, error)

    // MergeMap is invoked by MapElements when Merge is called
    MergeMap(MapElement) (Result, error)

    // MergeType is invoked by TypeElements when Merge is called
    MergeType(TypeElement) (Result, error)

    // MergePrimitive is invoked by PrimitiveElements when Merge is called
    MergePrimitive(PrimitiveElement) (Result, error)

    // MergeEmpty is invoked by EmptyElements when Merge is called
    MergeEmpty(EmptyElement) (Result, error)
}

Strategy implements a strategy for merging recorded, local and remote values contained in an element and returns the merged result. Follows the visitor pattern

type TypeElement Uses

type TypeElement struct {
    // FieldMetaImpl contains metadata about the field from openapi
    FieldMetaImpl

    MapElementData

    // Values contains the combined recorded-local-remote value of each field in the type
    // Values contains the values in mapElement.  Element must contain
    // a Name matching its key in Values
    Values map[string]Element
}

TypeElement contains the recorded, local and remote values for a field that is a complex type

func (TypeElement) GetValues Uses

func (e TypeElement) GetValues() map[string]Element

GetValues implements Element.GetValues

func (TypeElement) HasConflict Uses

func (e TypeElement) HasConflict() error

HasConflict returns ConflictError if some elements in type conflict.

func (TypeElement) Merge Uses

func (e TypeElement) Merge(v Strategy) (Result, error)

Merge implements Element.Merge

Directories

PathSynopsis
parse
strategy

Package apply imports 2 packages (graph) and is imported by 4 packages. Updated 2019-07-08. Refresh now. Tools for package owners.