Documentation ¶
Overview ¶
Package model implements a model for representing event taxonomies. +k8s:openapi-gen=true +k8s:deepcopy-gen=package +k8s:defaulter-gen=TypeMeta
Index ¶
- Constants
- func IsArrayType(t Type) bool
- func IsEnumType(t Type) bool
- func IsNullableType(t Type) bool
- func IsSafeTypeChange(fromStr string, toStr string) bool
- type AppIDUpdate
- type ArrayType
- type BoolType
- type DateTimeType
- type DateType
- type EnumFieldUpdate
- type EnumType
- type EnumUpdate
- type EnumValueSorter
- type EventEnum
- func (e *EventEnum) BuildIndex()
- func (in *EventEnum) DeepCopy() *EventEnum
- func (in *EventEnum) DeepCopyInto(out *EventEnum)
- func (e *EventEnum) FieldNames() []string
- func (e *EventEnum) FieldsAddedIn(new *EventEnum) []string
- func (e *EventEnum) FieldsPreservedIn(new *EventEnum) []string
- func (e *EventEnum) FieldsRemovedIn(new *EventEnum) []string
- func (e *EventEnum) GetField(name string) *EventEnumField
- func (e *EventEnum) GetFieldByValue(value int) *EventEnumField
- func (e *EventEnum) MaxValue() int
- func (e *EventEnum) NextValue() int
- func (e *EventEnum) OK() error
- func (e *EventEnum) SameAs(other *EventEnum) bool
- type EventEnumField
- type EventProperty
- func (in *EventProperty) DeepCopy() *EventProperty
- func (in *EventProperty) DeepCopyInto(out *EventProperty)
- func (f *EventProperty) EndLife()
- func (p *EventProperty) GetLifecycles(v interface{}, taxonomy *EventTaxonomy) []Lifecycle
- func (p *EventProperty) IsAssignableFrom(v interface{}, taxonomy *EventTaxonomy) bool
- func (p *EventProperty) OK() error
- func (f *EventProperty) Revive()
- func (p *EventProperty) SameAs(other *EventProperty) bool
- type EventTaxonomy
- func (t *EventTaxonomy) BlacklistPropertiesFilterNames() []string
- func (t *EventTaxonomy) BuildIndex()
- func (in *EventTaxonomy) DeepCopy() *EventTaxonomy
- func (in *EventTaxonomy) DeepCopyInto(out *EventTaxonomy)
- func (t *EventTaxonomy) EnumNames() []string
- func (t *EventTaxonomy) EnumsAddedIn(newModel *EventTaxonomy) []string
- func (t *EventTaxonomy) EnumsPreservedIn(newModel *EventTaxonomy) []string
- func (t *EventTaxonomy) EnumsRemovedIn(newModel *EventTaxonomy) []string
- func (t *EventTaxonomy) GetEnum(name string) *EventEnum
- func (t *EventTaxonomy) GetProperty(name string) *EventProperty
- func (t *EventTaxonomy) OK() error
- func (t *EventTaxonomy) PropertiesAddedIn(newModel *EventTaxonomy) []string
- func (t *EventTaxonomy) PropertiesPreservedIn(newModel *EventTaxonomy) []string
- func (t *EventTaxonomy) PropertiesRemovedIn(newModel *EventTaxonomy) []string
- func (t *EventTaxonomy) PropertyNames() []string
- func (t *EventTaxonomy) RemoveEnum(name string)
- func (t *EventTaxonomy) ValidateTwin(twin EventTaxonomy) (issues []error)
- type FixedStringType
- type FloatType
- type IntType
- type Lifecycle
- type LifecycleUpdate
- type NullableType
- type PropertyScope
- type PropertyUpdate
- type StringType
- type TaxonomyUpdate
- type Type
Constants ¶
const ( // PreProductionLifecycle - unsafe changes are allowed, field/property may be removed PreProductionLifecycle = Lifecycle("PreProduction") // ProductionLifecycle - changes are not allowed ProductionLifecycle = Lifecycle("Production") // ProductionEndOfLifeLifecycle - changes are not allowed, field is scheduled for removal ProductionEndOfLifeLifecycle = Lifecycle("ProductionEndOfLife") // VoidLifecycle - field is waiting to be permanently deleted and forgotten VoidLifecycle = Lifecycle("Void") // VoidLifecycle - field is waiting to be permanently deleted and forgotten EventNameFakeLifecycle = Lifecycle("EventName") )
const ( Int8TypeName = "Int8" Int16TypeName = "Int16" Int32TypeName = "Int32" Int64TypeName = "Int64" Float32TypeName = "Float32" Float64TypeName = "Float64" EnumTypeName = "Enum" DateTypeName = "Date" DateTimeTypeName = "DateTime" StringTypeName = "String" BoolTypeName = "Bool" )
Constants for type names
Variables ¶
This section is empty.
Functions ¶
func IsArrayType ¶ added in v1.1.40
func IsEnumType ¶ added in v1.1.40
func IsNullableType ¶ added in v1.1.40
func IsSafeTypeChange ¶
IsSafeTypeChange returns true if `fromType` can be safely altered to `toType`
Types ¶
type AppIDUpdate ¶
AppIDUpdate represents a changed "appid" for an EventTaxonomy
func (*AppIDUpdate) DeepCopy ¶
func (in *AppIDUpdate) DeepCopy() *AppIDUpdate
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppIDUpdate.
func (*AppIDUpdate) DeepCopyInto ¶
func (in *AppIDUpdate) DeepCopyInto(out *AppIDUpdate)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type ArrayType ¶ added in v1.1.40
type ArrayType struct {
InnerType Type
}
+kubebuilder:object:generate=false
func (ArrayType) ScalarType ¶ added in v1.1.40
type BoolType ¶
type BoolType struct{}
+kubebuilder:object:generate=false
func (BoolType) ScalarType ¶ added in v1.1.40
type DateTimeType ¶
type DateTimeType struct{}
+kubebuilder:object:generate=false
func (DateTimeType) ScalarType ¶ added in v1.1.40
func (t DateTimeType) ScalarType() string
func (DateTimeType) String ¶ added in v1.1.40
func (t DateTimeType) String() string
type DateType ¶
type DateType struct{}
+kubebuilder:object:generate=false
func (DateType) ScalarType ¶ added in v1.1.40
type EnumFieldUpdate ¶
type EnumFieldUpdate struct { From *EventEnumField `json:"from"` To *EventEnumField `json:"to"` }
EnumFieldUpdate describes a changed enum field
func (*EnumFieldUpdate) DeepCopy ¶
func (in *EnumFieldUpdate) DeepCopy() *EnumFieldUpdate
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnumFieldUpdate.
func (*EnumFieldUpdate) DeepCopyInto ¶
func (in *EnumFieldUpdate) DeepCopyInto(out *EnumFieldUpdate)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*EnumFieldUpdate) DetectIssues ¶
func (f *EnumFieldUpdate) DetectIssues(blacklistedProperties []string) (errors []error)
DetectIssues returns an error if the enum field change is not allowed, or `nil` if it is.
type EnumType ¶
type EnumType struct {
EnumName string
}
+kubebuilder:object:generate=false
func (EnumType) ScalarType ¶ added in v1.1.40
type EnumUpdate ¶
type EnumUpdate struct { Name string `json:"name"` AddedFields []*EventEnumField `json:"addedFields,omitempty"` RemovedFields []*EventEnumField `json:"removedFields,omitempty"` UpdatedFields []*EnumFieldUpdate `json:"updatedFields,omitempty"` }
EnumUpdate describes the changes to an enum.
func (*EnumUpdate) DeepCopy ¶
func (in *EnumUpdate) DeepCopy() *EnumUpdate
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnumUpdate.
func (*EnumUpdate) DeepCopyInto ¶
func (in *EnumUpdate) DeepCopyInto(out *EnumUpdate)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*EnumUpdate) DetectIssues ¶
func (e *EnumUpdate) DetectIssues(blacklistedProperties []string) (issues []error)
DetectIssues returns an non-empty slice of errors if the enum change is not allowed (empty if OK).
type EnumValueSorter ¶
type EnumValueSorter []*EventEnumField
func (EnumValueSorter) DeepCopy ¶
func (in EnumValueSorter) DeepCopy() EnumValueSorter
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnumValueSorter.
func (EnumValueSorter) DeepCopyInto ¶
func (in EnumValueSorter) DeepCopyInto(out *EnumValueSorter)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (EnumValueSorter) Len ¶
func (a EnumValueSorter) Len() int
func (EnumValueSorter) Less ¶
func (a EnumValueSorter) Less(i, j int) bool
func (EnumValueSorter) Swap ¶
func (a EnumValueSorter) Swap(i, j int)
type EventEnum ¶
type EventEnum struct { Name string `json:"name"` Fields []*EventEnumField `json:"fields"` FieldMap map[string]*EventEnumField `json:"-"` ValueMap map[int]*EventEnumField `json:"-"` }
EventEnum :
func (*EventEnum) BuildIndex ¶
func (e *EventEnum) BuildIndex()
func (*EventEnum) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EventEnum.
func (*EventEnum) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*EventEnum) FieldNames ¶
FieldNames returns a list of strings with names of all our enum fields
func (*EventEnum) FieldsAddedIn ¶
FieldsAddedIn returns a list of names of enum fields added in `new`
func (*EventEnum) FieldsPreservedIn ¶
FieldsPreservedIn returns a list of names of enum fields that are in both this object and `new`
func (*EventEnum) FieldsRemovedIn ¶
FieldsRemovedIn returns a list of names of enum fields removed in `new`
func (*EventEnum) GetFieldByValue ¶
func (e *EventEnum) GetFieldByValue(value int) *EventEnumField
GetFieldByValue returns the enum field with a given value, or nil if not found
type EventEnumField ¶
type EventEnumField struct { Name string `json:"name"` Value int `json:"value"` Lifecycle Lifecycle `json:"lifecycle"` LastModified metav1.Time `json:"last_modified"` }
EventEnumField represents a single field within an enum
func (*EventEnumField) DeepCopy ¶
func (in *EventEnumField) DeepCopy() *EventEnumField
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EventEnumField.
func (*EventEnumField) DeepCopyInto ¶
func (in *EventEnumField) DeepCopyInto(out *EventEnumField)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*EventEnumField) EndLife ¶ added in v1.1.38
func (f *EventEnumField) EndLife()
func (*EventEnumField) OK ¶
func (f *EventEnumField) OK() error
OK validates this object and returns an error if there is an issue
func (*EventEnumField) Revive ¶ added in v1.1.36
func (f *EventEnumField) Revive()
func (*EventEnumField) SameAs ¶
func (f *EventEnumField) SameAs(other *EventEnumField) bool
type EventProperty ¶
type EventProperty struct { Name string `json:"name"` Scope PropertyScope `json:"scope"` Lifecycle Lifecycle `json:"lifecycle"` LastModified metav1.Time `json:"last_modified"` Type string `json:"type"` }
EventProperty represents a single property (user, event or envelope) in the event taxonomy
func (*EventProperty) DeepCopy ¶
func (in *EventProperty) DeepCopy() *EventProperty
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EventProperty.
func (*EventProperty) DeepCopyInto ¶
func (in *EventProperty) DeepCopyInto(out *EventProperty)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*EventProperty) EndLife ¶ added in v1.1.38
func (f *EventProperty) EndLife()
func (*EventProperty) GetLifecycles ¶
func (p *EventProperty) GetLifecycles(v interface{}, taxonomy *EventTaxonomy) []Lifecycle
GetLifecycles returns Production, PreProduction or nil
func (*EventProperty) IsAssignableFrom ¶
func (p *EventProperty) IsAssignableFrom(v interface{}, taxonomy *EventTaxonomy) bool
IsAssignableFrom tells whether this property's value may be assigned from `v`. The input is assumed to come from json.Unmarshal()-ing into a map[string]interface{}, such that numeric values can be float64 or json.Number.
func (*EventProperty) OK ¶
func (p *EventProperty) OK() error
OK validates this object and returns an error if there is an issue
func (*EventProperty) Revive ¶ added in v1.1.36
func (f *EventProperty) Revive()
func (*EventProperty) SameAs ¶
func (p *EventProperty) SameAs(other *EventProperty) bool
type EventTaxonomy ¶
type EventTaxonomy struct { AppID string `json:"appid"` Enums []*EventEnum `json:"enums,omitempty"` Properties []*EventProperty `json:"properties"` BlacklistPropertiesFilter []string `json:"blacklist_properties_filter,omitempty"` EnumMap map[string]*EventEnum `json:"-"` PropertyMap map[string]*EventProperty `json:"-"` }
EventTaxonomy contains the event taxonomy for a single product.
func LoadTaxonomyFromFile ¶
func LoadTaxonomyFromFile(fileName string) (*EventTaxonomy, error)
LoadTaxonomyFromFile creates an EventTaxonomy object from a JSON file
func (*EventTaxonomy) BlacklistPropertiesFilterNames ¶
func (t *EventTaxonomy) BlacklistPropertiesFilterNames() []string
Blacklist properties names , sorted.
func (*EventTaxonomy) BuildIndex ¶
func (t *EventTaxonomy) BuildIndex()
BuildIndex creates lookup maps for enums, enum fields and properties
func (*EventTaxonomy) DeepCopy ¶
func (in *EventTaxonomy) DeepCopy() *EventTaxonomy
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EventTaxonomy.
func (*EventTaxonomy) DeepCopyInto ¶
func (in *EventTaxonomy) DeepCopyInto(out *EventTaxonomy)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*EventTaxonomy) EnumNames ¶
func (t *EventTaxonomy) EnumNames() []string
EnumNames returns a sorted array of just the enum names from the taxonomy
func (*EventTaxonomy) EnumsAddedIn ¶
func (t *EventTaxonomy) EnumsAddedIn(newModel *EventTaxonomy) []string
EnumsAddedIn returns a list of names of enums added in `newModel`
func (*EventTaxonomy) EnumsPreservedIn ¶
func (t *EventTaxonomy) EnumsPreservedIn(newModel *EventTaxonomy) []string
EnumsPreservedIn returns a list names of enums in both taxonomies
func (*EventTaxonomy) EnumsRemovedIn ¶
func (t *EventTaxonomy) EnumsRemovedIn(newModel *EventTaxonomy) []string
EnumsRemovedIn returns a list of removed event property names
func (*EventTaxonomy) GetProperty ¶
func (t *EventTaxonomy) GetProperty(name string) *EventProperty
GetProperty :
func (*EventTaxonomy) OK ¶
func (t *EventTaxonomy) OK() error
OK validates the object and returns nil if things are a-ok, or an error if not
func (*EventTaxonomy) PropertiesAddedIn ¶
func (t *EventTaxonomy) PropertiesAddedIn(newModel *EventTaxonomy) []string
PropertiesAddedIn returns a list of properties added in `newModel`
func (*EventTaxonomy) PropertiesPreservedIn ¶
func (t *EventTaxonomy) PropertiesPreservedIn(newModel *EventTaxonomy) []string
PropertiesPreservedIn returns a list of properties preserved in `newModel`
func (*EventTaxonomy) PropertiesRemovedIn ¶
func (t *EventTaxonomy) PropertiesRemovedIn(newModel *EventTaxonomy) []string
PropertiesRemovedIn returns a list of properties removed in `newModel`
func (*EventTaxonomy) PropertyNames ¶
func (t *EventTaxonomy) PropertyNames() []string
PropertyNames returns a sorted array of just the property names from the taxonomy
func (*EventTaxonomy) RemoveEnum ¶
func (t *EventTaxonomy) RemoveEnum(name string)
func (*EventTaxonomy) ValidateTwin ¶
func (t *EventTaxonomy) ValidateTwin(twin EventTaxonomy) (issues []error)
type FixedStringType ¶ added in v1.1.40
type FixedStringType struct {
Length int
}
+kubebuilder:object:generate=false
func (FixedStringType) ScalarType ¶ added in v1.1.40
func (t FixedStringType) ScalarType() string
func (FixedStringType) String ¶ added in v1.1.40
func (t FixedStringType) String() string
type FloatType ¶ added in v1.1.40
type FloatType struct {
Bits int
}
+kubebuilder:object:generate=false
func (FloatType) ScalarType ¶ added in v1.1.40
type IntType ¶ added in v1.1.40
type IntType struct {
Bits int
}
+kubebuilder:object:generate=false
func (IntType) ScalarType ¶ added in v1.1.40
type Lifecycle ¶
type Lifecycle string
Lifecycle describes whether a field/property is stable or deprecated
func (*Lifecycle) CanChangeTo ¶
CanChangeTo tells whether this lifecycle state can be changed to another
func (Lifecycle) IsExisting ¶ added in v1.1.36
func (*Lifecycle) UnmarshalJSON ¶
UnmarshalJSON unmashals a JSON string to a Lifecycle value
type LifecycleUpdate ¶
LifecycleUpdate represents a changed "lifecycle" for an EventTaxonomy
func (*LifecycleUpdate) DeepCopy ¶
func (in *LifecycleUpdate) DeepCopy() *LifecycleUpdate
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LifecycleUpdate.
func (*LifecycleUpdate) DeepCopyInto ¶
func (in *LifecycleUpdate) DeepCopyInto(out *LifecycleUpdate)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type NullableType ¶ added in v1.1.40
type NullableType struct {
InnerType Type
}
+kubebuilder:object:generate=false
func (NullableType) IsArray ¶ added in v1.1.40
func (t NullableType) IsArray() bool
func (NullableType) IsNullable ¶ added in v1.1.40
func (t NullableType) IsNullable() bool
func (NullableType) ScalarType ¶ added in v1.1.40
func (t NullableType) ScalarType() string
func (NullableType) String ¶ added in v1.1.40
func (t NullableType) String() string
type PropertyScope ¶
type PropertyScope string
PropertyScope describes whether a property describes something about the event, the user or the event envelope.
const ( // EventScope - property is part of the event EventScope PropertyScope = "Event" // UserScope - property describes the user UserScope PropertyScope = "User" // EnvelopeScope - property describe the event envelope EnvelopeScope PropertyScope = "Envelope" // InternalScope - property is internal, clients are not allowed to define it InternalScope PropertyScope = "Internal" )
func (PropertyScope) IsSacred ¶ added in v1.1.36
func (s PropertyScope) IsSacred() bool
func (*PropertyScope) UnmarshalJSON ¶
func (s *PropertyScope) UnmarshalJSON(b []byte) error
UnmarshalJSON unmashals a quoted json string to a PropertyScope value
type PropertyUpdate ¶
type PropertyUpdate struct { From *EventProperty `json:"from"` To *EventProperty `json:"to"` }
PropertyUpdate :
func (*PropertyUpdate) DeepCopy ¶
func (in *PropertyUpdate) DeepCopy() *PropertyUpdate
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PropertyUpdate.
func (*PropertyUpdate) DeepCopyInto ¶
func (in *PropertyUpdate) DeepCopyInto(out *PropertyUpdate)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*PropertyUpdate) DetectIssues ¶
func (c *PropertyUpdate) DetectIssues(blacklistedProperties []string) (errors []error)
DetectIssues returns an array of errors if these are changes in the property that are not allowed (or an empty array if there are no issues).
The rules are:
- Type: type changes must be "safe", except for "beta" properties
- Scope: "production" properties can not change scope away from "envelope"
- Lifecycle: any change ok, except for "envelope" or "internal" properties
type StringType ¶
type StringType struct{}
+kubebuilder:object:generate=false
func (StringType) ScalarType ¶ added in v1.1.40
func (t StringType) ScalarType() string
func (StringType) String ¶ added in v1.1.40
func (t StringType) String() string
type TaxonomyUpdate ¶
type TaxonomyUpdate struct { AppID *AppIDUpdate `json:"appid,omitempty"` AddedEnums []*EventEnum `json:"addedEnums,omitempty"` RemovedEnums []*EventEnum `json:"removedEnums,omitempty"` UpdatedEnums []*EnumUpdate `json:"updatedEnums,omitempty"` AddedProperties []*EventProperty `json:"addedProperties,omitempty"` RemovedProperties []*EventProperty `json:"removedProperties,omitempty"` UpdatedProperties []*PropertyUpdate `json:"updatedProperties,omitempty"` BlacklistedProperties []string `json:"blacklistedProperties,omitempty"` }
TaxonomyUpdate represents the changes needed to migrate from one version of the event taxonomy to another.
func ComputeChanges ¶
func ComputeChanges(oldT, newT *EventTaxonomy) *TaxonomyUpdate
ComputeChanges computes the changes needed to migrate between taxonomy versions and returns a `TaxonomyUpdate`
func ComputeChangesFromFiles ¶
func ComputeChangesFromFiles(oldFile, newFile string) (*TaxonomyUpdate, error)
ComputeChangesFromFiles computes the changes needed to migrate between taxonomy versions read from `oldFile and `newFile`, and returns a `TaxonomyUpdate` object.
func (*TaxonomyUpdate) DeepCopy ¶
func (in *TaxonomyUpdate) DeepCopy() *TaxonomyUpdate
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TaxonomyUpdate.
func (*TaxonomyUpdate) DeepCopyInto ¶
func (in *TaxonomyUpdate) DeepCopyInto(out *TaxonomyUpdate)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*TaxonomyUpdate) Validate ¶
func (c *TaxonomyUpdate) Validate() (issues []error)
Validate returns a list of errors if there are invalid/unsafe changes