Help us shape the future of Go! Take the 2026 Go Developer Survey

entity

package
v0.1.41 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package entity contains common entity definitions for MongoDB persistence.

Index

Constants

View Source
const (
	// AgentKeyFieldName is the field name used as the key for Agent entities in MongoDB.
	AgentKeyFieldName string = "metadata.instanceUid"

	// IdentifyingAttributesFieldName is the field name for identifying attributes in MongoDB.
	// It is indexed for efficient querying.
	IdentifyingAttributesFieldName string = "metadata.description.identifyingAttributes"
	// NonIdentifyingAttributesFieldName is the field name for non-identifying attributes in MongoDB.
	// It is indexed for efficient querying.
	NonIdentifyingAttributesFieldName string = "metadata.description.nonIdentifyingAttributes"
)
View Source
const (
	// AgentPackageNamespaceFieldName is the field name for agent package namespace in MongoDB.
	AgentPackageNamespaceFieldName = "metadata.namespace"
	// AgentPackageNameFieldName is the field name for agent package name in MongoDB.
	AgentPackageNameFieldName = "metadata.name"
)
View Source
const (
	// AgentRemoteConfigKeyFieldName is the key field name for agent remote config.
	AgentRemoteConfigKeyFieldName = "metadata.name"
	// AgentRemoteConfigNamespaceFieldName is the field name for namespace in MongoDB.
	AgentRemoteConfigNamespaceFieldName = "metadata.namespace"
	// AgentRemoteConfigNameFieldName is the field name for name in MongoDB.
	AgentRemoteConfigNameFieldName = "metadata.name"
)
View Source
const (
	// CertificateNamespaceFieldName is the field name for certificate namespace in MongoDB.
	CertificateNamespaceFieldName = "metadata.namespace"
	// CertificateNameFieldName is the field name for certificate name in MongoDB.
	CertificateNameFieldName = "metadata.name"
)
View Source
const (
	// AgentGroupKeyFieldName is the field name used as the key for AgentGroup entities in MongoDB.
	AgentGroupKeyFieldName string = "metadata.name"
)
View Source
const (
	// ContainerKeyFieldName is the key field name for container.
	ContainerKeyFieldName = "metadata.id"
)
View Source
const (
	// HostKeyFieldName is the key field name for host.
	HostKeyFieldName = "metadata.id"
)
View Source
const (
	// NamespaceKeyFieldName is the key field name for namespace.
	NamespaceKeyFieldName = "metadata.name"
)
View Source
const (
	// PermissionKeyFieldName is the key field name for permission.
	PermissionKeyFieldName = "metadata.uid"
)
View Source
const (
	// RoleBindingKeyFieldName is the key field name for role binding entities in MongoDB.
	RoleBindingKeyFieldName string = "metadata.name"
)
View Source
const (
	// RoleKeyFieldName is the key field name for role.
	RoleKeyFieldName = "metadata.uid"
)
View Source
const (
	// UserKeyFieldName is the key field name for user.
	UserKeyFieldName = "metadata.uid"
)
View Source
const (
	// UserRoleKeyFieldName is the key field name for user role.
	UserRoleKeyFieldName = "metadata.uid"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	Common `bson:",inline"`

	Metadata AgentMetadata `bson:"metadata"`
	Spec     AgentSpec     `bson:"spec"`
	Status   AgentStatus   `bson:"status"`
}

Agent is a struct that represents the MongoDB entity for an Agent.

func AgentFromDomain

func AgentFromDomain(agent *agentmodel.Agent) *Agent

AgentFromDomain converts domain model to persistence model.

func (*Agent) ToDomain

func (a *Agent) ToDomain() *agentmodel.Agent

ToDomain converts the Agent to domain model.

type AgentAvailableComponents

type AgentAvailableComponents struct {
	Components map[string]ComponentDetails `bson:"components"`
	Hash       bson.Binary                 `bson:"hash"`
}

AgentAvailableComponents is a map of available components.

func AgentAvailableComponentsFromDomain

func AgentAvailableComponentsFromDomain(acc *agentmodel.AgentAvailableComponents) *AgentAvailableComponents

AgentAvailableComponentsFromDomain converts domain model to persistence model.

func (*AgentAvailableComponents) ToDomain

ToDomain converts the AgentAvailableComponents to domain model.

type AgentCapabilities

type AgentCapabilities uint64

AgentCapabilities is a bitmask of capabilities that the Agent supports.

func AgentCapabilitiesFromDomain

func AgentCapabilitiesFromDomain(ac *agent.Capabilities) *AgentCapabilities

AgentCapabilitiesFromDomain converts domain model to persistence model.

func (*AgentCapabilities) ToDomain

func (ac *AgentCapabilities) ToDomain() *agent.Capabilities

ToDomain converts the AgentCapabilities to domain model.

type AgentComponentHealth

type AgentComponentHealth struct {
	Healthy             bool                            `bson:"healthy"`
	StartTimeUnixMilli  int64                           `bson:"startTimeUnixMilli"`
	LastError           string                          `bson:"lastError"`
	Status              string                          `bson:"status"`
	StatusTimeUnixMilli int64                           `bson:"statusTimeUnixMilli"`
	ComponentHealthMap  map[string]AgentComponentHealth `bson:"componentHealthMap,omitempty"`
}

