entity

package
v0.0.0-...-bff9524 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicRepositoryAuth

type BasicRepositoryAuth struct {
	Username string
	Password string
}

type CertificateGroup

type CertificateGroup struct {
	Certificate     *x509.Certificate
	PrivateKey      any
	CACertificate   *x509.Certificate
	CertificatePEM  []byte
	PrivateKeyPEM   []byte
	CACertficatePEM []byte
	RevocationTime  time.Time
	IsRevoked       bool
}

func (CertificateGroup) GetSerialNumber

func (c CertificateGroup) GetSerialNumber() string

type Configuration

type Configuration struct {
	TypeMeta
	ObjectMeta
	// repository
	Repository Repository
	// path of the manifest file in the local repo
	Path string
	// list of profiles
	Profiles []Profile
	// HeartbeatPeriod set the heartbeat period of the device
	HeartbeatPeriod time.Duration
	// LogLevel of the device
	LogLevel string
	// Selectors list of selectors
	Selectors []Selector
	// Devices holds the list of devices' ids which use this manifest
	Devices []string
	// Namespaces hold the list of namespace ids which use this manifest
	Namespaces []string
	// Sets holds the list of sets ids which use this manifest
	Sets []string
}

Configuration holds the configuration for a namespace, set or a device.

func (Configuration) GetDevices

func (c Configuration) GetDevices() []string

func (Configuration) GetNamespaces

func (c Configuration) GetNamespaces() []string

func (Configuration) GetSelectors

func (c Configuration) GetSelectors() Selectors

func (Configuration) GetSets

func (c Configuration) GetSets() []string

type CredentialsFunc

type CredentialsFunc func(ctx context.Context, path string) (interface{}, error)

type Device

type Device struct {
	// ID of the device
	ID string
	// EnrolStatus set to true if the device is enroled
	EnrolStatus EnrolStatus
	// EnroledAt represents the time when the device was enroled
	EnroledAt time.Time
	// Registred set to true if the device is already registered.
	Registred bool
	// RegisteredAt represents the time when the device registered.
	RegisteredAt time.Time
	// Namespace in which the device is placed.
	NamespaceID string
	// CertificateSerialNumber holds the SN of the certificate used for authorization.
	// This is the certificate generate at registration time.
	CertificateSerialNumber string
	// ID of set in which the device is present
	SetID *string
	// List of workloads attached to this device
	Workloads []ManifestV1
}

type DeviceConfiguration

type DeviceConfiguration struct {
	Hash          string
	Configuration Configuration
	Workload      []byte
}

DeviceConfiguration is the entity which maps the response to the device following the GetConfiguration call.

type EnrolStatus

type EnrolStatus int
const (
	EnroledStatus EnrolStatus = iota
	PendingEnrolStatus
	RefusedEnrolStatus
	NotEnroledStatus
)

func (EnrolStatus) FromString

func (e EnrolStatus) FromString(s string) EnrolStatus

func (EnrolStatus) String

func (e EnrolStatus) String() string

type Heartbeat

type Heartbeat struct{}

type Manifest

type Manifest interface {
	GetID() string
	GetVersion() Version
	GetHash() string
	GetSelectors() Selectors
	GetNamespaces() []string
	GetSets() []string
	GetDevices() []string
}

type ManifestV1

type ManifestV1 struct {
	TypeMeta
	ObjectMeta
	// repository
	Repository Repository
	// path of the manifest file in the local repo
	Path string
	// Description - description of the manifest
	Description string
	// Rootless - set the mode of podman execution: rootless or rootfull
	Rootless bool
	// Secrets - list of secrets without values. Values are retrieve from Vault.
	Secrets []Secret
	// Resources holds the list of file paths
	Resources []string
	// Selectors list of selectors
	Selectors []Selector
	// Devices holds the list of devices' ids which use this manifest
	Devices []string
	// Namespaces hold the list of namespace ids which use this manifest
	Namespaces []string
	// Sets holds the list of sets ids which use this manifest
	Sets []string
}

ManifestV1 holds the workload definition.

func (ManifestV1) GetDevices

func (w ManifestV1) GetDevices() []string

func (ManifestV1) GetNamespaces

