Documentation ¶
Overview ¶
Package properties provides a simple way to access properties of an entity
Index ¶
- Constants
- func NumericalValueToUpstreamID[T constraints.Integer](n T) string
- type Properties
- func (p *Properties) FilteredCopy(filter PropertyFilter) *Properties
- func (p *Properties) GetProperty(key string) *Property
- func (p *Properties) Iterate() iter.Seq2[string, *Property]
- func (p *Properties) Len() int
- func (p *Properties) Merge(other *Properties) *Properties
- func (p *Properties) SetKeyValue(key string, value any) error
- func (p *Properties) SetProperty(key string, prop *Property)
- func (p *Properties) String() string
- func (p *Properties) ToLogDict() *zerolog.Event
- func (p *Properties) ToProtoStruct() *structpb.Struct
- type Property
- func (p *Property) AsBool() (bool, error)
- func (p *Property) AsInt64() (int64, error)
- func (p *Property) AsString() (string, error)
- func (p *Property) AsUint64() (uint64, error)
- func (p *Property) Equal(other *Property) bool
- func (p *Property) GetBool() bool
- func (p *Property) GetInt64() int64
- func (p *Property) GetString() string
- func (p *Property) GetUint64() uint64
- func (p *Property) RawValue() any
- type PropertyFilter
Constants ¶
const ( // PropertyName represents the name of the entity. The name is formatted by the provider PropertyName = "name" // PropertyUpstreamID represents the ID of the entity in the provider PropertyUpstreamID = "upstream_id" )
General entity keys
const ( // RepoPropertyIsPrivate represents whether the repository is private RepoPropertyIsPrivate = "is_private" // RepoPropertyIsArchived represents whether the repository is archived RepoPropertyIsArchived = "is_archived" // RepoPropertyIsFork represents whether the repository is a fork RepoPropertyIsFork = "is_fork" )
Repository property keys
const (
// ArtifactPropertyType represents the type of the artifact (e.g 'container')
ArtifactPropertyType = "type"
)
Artifact property keys
Variables ¶
This section is empty.
Functions ¶
func NumericalValueToUpstreamID ¶
func NumericalValueToUpstreamID[T constraints.Integer](n T) string
NumericalValueToUpstreamID converts a numerical value to a string for use as an upstream ID
Types ¶
type Properties ¶
type Properties struct {
// contains filtered or unexported fields
}
Properties struct that holds the properties map and provides access to Property values
func NewProperties ¶
func NewProperties(props map[string]any, opts ...newPropertiesOption) (*Properties, error)
NewProperties creates Properties from a map
func (*Properties) FilteredCopy ¶
func (p *Properties) FilteredCopy(filter PropertyFilter) *Properties
FilteredCopy returns a new Properties with only the properties that pass the filter
func (*Properties) GetProperty ¶
func (p *Properties) GetProperty(key string) *Property
GetProperty returns the Property for a given key or an empty one as a fallback
func (*Properties) Iterate ¶
func (p *Properties) Iterate() iter.Seq2[string, *Property]
Iterate implements the seq2 iterator so that the caller can call for key, prop := range Iterate()
func (*Properties) Merge ¶
func (p *Properties) Merge(other *Properties) *Properties
Merge merges two Properties into a new one
func (*Properties) SetKeyValue ¶
func (p *Properties) SetKeyValue(key string, value any) error
SetKeyValue sets the key value pair in the Properties
func (*Properties) SetProperty ¶
func (p *Properties) SetProperty(key string, prop *Property)
SetProperty sets the Property for a given key
func (*Properties) String ¶
func (p *Properties) String() string
String implements the fmt.Stringer interface, for debugging purposes
func (*Properties) ToLogDict ¶
func (p *Properties) ToLogDict() *zerolog.Event
ToLogDict converts the Properties to a zerolog Dict
func (*Properties) ToProtoStruct ¶
func (p *Properties) ToProtoStruct() *structpb.Struct
ToProtoStruct converts the Properties to a protobuf Struct
type Property ¶
type Property struct {
// contains filtered or unexported fields
}
Property is a struct that holds a value. It's just a wrapper around structpb.Value with typed getters and handling of a nil receiver
func NewProperty ¶
NewProperty creates a new Property with a given value
func (*Property) AsBool ¶
AsBool returns the boolean value, or an error if the value is not a boolean
func (*Property) AsInt64 ¶
AsInt64 returns the int64 value, or an error if the value is not an int64
func (*Property) AsString ¶
AsString returns the string value, or an error if the value is not a string
func (*Property) AsUint64 ¶
AsUint64 returns the uint64 value, or an error if the value is not an uint64
func (*Property) GetBool ¶
GetBool returns the boolean value, or false if the value is not a boolean
func (*Property) GetString ¶
GetString returns the string value, or an empty string if the value is not a string
type PropertyFilter ¶
PropertyFilter is a function that filters properties
Directories ¶
Path | Synopsis |
---|---|
Package service provides a service to interact with properties of an entity
|
Package service provides a service to interact with properties of an entity |
mock
Package mock_service is a generated GoMock package.
|
Package mock_service is a generated GoMock package. |
mock/fixtures
Package fixtures contains code for creating RepositoryService fixtures and is used in various parts of the code.
|
Package fixtures contains code for creating RepositoryService fixtures and is used in various parts of the code. |