label

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2021 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB implements the Store interface using a postgres database.

func NewDB

func NewDB(ctx context.Context, db *sql.DB) (*DB, error)

NewDB will Set a DB backend from a sql.DB. An error will be returned if statements fail to prepare.

func (*DB) FindAllByService

func (db *DB) FindAllByService(ctx context.Context, serviceID string) ([]Label, error)

FindAllByService finds all labels for a particular service. It returns all key-value pairs.

func (*DB) SearchKeys added in v0.25.0

func (db *DB) SearchKeys(ctx context.Context, opts *KeySearchOptions) ([]string, error)

func (*DB) SearchValues added in v0.25.0

func (db *DB) SearchValues(ctx context.Context, opts *ValueSearchOptions) ([]string, error)

func (*DB) SetTx

func (db *DB) SetTx(ctx context.Context, tx *sql.Tx, label *Label) error

SetTx will set a label for the service. It can be used to set the key-value pair for the label, delete a label or update the value given the label's key.

func (*DB) UniqueKeys

func (db *DB) UniqueKeys(ctx context.Context) ([]string, error)

func (*DB) UniqueKeysTx

func (db *DB) UniqueKeysTx(ctx context.Context, tx *sql.Tx) ([]string, error)

type KeySearchOptions added in v0.25.0

type KeySearchOptions struct {
	Search string `json:"s,omitempty"`
	After  string `json:"a,omitempty"`

	// Omit specifies a list of key names to exclude from the results.
	Omit []string `json:"o,omitempty"`

	Limit int `json:"-"`
}

KeySearchOptions allow filtering and paginating the list of rotations.

type Label

type Label struct {
	Target assignment.Target
	Key    string `json:"key"`
	Value  string `json:"value"`
}

A Label is a key-value pair assigned to a target.

func (Label) Normalize

func (l Label) Normalize() (*Label, error)

Normalize will validate and normalize the label, returning a copy.

type Store

type Store interface {
	SetTx(ctx context.Context, tx *sql.Tx, label *Label) error
	FindAllByService(ctx context.Context, serviceID string) ([]Label, error)
	UniqueKeysTx(ctx context.Context, tx *sql.Tx) ([]string, error)
	UniqueKeys(ctx context.Context) ([]string, error)
	SearchKeys(ctx context.Context, opts *KeySearchOptions) ([]string, error)
	SearchValues(ctx context.Context, opts *ValueSearchOptions) ([]string, error)
}

Store allows the lookup and management of Labels.

type ValueSearchOptions added in v0.25.0

type ValueSearchOptions struct {
	Key string `json:"k"`

	KeySearchOptions
}

ValueSearchOptions allow filtering and paginating the list of rotations.

Jump to

Keyboard shortcuts

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