func (w ManifestV1) GetNamespaces() []string

func (ManifestV1) GetSelectors

func (w ManifestV1) GetSelectors() Selectors

func (ManifestV1) GetSets

func (w ManifestV1) GetSets() []string

type Namespace

type Namespace struct {
	Name      string
	IsDefault bool
	// List of sets belonging to his namespace
	Sets []string
	// List of devices belonging to this namespace
	Devices []string
	// List of workload's reference attached to this namespace
	Workloads []ManifestV1
}

type ObjectMeta

type ObjectMeta struct {
	// Id - id of the manifest which is the hash of the filepath
	Id string
	// Labels
	Labels map[string]string
	Hash   string
}

func (ObjectMeta) GetHash

func (o ObjectMeta) GetHash() string

func (ObjectMeta) GetID

func (o ObjectMeta) GetID() string

func (ObjectMeta) GetLabels

func (o ObjectMeta) GetLabels() map[string]string

type Profile

type Profile struct {
	// Name is the name of the profile
	Name string `json:"name"`
	// Conditions holds profile's conditions.
	Conditions []ProfileCondition `json:"conditions"`
}
DeviceProfile specify all the conditions of a profile:

```yaml state:

  • perfomance:
  • low: cpu<25%
  • medium: cpu>25%

``` In this example the profile is _perfomance_ and the conditions are _low_ and _medium_. Each condition's expression is evaluated using Variables. The expression is only evaluated when all the variables need it by the expression are present in the variable map.

type ProfileCondition

type ProfileCondition struct {
	// Name is the name of the condition
	Name string `json:"name"`
	// Expression is the boolean expression for the condition
	Expression string `json:"expression"`
}

type Relation

type Relation struct {
	Type       RelationType
	ResourceID string
	ManifestID string
}

func NewDeviceRelation

func NewDeviceRelation(deviceId, manifestId string) Relation

func NewNamespaceRelation

func NewNamespaceRelation(namespaceId, manifestId string) Relation

func NewSetRelation

func NewSetRelation(setId, manifestId string) Relation

type RelationType

type RelationType int
const (
	NamespaceRelationType RelationType = iota
	SetRelationType
	DeviceRelationType
)

type Repository

type Repository struct {
	Id                    string
	AuthType              RepositoryAuthType
	Credentials           CredentialsFunc
	CredentialsSecretPath string
	Url                   string
	Branch                string
	LocalPath             string
	CurrentHeadSha        string
	TargetHeadSha         string
	PullPeriod            time.Duration
	Manifests             []string
}

Repository holds the information about the git repository where the ManifestWork are to be found.

type RepositoryAuthType

type RepositoryAuthType int
const (
	SSHRepositoryAuthType RepositoryAuthType = iota
	BasicRepositoryAuthType
	TokenRepositoryAuthType
	NoRepositoryAuthType
)

type SSHRepositoryAuth

type SSHRepositoryAuth struct {
	PrivateKey []byte
	Password   string
}

type Secret

type Secret struct {
	Id    string
	Path  string
	Key   string
	Hash  string
	Value string
}

type Selector

type Selector struct {
	Type  SelectorType
	Value string
}

type SelectorType

type SelectorType int
const (
	NamespaceSelector SelectorType = iota
	SetSelector
	DeviceSelector
)

type Selectors

type Selectors []Selector

func (Selectors) ExtractType

func (selectors Selectors) ExtractType(t SelectorType) []string

type Set

type Set struct {
	// Name of the group
	Name string
	// NamespaceID is the id the namsepace to which this set blongs
	NamespaceID string
	// List of the id of devices in the group
	Devices []string
	// List of workload's reference attached to this set
	Workloads []ManifestV1
}

type TokenRepositoryAuth

type TokenRepositoryAuth struct {
	Token string
}

type TypeMeta

type TypeMeta struct {
	// Version
	Version Version
}

func (TypeMeta) GetVersion

func (t TypeMeta) GetVersion() Version

type Version

type Version string
const (
	ManifestVersionV1      Version = "v1"
	ManifestUnknownVersion Version = "unknown version"
)

func (Version) String

func (v Version) String() string

Jump to

Keyboard shortcuts

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