label

package
v0.0.0-...-a423d60 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalSystemRoleLabelKey string

GlobalSystemRoleLabelKey is a global variable containing the name of the system role label

Functions

func ExtractValueFromJSONPath

func ExtractValueFromJSONPath(jpq string) ([]interface{}, error)

ExtractValueFromJSONPath returns the value that is placed in the SQL/JSON path query

For a given JSON path $[*] ? (@ == "dd") it extracts the actual value - dd For a given JSON path $[*] ? (@ == "dd" || @ == "ww") it extracts the actual values - dd and ww

func FilterQuery

func FilterQuery(queryFor model.LabelableObject, setCombination SetCombination, tenant uuid.UUID, filter []*labelfilter.LabelFilter) (string, []interface{}, error)

FilterQuery builds select query for given filters

It supports querying defined by `queryFor` parameter. All queries are created in the context of given tenant

func FilterQueryGlobal

func FilterQueryGlobal(queryFor model.LabelableObject, setCombination SetCombination, filters []*labelfilter.LabelFilter) (string, []interface{}, error)

FilterQueryGlobal builds select query for given filters

It supports querying defined by `queryFor` parameter. All queries are created in the global context

func FilterSubquery

func FilterSubquery(queryFor model.LabelableObject, setCombination SetCombination, tenant uuid.UUID, filter []*labelfilter.LabelFilter) (string, []interface{}, error)

FilterSubquery builds select sub query for given filters that can be appended to other query

It supports querying defined by `queryFor` parameter. All queries are created in the context of given tenant

func NewConverter

func NewConverter() *converter

NewConverter missing godoc

func NewLabelService

func NewLabelService(labelRepo LabelRepository, labelDefinitionRepo LabelDefinitionRepository, uidService UIDService) *labelService

NewLabelService missing godoc

func NewRepository

func NewRepository(conv Converter) *repository

NewRepository missing godoc

func ValueToStringsSlice

func ValueToStringsSlice(value interface{}) ([]string, error)

ValueToStringsSlice missing godoc

Types

type Collection

type Collection []Entity

Collection is a collection of label entities.

func (Collection) Len

func (c Collection) Len() int

Len returns the number of entities in the collection.

type Converter

type Converter interface {
	ToEntity(in *model.Label) (*Entity, error)
	FromEntity(in *Entity) (*model.Label, error)
}

Converter missing godoc

type Entity

type Entity struct {
	ID                  string         `db:"id"`
	TenantID            sql.NullString `db:"tenant_id"`
	Key                 string         `db:"key"`
	AppID               sql.NullString `db:"app_id"`
	RuntimeID           sql.NullString `db:"runtime_id"`
	RuntimeContextID    sql.NullString `db:"runtime_context_id"`
	AppTemplateID       sql.NullString `db:"app_template_id"`
	WebhookID           sql.NullString `db:"webhook_id"`
	FormationTemplateID sql.NullString `db:"formation_template_id"`
	Value               string         `db:"value"`
	Version             int            `db:"version"`
}

Entity is a label entity.

func (*Entity) DecorateWithTenantID

func (e *Entity) DecorateWithTenantID(tenant string) interface{}

DecorateWithTenantID decorates the entity with the given tenant ID.

func (*Entity) GetID

func (e *Entity) GetID() string

GetID returns the ID of the label.

func (*Entity) GetParent

func (e *Entity) GetParent(_ resource.Type) (resource.Type, string)

GetParent returns the parent type and the parent ID of the entity.

func (*Entity) GetValue

func (e *Entity) GetValue() (interface{}, error)

GetValue returns the Value of the label.

type LabelDefinitionRepository

type LabelDefinitionRepository interface {
	Create(ctx context.Context, def model.LabelDefinition) error
	Exists(ctx context.Context, tenant string, key string) (bool, error)
	GetByKey(ctx context.Context, tenant string, key string) (*model.LabelDefinition, error)
}

LabelDefinitionRepository missing godoc

type LabelRepository

type LabelRepository interface {
	Create(ctx context.Context, tenant string, label *model.Label) error
	Upsert(ctx context.Context, tenant string, label *model.Label) error
	UpsertGlobal(ctx context.Context, label *model.Label) error
	UpdateWithVersion(ctx context.Context, tenant string, label *model.Label) error
	GetByKey(ctx context.Context, tenant string, objectType model.LabelableObject, objectID, key string) (*model.Label, error)
	GetByKeyGlobal(ctx context.Context, objectType model.LabelableObject, objectID, key string) (*model.Label, error)
	Delete(ctx context.Context, tenantID string, objectType model.LabelableObject, objectID string, key string) error
	ListForObject(ctx context.Context, tenantID string, objectType model.LabelableObject, objectID string) (map[string]*model.Label, error)
}

LabelRepository missing godoc

type ParentAccessVerifier

type ParentAccessVerifier struct {
	// contains filtered or unexported fields
}

ParentAccessVerifier defines parent access verifier

func NewDefaultParentAccessVerifier

func NewDefaultParentAccessVerifier() *ParentAccessVerifier

NewDefaultParentAccessVerifier creates new ParentAccessVerifier with default converter and label repository

func NewParentAccessVerifier

func NewParentAccessVerifier(labelRepo LabelRepository) *ParentAccessVerifier

NewParentAccessVerifier creates new ParentAccessVerifier

func (*ParentAccessVerifier) Verify

func (p *ParentAccessVerifier) Verify(ctx context.Context, parentResourceType resource.Type, parentID string) error

Verify verifies that the provided parent belongs to the same tenant as the one in the context

type SetCombination

type SetCombination string

SetCombination type defines possible result set combination for querying

const (
	// IntersectSet missing godoc
	IntersectSet SetCombination = "INTERSECT"
	// ExceptSet missing godoc
	ExceptSet SetCombination = "EXCEPT"
	// UnionSet missing godoc
	UnionSet SetCombination = "UNION"
)

type UIDService

type UIDService interface {
	Generate() string
}

UIDService missing godoc

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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