naming

package
v0.0.0-...-ffd2651 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Separator is the character separating a path's namespace, kind and name
	Separator = "/"
)

Variables

View Source
var (
	Cluster = Path{Name: "cluster", Namespace: "root", Kind: KindCcfg}

	// ErrInvalid is raised when the path allocator can not return a path
	// because one of the path element is not valid.
	ErrInvalid = errors.New("invalid path")
)

Functions

func IsValidFQDN

func IsValidFQDN(s string) bool

IsValidFQDN verifies the string meets the RFC1123 requirements

func LogWithPath

func LogWithPath(l *plog.Logger, p Path) *plog.Logger

LogWithPath returns plog.Logger from existing logger with naming attrs sets

func Random

func Random() string

Types

type FQDN

type FQDN struct {
	Path    Path
	Cluster string
}

func NewFQDN

func NewFQDN(path Path, cluster string) *FQDN

func ParseFQDN

func ParseFQDN(s string) (*FQDN, error)

func (FQDN) Domain

func (t FQDN) Domain() string

Domain returns the domain part of the fqdn

func (FQDN) MarshalText

func (t FQDN) MarshalText() ([]byte, error)

MarshalText implements the json interface

func (FQDN) String

func (t FQDN) String() string

func (*FQDN) UnmarshalText

func (t *FQDN) UnmarshalText(b []byte) error

UnmarshalText implements the json interface

type Kind

type Kind string

Kind is opensvc object kind.

const (
	KindInvalid Kind = ""

	// KindSvc is the kind of objects containing app, containers, or volumes resources.
	KindSvc Kind = "svc"

	// KindVol is the kind of objects containing fs, disk resources. Allocated from Pools.
	KindVol Kind = "vol"

	// KindCfg is the kind of objects containing unencrypted key/val pairs used to abstract Svc configurations
	KindCfg Kind = "cfg"

	// KindSec is the kind of objects containing encrypted key/val pairs used to abstract Svc configurations
	KindSec Kind = "sec"

	// KindUsr is the kind of objects containing a API user grants and credentials
	KindUsr Kind = "usr"

	// KindCcfg is the kind of objects containing the cluster configuration
	KindCcfg Kind = "ccfg"

	// KindNscfg is the kind of objects containing a namespace configuration
	KindNscfg Kind = "nscfg"
)

func ParseKind

func ParseKind(s string) Kind

ParseKind returns a Kind from its string representation.

func (Kind) Or

func (t Kind) Or(kinds ...Kind) Kinds

func (Kind) String

func (t Kind) String() string

type Kinds

type Kinds map[Kind]any

Kinds is the result of a binary Or on Kind values

func NewKinds

func NewKinds(kinds ...Kind) Kinds

func (Kinds) Has

func (t Kinds) Has(kind Kind) bool

func (Kinds) Or

func (t Kinds) Or(kinds ...Kind) Kinds

func (Kinds) String

func (t Kinds) String() string

type M

type M map[string]interface{}

M is a map indexed by path string representation.

func (M) Has

func (t M) Has(s string) bool

type Metadata

type Metadata struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
	Kind      Kind   `json:"kind"`
}

Metadata is the parsed representation of a path, used by api handlers to ease dumb clients access to individual path fields.

type Path

type Path struct {
	// Name is the name part of the path
	Name string
	// Namespace is the namespace part of the path
	Namespace string
	// Kind is the kind part of the path
	Kind Kind
}

Path represents an opensvc object path-like identifier. Ex: ns1/svc/svc1

func NewPath

func NewPath(namespace string, kind Kind, name string) (Path, error)

NewPath allocates a new path type from its elements

func NewPathFromStrings

func NewPathFromStrings(namespace, kind, name string) (Path, error)

func ParsePath

func ParsePath(s string) (Path, error)

ParsePath returns a new path struct from a path string representation

func PathOf

func PathOf(o any) Path

func (Path) ConfigFile

func (t Path) ConfigFile() string

ConfigFile returns the object configuration file path on the local filesystem.

func (Path) Equal

func (t Path) Equal(o Path) bool

func (Path) Exists

func (t Path) Exists() bool

Exists returns true if the object configuration file exists.

func (Path) FQN

func (t Path) FQN() string

func (Path) FrozenFile

func (t Path) FrozenFile() string

FrozenFile returns the path of the flag file blocking orchestrations and resource restart.

func (Path) IsZero

func (t Path) IsZero() bool

func (Path) LogDir

func (t Path) LogDir() string

LogDir returns the directory on the local filesystem where the object stores its temporary files.

func (Path) LogFile

func (t Path) LogFile() string

LogFile returns the object log file path on the local filesystem.

func (Path) MarshalText

func (t Path) MarshalText() ([]byte, error)

MarshalText implements the json interface

func (Path) Match

func (t Path) Match(pattern string) bool

Match returns true if the object matches the pattern, using a fnmatch matching algorithm with a few special cases to mask the root namespace tricks and the svc object kind as default.

Trick: The 'f*' pattern matches all svc objects in the root namespace. The '*' pattern matches all svc objects in all namespaces.

func (Path) Path

func (t Path) Path() Path

Path implements the Pather interface

func (Path) ScalerSliceIndex

func (t Path) ScalerSliceIndex() int

ScalerSliceIndex returns the <i> int from a scaler slice name like <i>.<scalerName> Return -1 if not a scaler slice.

func (Path) String

func (t Path) String() string

func (Path) TmpDir

func (t Path) TmpDir() string

TmpDir returns the directory on the local filesystem where the object stores its temporary files.

func (Path) ToMetadata

func (t Path) ToMetadata() *Metadata

ToMetadata returns the parsed representation of the path

func (*Path) UnmarshalText

func (t *Path) UnmarshalText(b []byte) error

UnmarshalText implements the json interface

func (Path) VarDir

func (t Path) VarDir() string

VarDir returns the directory on the local filesystem where the object variable persistent data is stored as files.

type Paths

type Paths []Path

Paths is a list of object paths.

func InstalledPaths

func InstalledPaths() (Paths, error)

InstalledPaths returns a list of every object path with a locally installed configuration file.

func ParsePaths

func ParsePaths(l ...string) (Paths, error)

ParsePaths returns a new naming.Paths from a []string path list.

func (Paths) Existing

func (t Paths) Existing() Paths

func (Paths) Filter

func (t Paths) Filter(pattern string) Paths

func (Paths) Merge

func (t Paths) Merge(other Paths) Paths

func (Paths) Namespaces

func (t Paths) Namespaces() []string

Namespaces return the list of unique namespaces in Paths

func (Paths) StrMap

func (t Paths) StrMap() M

StrMap converts Paths into a map indexed by path string representation. This format is useful for fast Has(string) bool functions.

func (Paths) StrSlice

func (t Paths) StrSlice() []string

StrSlice converts Paths into a string slice. This format is useful to prepare api handlers parameters.

func (Paths) String

func (t Paths) String() string

type Relation

type Relation string

Relation is an object path or an instance path (path@node).

func (Relation) Node

func (t Relation) Node() string

func (Relation) Path

func (t Relation) Path() (Path, error)

func (Relation) Split

func (t Relation) Split() (Path, string, error)

func (Relation) String

func (t Relation) String() string

type Relations

type Relations []Relation

Relations is a slice of Relation

func ParseRelations

func ParseRelations(l []string) Relations

func (Relations) Strings

func (relations Relations) Strings() []string

Jump to

Keyboard shortcuts

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