AgentComponentHealth is a struct to manage component health.

func AgentComponentHealthFromDomain

func AgentComponentHealthFromDomain(ach *agentmodel.AgentComponentHealth) *AgentComponentHealth

AgentComponentHealthFromDomain converts domain model to persistence model.

func (*AgentComponentHealth) ToDomain

ToDomain converts the AgentComponentHealth to domain model.

type AgentCondition

type AgentCondition struct {
	Type               string        `bson:"type"`
	LastTransitionTime bson.DateTime `bson:"lastTransitionTime"`
	Status             string        `bson:"status"`
	Reason             string        `bson:"reason"`
	Message            string        `bson:"message,omitempty"`
}

AgentCondition represents a condition of an agent in MongoDB.

func AgentConditionsFromDomain

func AgentConditionsFromDomain(conditions []agentmodel.AgentCondition) []AgentCondition

AgentConditionsFromDomain converts domain conditions to persistence model.

type AgentConfigFile

type AgentConfigFile struct {
	Body        bson.Binary `bson:"body"`
	ContentType string      `bson:"contentType"`
}

AgentConfigFile is a struct to manage config file.

type AgentConfigMap

type AgentConfigMap struct {
	ConfigMap map[string]AgentConfigFile `bson:"configMap,omitempty"`
}

AgentConfigMap is a struct to manage config map.

type AgentConnectionConfig

type AgentConnectionConfig struct {
	OpAMP            ConnectionSettings            `bson:"opamp"            json:"opamp"`
	OwnMetrics       ConnectionSettings            `bson:"ownMetrics"       json:"ownMetrics"`
	OwnLogs          ConnectionSettings            `bson:"ownLogs"          json:"ownLogs"`
	OwnTraces        ConnectionSettings            `bson:"ownTraces"        json:"ownTraces"`
	OtherConnections map[string]ConnectionSettings `bson:"otherConnections" json:"otherConnections"`
}

AgentConnectionConfig represents connection settings for agents in the group.

type AgentCustomCapabilities

type AgentCustomCapabilities struct {
	Capabilities []string `bson:"capabilities"`
}

AgentCustomCapabilities is a custom capabilities of the agent.

func AgentCustomCapabilitiesFromDomain

func AgentCustomCapabilitiesFromDomain(acc *agentmodel.AgentCustomCapabilities) *AgentCustomCapabilities

AgentCustomCapabilitiesFromDomain converts domain model to persistence model.

func (*AgentCustomCapabilities) ToDomain

ToDomain converts the AgentCustomCapabilities to domain model.

type AgentDescription

type AgentDescription struct {
	IdentifyingAttributes    KeyValuePairs `bson:"identifyingAttributes,omitempty"`
	NonIdentifyingAttributes KeyValuePairs `bson:"nonIdentifyingAttributes,omitempty"`
}

AgentDescription is a struct to manage agent description.

func AgentDescriptionFromDomain

func AgentDescriptionFromDomain(ads *agent.Description) *AgentDescription

AgentDescriptionFromDomain converts domain model to persistence model.

func (*AgentDescription) ToDomain

func (ad *AgentDescription) ToDomain() *agent.Description

ToDomain converts the AgentDescription to domain model.

type AgentEffectiveConfig

type AgentEffectiveConfig struct {
	ConfigMap AgentConfigMap `bson:"configMap"`
}

AgentEffectiveConfig is a struct to manage effective config.

func AgentEffectiveConfigFromDomain

func AgentEffectiveConfigFromDomain(aec *agentmodel.AgentEffectiveConfig) *AgentEffectiveConfig

AgentEffectiveConfigFromDomain converts domain model to persistence model.

func (*AgentEffectiveConfig) ToDomain

ToDomain converts the AgentEffectiveConfig to domain model.

type AgentGroup

type AgentGroup struct {
	Common `bson:",inline"`

	Metadata AgentGroupMetadata `bson:"metadata"`
	Spec     AgentGroupSpec     `bson:"spec"`
	Status   AgentGroupStatus   `bson:"status"`
}

AgentGroup is the mongo entity representation of the AgentGroup domain model.

func AgentGroupFromDomain

func AgentGroupFromDomain(agentgroup *agentmodel.AgentGroup) *AgentGroup

AgentGroupFromDomain converts the AgentGroup domain model to the entity representation.

func (*AgentGroup) ToDomain

func (e *AgentGroup) ToDomain(statistics *AgentGroupStatistics) *agentmodel.AgentGroup

ToDomain converts the AgentGroup entity to the domain model.

type AgentGroupAgentRemoteConfig

type AgentGroupAgentRemoteConfig struct {
	AgentRemoteConfigName *string                `bson:"agentRemoteConfigName,omitempty"`
	AgentRemoteConfigSpec *AgentRemoteConfigSpec `bson:"agentRemoteConfigSpec,omitempty"`
	AgentRemoteConfigRef  *string                `bson:"agentRemoteConfigRef,omitempty"`
}

AgentGroupAgentRemoteConfig represents the remote configuration for agents in the group.

type AgentGroupMetadata

