Documentation ¶
Index ¶
- Variables
- func AreEqualShapes(a, b *awssdkmodel.Shape, allowMemberNamesInequality bool) (bool, error)
- func ComputeRenamesDelta(srcRenames, dstRenames map[string]string) (map[string]string, error)
- type APIVersionManager
- func (m *APIVersionManager) CompareAPIVersions(srcAPIVersion, dstAPIVersion string) (map[string]*CRDDelta, error)
- func (m *APIVersionManager) CompareHubWith(apiVersion string) (map[string]*CRDDelta, error)
- func (m *APIVersionManager) GetHubVersion() string
- func (m *APIVersionManager) GetModel(apiVersion string) (*ackmodel.Model, error)
- func (m *APIVersionManager) GetSpokeVersions() []string
- func (m *APIVersionManager) VerifyAPIVersions(apiVersions ...string) error
- type CRDDelta
- type FieldChangeType
- type FieldDelta
Constants ¶
This section is empty.
Variables ¶
var ( ErrAPIVersionNotFound = errors.New("api version not found") ErrAPIVersionRemoved = errors.New("api version removed") ErrAPIVersionDeprecated = errors.New("api version deprecated") )
var ( // ErrProhibitedRename is returned by ComputeRenamesDelta when a prohibited renaming // pattern is detected. // // One example of prohibited renaming is: renaming X to Y in v1 and Z to Y in v2. ErrProhibitedRename = errors.New("prohibited rename") )
Functions ¶
func AreEqualShapes ¶
func AreEqualShapes(a, b *awssdkmodel.Shape, allowMemberNamesInequality bool) (bool, error)
AreEqualShapes returns whether two awssdkmodel.ShapeRef are equal or not. When the two given shapes are not equal, it will return an error representing the first type mismatch detected.
func ComputeRenamesDelta ¶
ComputeRenamesDelta returns a map representing the field renames map between two distinguished api versions.
Examples:
if we rename X to Y in v1 and X to Y in v2 the map of renames is {} if we rename X to Y in v1 and X to Z in v2 the map of renames is {Y: Z} if we don't rename any field in v1 and we rename X to Y in v2 the map of renames if {X: Y}
Types ¶
type APIVersionManager ¶
type APIVersionManager struct {
// contains filtered or unexported fields
}
APIVersionManager is a API versions manager. It contains the mapping of each non-deprecated version with their corresponding ackmodel.Model and APIInfos.
func NewAPIVersionManager ¶
func NewAPIVersionManager( sdkCacheDir string, metadataPath string, servicePackageName string, hubVersion string, apisInfo map[string]ackmetadata.APIInfo, defaultConfig ackgenconfig.Config, ) (*APIVersionManager, error)
NewAPIVersionManager initialises and returns a new APIVersionManager.
func (*APIVersionManager) CompareAPIVersions ¶
func (m *APIVersionManager) CompareAPIVersions(srcAPIVersion, dstAPIVersion string) ( map[string]*CRDDelta, error, )
CompareAPIVersions compares two api versions and returns a slice of FieldDeltas representing the diff between CRDs status and spec fields.
func (*APIVersionManager) CompareHubWith ¶
func (m *APIVersionManager) CompareHubWith(apiVersion string) (map[string]*CRDDelta, error)
CompareHubWith compares a given api version with the hub version and returns a string to *CRDDelta map.
func (*APIVersionManager) GetHubVersion ¶
func (m *APIVersionManager) GetHubVersion() string
GetHubVersion returns the hub version.
func (*APIVersionManager) GetModel ¶
func (m *APIVersionManager) GetModel(apiVersion string) (*ackmodel.Model, error)
GetModel returns the model of a given api version.
func (*APIVersionManager) GetSpokeVersions ¶
func (m *APIVersionManager) GetSpokeVersions() []string
GetSpokeVersions returns the spokes versions list.
func (*APIVersionManager) VerifyAPIVersions ¶
func (m *APIVersionManager) VerifyAPIVersions(apiVersions ...string) error
VerifyAPIVersions verifies that an API version exists and is not deprecated.
type CRDDelta ¶
type CRDDelta struct { SpecDeltas []FieldDelta StatusDeltas []FieldDelta }
CRDDelta stores the spec and status deltas for a custom resource.
func ComputeCRDFieldDeltas ¶
ComputeCRDFieldDeltas compares two ackmodel.CRD instances and returns the spec and status fields deltas. src is the CRD of the spoke (source) version and dst is the CRD of the hub (destination) version.
type FieldChangeType ¶
type FieldChangeType string
FieldChangeType represents the type of field modification.
- FieldChangeTypeUnknown is used when ChangeType cannot be computed.
- FieldChangeTypeNone is used when a field name and structure didn't change.
- FieldChangeTypeAdded is used when a new field is introduced in a CRD.
- FieldChangeTypeRemoved is used a when a field is removed from a CRD.
- FieldChangeTypeRenamed is used when a field is renamed.
- FieldChangeTypeShapeChanged is used when a field shape has changed.
- FieldChangeTypeShapeChangedFromStringToSecret is used when a field change to a k8s secret type.
- FieldChangeTypeShapeChangedFromSecretToString is used when a field changed from a k8s secret to a Go string.
const ( FieldChangeTypeUnknown FieldChangeType = "unknown" FieldChangeTypeNone FieldChangeType = "none" FieldChangeTypeAdded FieldChangeType = "added" FieldChangeTypeRemoved FieldChangeType = "removed" FieldChangeTypeRenamed FieldChangeType = "renamed" FieldChangeTypeShapeChanged FieldChangeType = "shape-changed" FieldChangeTypeShapeChangedFromStringToSecret FieldChangeType = "shape-changed-from-string-to-secret" FieldChangeTypeShapeChangedFromSecretToString FieldChangeType = "shape-changed-from-secret-to-string" )
type FieldDelta ¶
type FieldDelta struct { ChangeType FieldChangeType // Field from the destination CRD Destination *ackmodel.Field // Field from the source CRD Source *ackmodel.Field }
FieldDelta represents the delta between the same original field in two different CRD versions. If a field is removed in the Destination version the Destination value will be nil. If a field is new in the Destination version, the Source value will be nil.
func ComputeFieldDeltas ¶
func ComputeFieldDeltas( srcFields map[string]*ackmodel.Field, dstFields map[string]*ackmodel.Field, renames map[string]string, ) ([]FieldDelta, error)
ComputeFieldDeltas computes the difference between two maps of fields. It returns a list of FieldDelta's that contains the ChangeType and at least one field reference.