properties

package
v0.0.81 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package properties provides a simple way to access properties of an entity

Index

Constants

View Source
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

View Source
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

View Source
const (
	// PullRequestCommitSHA represents the commit SHA of the pull request
	PullRequestCommitSHA = "commit_sha"
	// PullRequestBaseCloneURL represents the clone URL of the base repository
	PullRequestBaseCloneURL = "base_clone_url"
	// PullRequestBaseDefaultBranch represents the default branch of the base repository
	PullRequestBaseDefaultBranch = "base_default_branch"
	// PullRequestTargetCloneURL represents the clone URL of the target repository.
	// Where the pull request comes from.
	PullRequestTargetCloneURL = "target_clone_url"
	// PullRequestTargetBranch represents the default branch of the target repository.
	// Where the pull request comes from.
	PullRequestTargetBranch = "target_branch"
	// PullRequestUpstreamURL represents the URL of the pull request in the provider
	PullRequestUpstreamURL = "upstream_url"
)

Pull Request property keys

View Source
const (
	// ReleasePropertyTag represents the release tag name.
	ReleasePropertyTag = "tag"
	// ReleasePropertyBranch represents the release branch
	ReleasePropertyBranch = "branch"
	// ReleaseCommitSHA represents the commit SHA of the release
	ReleaseCommitSHA = "commit_sha"
)

Release property keys

View Source
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) Len

func (p *Properties) Len() int

Len returns the number of properties

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

func NewProperty(value any) (*Property, error)

NewProperty creates a new Property with a given value

func (*Property) AsBool

func (p *Property) AsBool() (bool, error)

AsBool returns the boolean value, or an error if the value is not a boolean

func (*Property) AsInt64

func (p *Property) AsInt64() (int64, error)

AsInt64 returns the int64 value, or an error if the value is not an int64

func (*Property) AsString

func (p *Property) AsString() (string, error)

AsString returns the string value, or an error if the value is not a string

func (*Property) AsUint64

func (p *Property) AsUint64() (uint64, error)

AsUint64 returns the uint64 value, or an error if the value is not an uint64

func (*Property) Equal

func (p *Property) Equal(other *Property) bool

Equal checks if two Properties are equal

func (*Property) GetBool

func (p *Property) GetBool() bool

GetBool returns the boolean value, or false if the value is not a boolean

func (*Property) GetInt64

func (p *Property) GetInt64() int64

GetInt64 returns the int64 value, or 0 if the value is not an int64

func (*Property) GetString

func (p *Property) GetString() string

GetString returns the string value, or an empty string if the value is not a string

func (*Property) GetUint64

func (p *Property) GetUint64() uint64

GetUint64 returns the uint64 value, or 0 if the value is not an uint64

func (*Property) RawValue

func (p *Property) RawValue() any

RawValue returns the raw value as an any

type PropertyFilter

type PropertyFilter func(key string, prop *Property) bool

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

Jump to

Keyboard shortcuts

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