type AgentGroupMetadata struct {
	Namespace  string            `bson:"namespace"`
	Name       string            `bson:"name"`
	Attributes map[string]string `bson:"attributes"`
	CreatedAt  time.Time         `bson:"createdAt"`
	DeletedAt  *time.Time        `bson:"deletedAt,omitempty"`
}

AgentGroupMetadata represents metadata information for an agent group.

type AgentGroupSpec

type AgentGroupSpec struct {
	Priority              int                          `bson:"priority"`
	Selector              AgentSelector                `bson:"selector"`
	AgentRemoteConfig     *AgentGroupAgentRemoteConfig `bson:"agentConfig,omitempty"`
	AgentConnectionConfig *AgentConnectionConfig       `bson:"agentConnectionConfig,omitempty"`
}

AgentGroupSpec represents the specification of an agent group.

type AgentGroupStatistics

type AgentGroupStatistics struct {
	NumAgents             int64
	NumConnectedAgents    int64
	NumHealthyAgents      int64
	NumUnhealthyAgents    int64
	NumNotConnectedAgents int64
}

AgentGroupStatistics holds statistical data for an agent group.

type AgentGroupStatus

type AgentGroupStatus struct {
	Conditions []Condition `bson:"conditions"`
}

AgentGroupStatus represents the status of an agent group in MongoDB.

type AgentMetadata

type AgentMetadata struct {
	InstanceUID        bson.Binary              `bson:"instanceUid"`
	InstanceUIDString  string                   `bson:"instanceUidString"` // String representation for searching
	Namespace          string                   `bson:"namespace"`
	Capabilities       *AgentCapabilities       `bson:"capabilities,omitempty"`
	Description        *AgentDescription        `bson:"description,omitempty"`
	CustomCapabilities *AgentCustomCapabilities `bson:"customCapabilities,omitempty"`
}

AgentMetadata represents the metadata of an agent.

func (*AgentMetadata) ToDmain

func (metadata *AgentMetadata) ToDmain() agentmodel.AgentMetadata

ToDmain converts the AgentMetadata to domain model.

type AgentPackage

type AgentPackage struct {
	Common `bson:",inline"`

	Metadata AgentPackageMetadata       `bson:"metadata"`
	Spec     AgentPackageSpec           `bson:"spec"`
	Status   AgentPackageResourceStatus `bson:"status"`
}

AgentPackage is the MongoDB entity for agent package.

func AgentPackageFromDomain

func AgentPackageFromDomain(domain *agentmodel.AgentPackage) *AgentPackage

AgentPackageFromDomain converts domain model to entity.

func (*AgentPackage) ToDomain

func (ap *AgentPackage) ToDomain() *agentmodel.AgentPackage

ToDomain converts the entity to domain model.

type AgentPackageMetadata

type AgentPackageMetadata struct {
	Name       string            `bson:"name"`
	Namespace  string            `bson:"namespace"`
	Attributes map[string]string `bson:"attributes,omitempty"`
	CreatedAt  time.Time         `bson:"createdAt"`
	DeletedAt  *time.Time        `bson:"deletedAt,omitempty"`
}

AgentPackageMetadata represents the metadata of an agent package.

type AgentPackageResourceStatus

type AgentPackageResourceStatus struct {
	Conditions []Condition `bson:"conditions,omitempty"`
}

AgentPackageResourceStatus represents the status of an agent package resource.

type AgentPackageSpec

type AgentPackageSpec struct {
	PackageType string            `bson:"packageType"`
	Version     string            `bson:"version"`
	DownloadURL string            `bson:"downloadUrl"`
	ContentHash []byte            `bson:"contentHash,omitempty"`
	Signature   []byte            `bson:"signature,omitempty"`
	Headers     map[string]string `bson:"headers,omitempty"`
	Hash        []byte            `bson:"hash,omitempty"`
}

AgentPackageSpec represents the specification of an agent package.

type AgentPackageStatus

type AgentPackageStatus struct {
	Name                 string                 `bson:"name"`
	AgentHasVersion      string                 `bson:"agentHasVersion"`
	AgentHasHash         bson.Binary            `bson:"agentHasHash"`
	ServerOfferedVersion string                 `bson:"serverOfferedVersion"`
	Status               AgentPackageStatusEnum `bson:"status"`
	ErrorMessage         string                 `bson:"errorMessage"`
}

AgentPackageStatus is a status of a package.

type AgentPackageStatusEnum

type AgentPackageStatusEnum int32

AgentPackageStatusEnum is an enum that represents the status of a package.

type AgentPackageStatuses

type AgentPackageStatuses struct {
	Packages                     map[string]AgentPackageStatus `bson:"packages"`
	ServerProvidedAllPackgesHash bson.Binary                   `bson:"serverProvidedAllPackgesHash"`
	ErrorMessage                 string                        `bson:"errorMessage"`
}

AgentPackageStatuses is a map of package statuses.

func AgentPackageStatusesFromDomain

func AgentPackageStatusesFromDomain(aps *agentmodel.AgentPackageStatuses) *AgentPackageStatuses

AgentPackageStatusesFromDomain converts domain model to persistence model.

func (*AgentPackageStatuses) ToDomain

ToDomain converts the AgentPackageStatuses to domain model.

type AgentRemoteConfigData

