model

package
v1.1.43 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2020 License: Apache-2.0 Imports: 12 Imported by: 2

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

View Source
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")
)
View Source
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 IsArrayType(t Type) bool

func IsEnumType added in v1.1.40

func IsEnumType(t Type) bool

func IsNullableType added in v1.1.40

func IsNullableType(t Type) bool

func IsSafeTypeChange

func IsSafeTypeChange(fromStr string, toStr string) bool

IsSafeTypeChange returns true if `fromType` can be safely altered to `toType`

Types

type AppIDUpdate

type AppIDUpdate struct {
	From string `json:"from"`
	To   string `json:"to"`
}

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

func (t ArrayType) ScalarType() string

func (ArrayType) String added in v1.1.40

func (t ArrayType) String() string

type BoolType

type BoolType struct{}

+kubebuilder:object:generate=false

func (BoolType) ScalarType added in v1.1.40

func (t BoolType) ScalarType() string

func (BoolType) String added in v1.1.40

func (t BoolType) String() string

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

func (t DateType) ScalarType() string

func (DateType) String added in v1.1.40

func (t DateType) String() string

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

func (t EnumType) ScalarType() string

func (EnumType) String added in v1.1.40

func (t EnumType) String() string

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

func (in *EventEnum) DeepCopy() *EventEnum

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EventEnum.

func (*EventEnum) DeepCopyInto

func (in *EventEnum) DeepCopyInto(out *EventEnum)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*EventEnum) FieldNames

func (e *EventEnum) FieldNames() []string

FieldNames returns a list of strings with names of all our enum fields

func (*EventEnum) FieldsAddedIn

func (e *EventEnum) FieldsAddedIn(new *EventEnum) []string

FieldsAddedIn returns a list of names of enum fields added in `new`

func (*EventEnum) FieldsPreservedIn

func (e *EventEnum) FieldsPreservedIn(new *EventEnum) []string

FieldsPreservedIn returns a list of names of enum fields that are in both this object and `new`

func (*EventEnum) FieldsRemovedIn

func (e *EventEnum) FieldsRemovedIn(new *EventEnum) []string

FieldsRemovedIn returns a list of names of enum fields removed in `new`

func (*EventEnum) GetField

func (e *EventEnum) GetField(name string) *EventEnumField

GetField :

func (*EventEnum) GetFieldByValue

func (e *EventEnum) GetFieldByValue(value int) *EventEnumField

GetFieldByValue returns the enum field with a given value, or nil if not found

func (*EventEnum) MaxValue

func (e *EventEnum) MaxValue() int

MaxValue returns the highest value in one of our enum fields

func (*EventEnum) NextValue added in v1.1.36

func (e *EventEnum) NextValue() int

func (*EventEnum) OK

func (e *EventEnum) OK() error

OK :

func (*EventEnum) SameAs

func (e *EventEnum) SameAs(other *EventEnum) bool

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) GetEnum

func (t *EventTaxonomy) GetEnum(name string) *EventEnum

GetEnum :

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) MaxValue added in v1.1.40

func (t FloatType) MaxValue() float64

func (FloatType) MinValue added in v1.1.40

func (t FloatType) MinValue() float64

func (FloatType) ScalarType added in v1.1.40

func (t FloatType) ScalarType() string

func (FloatType) String added in v1.1.40

func (t FloatType) String() string

type IntType added in v1.1.40

type IntType struct {
	Bits int
}

+kubebuilder:object:generate=false

func (IntType) MaxValue added in v1.1.40

func (t IntType) MaxValue() int

func (IntType) MinValue added in v1.1.40

func (t IntType) MinValue() int

func (IntType) ScalarType added in v1.1.40

func (t IntType) ScalarType() string

func (IntType) String added in v1.1.40

func (t IntType) String() string

type Lifecycle

type Lifecycle string

Lifecycle describes whether a field/property is stable or deprecated

func (*Lifecycle) CanChangeTo

func (l *Lifecycle) CanChangeTo(to Lifecycle) bool

CanChangeTo tells whether this lifecycle state can be changed to another

func (*Lifecycle) EndLife added in v1.1.38

func (l *Lifecycle) EndLife()

func (Lifecycle) IsAlive

func (l Lifecycle) IsAlive() bool

func (Lifecycle) IsExisting added in v1.1.36

func (l Lifecycle) IsExisting() bool

func (*Lifecycle) Revive added in v1.1.35

func (l *Lifecycle) Revive()

*

  • Revive the property

func (*Lifecycle) UnmarshalJSON

func (l *Lifecycle) UnmarshalJSON(b []byte) error

UnmarshalJSON unmashals a JSON string to a Lifecycle value

type LifecycleUpdate

type LifecycleUpdate struct {
	From Lifecycle `json:"from"`
	To   Lifecycle `json:"to"`
}

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

type Type added in v1.1.40

type Type interface {
	ScalarType() string
	String() string
}

+kubebuilder:object:generate=false

func ParseScalarType added in v1.1.40

func ParseScalarType(typeStr string) (Type, error)

func ParseType

func ParseType(typeStr string) (Type, error)

Jump to

Keyboard shortcuts

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