type AgentRemoteConfigData struct {
	Key                bson.Binary                 `bson:"key"`
	Status             AgentRemoteConfigStatusEnum `bson:"status"`
	Config             bson.Binary                 `bson:"config"`
	LastUpdatedAtMilli int64                       `bson:"lastUpdatedAtMilli"`
}

AgentRemoteConfigData is a struct to manage remote config data.

type AgentRemoteConfigResourceEntity

type AgentRemoteConfigResourceEntity struct {
	ID       *bson.ObjectID                        `bson:"_id,omitempty"`
	Metadata AgentRemoteConfigResourceMetadata     `bson:"metadata"`
	Spec     AgentRemoteConfigResourceSpec         `bson:"spec"`
	Status   AgentRemoteConfigResourceEntityStatus `bson:"status"`
}

AgentRemoteConfigResourceEntity is the MongoDB entity for agent remote config resource.

func AgentRemoteConfigResourceEntityFromDomain

func AgentRemoteConfigResourceEntityFromDomain(
	arc *agentmodel.AgentRemoteConfig,
) *AgentRemoteConfigResourceEntity

AgentRemoteConfigResourceEntityFromDomain converts domain model to entity.

func (*AgentRemoteConfigResourceEntity) ToDomain

ToDomain converts the entity to domain model.

type AgentRemoteConfigResourceEntityStatus

type AgentRemoteConfigResourceEntityStatus struct {
	Conditions []Condition `bson:"conditions,omitempty"`
}

AgentRemoteConfigResourceEntityStatus represents the status of an agent remote config resource.

type AgentRemoteConfigResourceMetadata

type AgentRemoteConfigResourceMetadata struct {
	Name       string            `bson:"name"`
	Namespace  string            `bson:"namespace"`
	Attributes map[string]string `bson:"attributes,omitempty"`
	CreatedAt  time.Time         `bson:"createdAt"`
	DeletedAt  *time.Time        `bson:"deletedAt,omitempty"`
}

AgentRemoteConfigResourceMetadata represents the metadata of an agent remote config resource.

type AgentRemoteConfigResourceSpec

type AgentRemoteConfigResourceSpec struct {
	Value       []byte `bson:"value"`
	ContentType string `bson:"contentType"`
}

AgentRemoteConfigResourceSpec represents the specification of an agent remote config resource.

type AgentRemoteConfigSpec

type AgentRemoteConfigSpec struct {
	Value       []byte `bson:"value"       json:"value"`
	ContentType string `bson:"contentType" json:"contentType"`
}

AgentRemoteConfigSpec represents the specification of a remote config.

type AgentRemoteConfigStatus

type AgentRemoteConfigStatus struct {
	LastRemoteConfigHash *bson.Binary                `bson:"lastRemoteConfigHash,omitempty"`
	Status               AgentRemoteConfigStatusEnum `bson:"status"`
	ErrorMessage         string                      `bson:"errorMessage,omitempty"`
}

AgentRemoteConfigStatus represents the status of remote config in MongoDB.

func AgentRemoteConfigStatusFromDomain

func AgentRemoteConfigStatusFromDomain(arcs *agentmodel.AgentRemoteConfigStatus) *AgentRemoteConfigStatus

AgentRemoteConfigStatusFromDomain converts domain model to persistence model.

func (*AgentRemoteConfigStatus) ToDomain

ToDomain converts the AgentRemoteConfigStatus to domain model.

type AgentRemoteConfigStatusEnum

type AgentRemoteConfigStatusEnum int32

AgentRemoteConfigStatusEnum is an enum that represents the status of the remote config.

type AgentRemoteConfigSub

type AgentRemoteConfigSub struct {
	Key   bson.Binary                 `bson:"key"`
	Value AgentRemoteConfigStatusEnum `bson:"value"`
}

AgentRemoteConfigSub is a struct to manage remote config status with key.

type AgentSelector

type AgentSelector struct {
	IdentifyingAttributes    map[string]string `json:"identifyingAttributes"`
	NonIdentifyingAttributes map[string]string `json:"nonIdentifyingAttributes"`
}

AgentSelector defines the criteria for selecting agents to be included in the agent group.

type AgentSpec

type AgentSpec struct {
	NewInstanceUID      *bson.Binary           `bson:"newInstanceUID,omitempty"`
	RemoteConfig        *AgentSpecRemoteConfig `bson:"remoteConfig,omitempty"`
	RequiredRestartedAt bson.DateTime          `bson:"requiredRestartedAt,omitempty"`
}

AgentSpec represents the desired specification of an agent.

func (*AgentSpec) ToDomain

func (spec *AgentSpec) ToDomain() agentmodel.AgentSpec

ToDomain converts the AgentSpec to domain model.

type AgentSpecRemoteConfig

type AgentSpecRemoteConfig struct {
	ConfigMap          map[string]AgentConfigFile `bson:"configMap,omitempty"`
	LegacyRemoteConfig []string                   `bson:"remoteConfig,omitempty"`
}

AgentSpecRemoteConfig stores the remote config files materialised onto the agent's spec. Both name and content (Body/ContentType) are persisted so the next OpAMP response can reproduce the AgentRemoteConfig message even after a cache miss or server restart.

LegacyRemoteConfig holds the names-only array used by the pre-content schema. We still decode it so existing documents are not silently emptied on first read after upgrade — the names become placeholders so AgentGroup reconcile knows what to re-resolve. New writes only populate ConfigMap; LegacyRemoteConfig has `omitempty` so it never persists once a fresh write happens.

func AgentSpecRemoteConfigFromDomain

func AgentSpecRemoteConfigFromDomain(arc *agentmodel.AgentSpecRemoteConfig) *AgentSpecRemoteConfig

AgentSpecRemoteConfigFromDomain converts domain model to persistence model.

func (*AgentSpecRemoteConfig) ToDomain

ToDomain converts the AgentSpecRemoteConfig to domain model.

func (*AgentSpecRemoteConfig) ToDomainPtr

ToDomainPtr converts the AgentSpecRemoteConfig to domain model pointer.

type AgentStatus

type AgentStatus struct {
	EffectiveConfig     *AgentEffectiveConfig     `bson:"effectiveConfig,omitempty"`
	PackageStatuses     *AgentPackageStatuses     `bson:"packageStatuses,omitempty"`
	ComponentHealth     *AgentComponentHealth     `bson:"componentHealth,omitempty"`
	AvailableComponents *AgentAvailableComponents `bson:"availableComponents,omitempty"`
	RemoteConfigStatus  *AgentRemoteConfigStatus  `bson:"remoteConfigStatus,omitempty"`
	// Conditions stores agent conditions for informational purposes only.
	// WARNING: Do NOT use Conditions for MongoDB queries or aggregations.
	// The Conditions field can be null which causes MongoDB aggregation errors.
	// Use the following indexed fields instead:
	// - Connected (bool): for connection status queries
	// - ComponentHealth.Healthy (bool): for health status queries
	Conditions         []AgentCondition `bson:"conditions,omitempty"`
	Connected          bool             `bson:"connected,omitempty"`
	ConnectionType     string           `bson:"connectionType,omitempty"`
	SequenceNum        uint64           `bson:"sequenceNum,omitempty"`
	LastCommunicatedAt bson.DateTime    `bson:"lastCommunicatedAt,omitempty"`
	LastCommunicatedTo string           `bson:"lastCommunicatedTo,omitempty"`
}

AgentStatus represents the current status of an agent.

func (*AgentStatus) ToDomain

func (status *AgentStatus) ToDomain() agentmodel.AgentStatus

ToDomain converts the AgentStatus to domain model.

type BasicAuthCredential

type BasicAuthCredential struct {
	PasswordHash string `bson:"passwordHash"`
}

BasicAuthCredential represents a user's basic-auth password credential in MongoDB. The hash is sensitive server-side material and is never projected into API responses.

type Certificate

type Certificate struct {
	Common `bson:",inline"`

	Metadata CertificateMetadata `bson:"metadata"`
	Spec     CertificateSpec     `bson:"spec"`
	Status   CertificateStatus   `bson:"status"`
}

Certificate is the MongoDB entity for certificate.

func CertificateFromDomain

func CertificateFromDomain(domain *agentmodel.Certificate) *Certificate

CertificateFromDomain converts domain model to entity.

func (*Certificate) ToDomain

func (c *Certificate) ToDomain() *agentmodel.Certificate

ToDomain converts the entity to domain model.

type CertificateMetadata

type CertificateMetadata struct {
	Name       string            `bson:"name"`
	Namespace  string            `bson:"namespace"`
	Attributes map[string]string `bson:"attributes,omitempty"`
	CreatedAt  time.Time         `bson:"createdAt,omitempty"`
	DeletedAt  time.Time         `bson:"deletedAt,omitempty"`
}

CertificateMetadata represents the metadata of a certificate.

type CertificateSpec

type CertificateSpec struct {
	Cert       []byte `bson:"cert,omitempty"`
	PrivateKey []byte `bson:"privateKey,omitempty"`
	CaCert     []byte `bson:"caCert,omitempty"`
}

CertificateSpec represents the specification of a certificate.

type CertificateStatus

type CertificateStatus struct {
	Conditions []Condition `bson:"conditions,omitempty"`
}

CertificateStatus represents the status of a certificate.

type Common

type Common struct {
	// Version is the version of the entity's schema.
	Version Version `bson:"version"`

	// ID is the unique identifier of the entity.
	// It is used as the primary key in the database.
	// IT is used internally and as a continueToken for pagination.
	ID *bson.ObjectID `bson:"_id,omitempty"`
}

Common is a struct that contains common fields for all entities. All entities SHOULD embed this struct.

type ComponentDetails

type ComponentDetails struct {
	Metadata        map[string]string           `bson:"metadata"`
	SubComponentMap map[string]ComponentDetails `bson:"subComponentMap"`
}

ComponentDetails is a details of a component.

func ComponentDetailsFromDomain

func ComponentDetailsFromDomain(cd *agentmodel.ComponentDetails) *ComponentDetails

ComponentDetailsFromDomain converts domain model to persistence model.

func (*ComponentDetails) ToDomain

ToDomain converts the ComponentDetails to domain model.

type Condition

type Condition struct {
	Type               string        `bson:"type"`
	LastTransitionTime bson.DateTime `bson:"lastTransitionTime"`
	Status             string        `bson:"status"`
	Reason             string        `bson:"reason"`
	Message            string        `bson:"message,omitempty"`
}

Condition represents a condition of an agent group in MongoDB.

func NewConditionFromDomain

func NewConditionFromDomain(condition model.Condition) Condition

NewConditionFromDomain creates a new Condition from domain model.

func (*Condition) ToDomain

func (c *Condition) ToDomain() model.Condition

ToDomain converts Condition to domain model.

type ConnectionSettings

type ConnectionSettings struct {
	DestinationEndpoint string              `bson:"destinationEndpoint"       json:"destinationEndpoint"`
	Headers             map[string][]string `bson:"headers,omitempty"         json:"headers,omitempty"`
	CertificateName     *string             `bson:"certificateName,omitempty" json:"certificateName,omitempty"`
}

ConnectionSettings represents connection settings for telemetry.

type Container

type Container struct {
	Common `bson:",inline"`

	Metadata ContainerMetadata       `bson:"metadata"`
	Spec     ContainerSpec           `bson:"spec"`
	Status   ContainerResourceStatus `bson:"status"`
}

Container is the MongoDB entity for container.

func ContainerFromDomain

func ContainerFromDomain(domain *agentmodel.Container) *Container

ContainerFromDomain converts domain model to entity.

func (*Container) ToDomain

func (c *Container) ToDomain() *agentmodel.Container

ToDomain converts the entity to domain model.

type ContainerMetadata

type ContainerMetadata struct {
	ID          string            `bson:"id"`
	Name        string            `bson:"name,omitempty"`
	Labels      map[string]string `bson:"labels,omitempty"`
	Annotations map[string]string `bson:"annotations,omitempty"`
	FirstSeenAt time.Time         `bson:"firstSeenAt"`
	LastSeenAt  time.Time         `bson:"lastSeenAt"`
}

ContainerMetadata represents the metadata of a container.

type ContainerResourceStatus

type ContainerResourceStatus struct {
	AgentInstanceUIDs []string    `bson:"agentInstanceUids,omitempty"`
	Conditions        []Condition `bson:"conditions,omitempty"`
}

ContainerResourceStatus represents the status of a container resource.

type ContainerSpec

type ContainerSpec struct {
	Platform         string `bson:"platform"`
	ImageName        string `bson:"imageName,omitempty"`
	Runtime          string `bson:"runtime,omitempty"`
	HostID           string `bson:"hostId,omitempty"`
	K8sPodName       string `bson:"k8sPodName,omitempty"`
	K8sPodUID        string `bson:"k8sPodUid,omitempty"`
	K8sNamespaceName string `bson:"k8sNamespaceName,omitempty"`
	K8sNodeName      string `bson:"k8sNodeName,omitempty"`
	K8sContainerName string `bson:"k8sContainerName,omitempty"`
}

ContainerSpec represents the spec of a container.

type Host

type Host struct {
	Common `bson:",inline"`

	Metadata HostMetadata       `bson:"metadata"`
	Spec     HostSpec           `bson:"spec"`
	Status   HostResourceStatus `bson:"status"`
}

Host is the MongoDB entity for host.

func HostFromDomain

func HostFromDomain(domain *agentmodel.Host) *Host

HostFromDomain converts domain model to entity.

func (*Host) ToDomain

func (h *Host) ToDomain() *agentmodel.Host

ToDomain converts the entity to domain model.

type HostMetadata

type HostMetadata struct {
	ID          string            `bson:"id"`
	Name        string            `bson:"name,omitempty"`
	Labels      map[string]string `bson:"labels,omitempty"`
	Annotations map[string]string `bson:"annotations,omitempty"`
	FirstSeenAt time.Time         `bson:"firstSeenAt"`
	LastSeenAt  time.Time         `bson:"lastSeenAt"`
}

HostMetadata represents the metadata of a host.

type HostResourceStatus

type HostResourceStatus struct {
	AgentInstanceUIDs []string    `bson:"agentInstanceUids,omitempty"`
	Conditions        []Condition `bson:"conditions,omitempty"`
}

HostResourceStatus represents the status of a host resource.

type HostSpec

type HostSpec struct {
	Platform      string `bson:"platform"`
	Arch          string `bson:"arch,omitempty"`
	Type          string `bson:"type,omitempty"`
	OSType        string `bson:"osType,omitempty"`
	OSVersion     string `bson:"osVersion,omitempty"`
	CloudProvider string `bson:"cloudProvider,omitempty"`
	CloudPlatform string `bson:"cloudPlatform,omitempty"`
	CloudRegion   string `bson:"cloudRegion,omitempty"`
}

HostSpec represents the spec of a host.

type KeyValuePair

type KeyValuePair struct {
	Key   string `bson:"key"`
	Value string `bson:"value"`
}

KeyValuePair is a struct to manage key-value pairs.

type KeyValuePairs

type KeyValuePairs []KeyValuePair

KeyValuePairs is a slice of KeyValuePair.

func MapToKeyValuePairs

func MapToKeyValuePairs(input map[string]string) KeyValuePairs

MapToKeyValuePairs converts a map to KeyValuePairs.

func (KeyValuePairs) ToMap

func (kvs KeyValuePairs) ToMap() map[string]string

ToMap converts KeyValuePairs to a map.

type Namespace

type Namespace struct {
	Common `bson:",inline"`

	Metadata NamespaceMetadata       `bson:"metadata"`
	Status   NamespaceResourceStatus `bson:"status"`
}

Namespace is the MongoDB entity for namespace.

func NamespaceFromDomain

func NamespaceFromDomain(domain *agentmodel.Namespace) *Namespace

NamespaceFromDomain converts domain model to entity.

func (*Namespace) ToDomain

func (ns *Namespace) ToDomain() *agentmodel.Namespace

ToDomain converts the entity to domain model.

type NamespaceMetadata

type NamespaceMetadata struct {
	Name        string            `bson:"name"`
	Labels      map[string]string `bson:"labels,omitempty"`
	Annotations map[string]string `bson:"annotations,omitempty"`
	CreatedAt   time.Time         `bson:"createdAt"`
	DeletedAt   *time.Time        `bson:"deletedAt,omitempty"`
}

NamespaceMetadata represents the metadata of a namespace.

type NamespaceResourceStatus

type NamespaceResourceStatus struct {
	Conditions []Condition `bson:"conditions,omitempty"`
}

NamespaceResourceStatus represents the status of a namespace resource.

type Permission

type Permission struct {
	Common `bson:",inline"`

	Metadata PermissionMetadata `bson:"metadata"`
	Spec     PermissionSpec     `bson:"spec"`
	Status   PermissionStatus   `bson:"status"`
}

Permission is the MongoDB entity for permission.

func PermissionFromDomain

func PermissionFromDomain(domain *usermodel.Permission) *Permission

PermissionFromDomain converts domain model to entity.

func (*Permission) ToDomain

func (p *Permission) ToDomain() *usermodel.Permission

ToDomain converts the entity to domain model.

type PermissionMetadata

type PermissionMetadata struct {
	UID       string     `bson:"uid"`
	CreatedAt time.Time  `bson:"createdAt,omitempty"`
	UpdatedAt time.Time  `bson:"updatedAt,omitempty"`
	DeletedAt *time.Time `bson:"deletedAt,omitempty"`
}

PermissionMetadata represents the metadata of a permission.

type PermissionSpec

type PermissionSpec struct {
	Name        string `bson:"name"`
	Description string `bson:"description"`
	Resource    string `bson:"resource"`
	Action      string `bson:"action"`
	IsBuiltIn   bool   `bson:"isBuiltIn"`
}

PermissionSpec represents the specification of a permission.

type PermissionStatus

type PermissionStatus struct {
	Conditions []Condition `bson:"conditions,omitempty"`
}

PermissionStatus represents the status of a permission.

type Role

type Role struct {
	Common `bson:",inline"`

	Metadata RoleMetadata `bson:"metadata"`
	Spec     RoleSpec     `bson:"spec"`
	Status   RoleStatus   `bson:"status"`
}

Role is the MongoDB entity for role.

func RoleFromDomain

func RoleFromDomain(domain *usermodel.Role) *Role

RoleFromDomain converts domain model to entity.

func (*Role) ToDomain

func (r *Role) ToDomain() *usermodel.Role

ToDomain converts the entity to domain model.

type RoleBinding

type RoleBinding struct {
	Common `bson:",inline"`

	Metadata RoleBindingMetadata `bson:"metadata"`
	Spec     RoleBindingSpec     `bson:"spec"`
	Status   RoleBindingStatus   `bson:"status"`
}

RoleBinding is the MongoDB entity for a RoleBinding resource.

func RoleBindingFromDomain

func RoleBindingFromDomain(domain *usermodel.RoleBinding) *RoleBinding

RoleBindingFromDomain converts domain model to entity.

func (*RoleBinding) ToDomain

func (e *RoleBinding) ToDomain() *usermodel.RoleBinding

ToDomain converts the entity to domain model.

type RoleBindingMetadata

type RoleBindingMetadata struct {
	Namespace string     `bson:"namespace"`
	Name      string     `bson:"name"`
	CreatedAt time.Time  `bson:"createdAt"`
	UpdatedAt time.Time  `bson:"updatedAt"`
	DeletedAt *time.Time `bson:"deletedAt,omitempty"`
}

RoleBindingMetadata represents the metadata of a role binding.

type RoleBindingRoleRef

type RoleBindingRoleRef struct {
	Kind string `bson:"kind"`
	Name string `bson:"name"`
}

RoleBindingRoleRef references a role in MongoDB.

type RoleBindingSpec

type RoleBindingSpec struct {
	RoleRef  RoleBindingRoleRef   `bson:"roleRef"`
	Subjects []RoleBindingSubject `bson:"subjects,omitempty"`
}

RoleBindingSpec represents the specification of a role binding.

type RoleBindingStatus

type RoleBindingStatus struct {
	Conditions []Condition `bson:"conditions,omitempty"`
}

RoleBindingStatus represents the status of a role binding.

type RoleBindingSubject

type RoleBindingSubject struct {
	Kind       string `bson:"kind"`
	Name       string `bson:"name"`
	APIVersion string `bson:"apiVersion,omitempty"`
}

RoleBindingSubject references a principal that a RoleBinding grants its role to.

type RoleMetadata

type RoleMetadata struct {
	UID       string     `bson:"uid"`
	CreatedAt time.Time  `bson:"createdAt,omitempty"`
	UpdatedAt time.Time  `bson:"updatedAt,omitempty"`
	DeletedAt *time.Time `bson:"deletedAt,omitempty"`
}

RoleMetadata represents the metadata of a role.

type RoleSpec

type RoleSpec struct {
	DisplayName string   `bson:"displayName"`
	Description string   `bson:"description"`
	Permissions []string `bson:"permissions,omitempty"`
	IsBuiltIn   bool     `bson:"isBuiltIn"`
}

RoleSpec represents the specification of a role.

type RoleStatus

type RoleStatus struct {
	Conditions []Condition `bson:"conditions,omitempty"`
}

RoleStatus represents the status of a role.

type Server

type Server struct {
	// ID is the MongoDB ObjectID.
	ID *bson.ObjectID `bson:"_id,omitempty"`
	// ServerID is the unique identifier for the server.
	ServerID string `bson:"serverId"`
	// LastHeartbeatAt is the last time the server sent a heartbeat.
	LastHeartbeatAt time.Time `bson:"lastHeartbeatAt"`
	// Conditions is a list of conditions that apply to the server.
	Conditions []Condition `bson:"conditions,omitempty"`
}

Server represents a server entity in MongoDB.

func ToServerEntity

func ToServerEntity(server *agentmodel.Server) *Server

ToServerEntity converts a domain model to a Server entity.

func (*Server) ToDomainModel

func (s *Server) ToDomainModel() *agentmodel.Server

ToDomainModel converts the Server entity to a domain model.

type User

type User struct {
	Common `bson:",inline"`

	Metadata UserMetadata `bson:"metadata"`
	Spec     UserSpec     `bson:"spec"`
	Status   UserStatus   `bson:"status"`
}

User is the MongoDB entity for user.

func UserFromDomain

func UserFromDomain(domain *usermodel.User) *User

UserFromDomain converts domain model to entity.

func (*User) ToDomain

func (u *User) ToDomain() *usermodel.User

ToDomain converts the entity to domain model.

type UserIdentity

type UserIdentity struct {
	Provider       string `bson:"provider"`
	ProviderUserID string `bson:"providerUserId"`
	Email          string `bson:"email"`
	DisplayName    string `bson:"displayName"`
}

UserIdentity represents a linked external identity provider account in MongoDB.

type UserMetadata

type UserMetadata struct {
	UID       string            `bson:"uid"`
	CreatedAt time.Time         `bson:"createdAt,omitempty"`
	UpdatedAt time.Time         `bson:"updatedAt,omitempty"`
	DeletedAt *time.Time        `bson:"deletedAt,omitempty"`
	Labels    map[string]string `bson:"labels,omitempty"`
}

UserMetadata represents the metadata of a user.

type UserRole

type UserRole struct {
	Common `bson:",inline"`

	Metadata UserRoleMetadata `bson:"metadata"`
	Spec     UserRoleSpec     `bson:"spec"`
	Status   UserRoleStatus   `bson:"status"`
}

UserRole is the MongoDB entity for user role assignment.

func UserRoleFromDomain

func UserRoleFromDomain(domain *usermodel.UserRole) *UserRole

UserRoleFromDomain converts domain model to entity.

func (*UserRole) ToDomain

func (ur *UserRole) ToDomain() *usermodel.UserRole

ToDomain converts the entity to domain model.

type UserRoleMetadata

type UserRoleMetadata struct {
	UID       string     `bson:"uid"`
	CreatedAt time.Time  `bson:"createdAt,omitempty"`
	UpdatedAt time.Time  `bson:"updatedAt,omitempty"`
	DeletedAt *time.Time `bson:"deletedAt,omitempty"`
}

UserRoleMetadata represents the metadata of a user role assignment.

type UserRoleSpec

type UserRoleSpec struct {
	UserID     string    `bson:"userID"`
	RoleID     string    `bson:"roleID"`
	Namespace  string    `bson:"namespace"`
	AssignedAt time.Time `bson:"assignedAt"`
	AssignedBy string    `bson:"assignedBy"`
}

UserRoleSpec represents the specification of a user role assignment.

type UserRoleStatus

type UserRoleStatus struct {
	Conditions []Condition `bson:"conditions,omitempty"`
}

UserRoleStatus represents the status of a user role assignment.

type UserSpec

type UserSpec struct {
	Email      string               `bson:"email"`
	Username   string               `bson:"username"`
	IsActive   bool                 `bson:"isActive"`
	Identities []UserIdentity       `bson:"identities,omitempty"`
	BasicAuth  *BasicAuthCredential `bson:"basicAuth,omitempty"`
}

UserSpec represents the specification of a user.

type UserStatus

type UserStatus struct {
	Conditions []Condition `bson:"conditions,omitempty"`
	Roles      []string    `bson:"roles,omitempty"`
}

UserStatus represents the status of a user.

type Version

type Version int

Version represents the version of the entity's schema.

const (
	// VersionV1 is the initial version of the agent group.
	VersionV1 Version = 1
)

Jump to

Keyboard shortcuts

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