helper

package
v0.1.40 Latest Latest
Warning

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

Go to latest
Published: May 31, 2026 License: MIT Imports: 10 Imported by: 0 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

Overview

Package helper provides helper functions for mapping between domain models and API models.

Index

Constants

View Source
const (
	// TextJSON is the content type for JSON.
	TextJSON = "text/json"
	// TextYAML is the content type for YAML.
	TextYAML = "text/yaml"
	// Empty is the content type for empty.
	// Empty content type is treated as YAML by default.
	// Due to spec miss, old otel-collector sends empty content type even though it should be YAML.
	Empty = ""
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Mapper

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

Mapper is a struct that provides methods to map between domain models and API models.

The injected clock is consulted for time-sensitive derivations (e.g. evaluating heartbeat-staleness for the Agent.Connected API field). Tests using mapped output for assertions can pass a fake clock for deterministic results.

connectionStaleness controls how long after an agent's LastReportedAt the API still treats it as connected. Operators tuning the OpAMP heartbeat interval should pass a value at least 2-3× their interval.

func NewMapper

func NewMapper(clk clock.PassiveClock, connectionStaleness time.Duration) *Mapper

NewMapper creates a new instance of Mapper. A nil clock falls back to k8s.io/utils/clock.RealClock so a misconfigured call site never crashes at MapAgentToAPI time — better to be visibly wrong than silently nil. A non-positive connectionStaleness falls back to agentmodel.DefaultConnectionStaleness.

func (*Mapper) MapAPIToAgent

func (mapper *Mapper) MapAPIToAgent(apiAgent *v1.Agent) *agentmodel.Agent

MapAPIToAgent maps an API model Agent to a domain model Agent.

func (*Mapper) MapAPIToAgentGroup

func (mapper *Mapper) MapAPIToAgentGroup(apiAgentGroup *v1.AgentGroup) *agentmodel.AgentGroup

MapAPIToAgentGroup maps an API model AgentGroup to a domain model AgentGroup.

func (*Mapper) MapAPIToAgentPackage added in v0.1.28

func (mapper *Mapper) MapAPIToAgentPackage(apiModel *v1.AgentPackage) *agentmodel.AgentPackage

MapAPIToAgentPackage maps an API model AgentPackage to a domain model AgentPackage.

func (*Mapper) MapAPIToAgentRemoteConfig added in v0.1.30

func (mapper *Mapper) MapAPIToAgentRemoteConfig(
	api *v1.AgentRemoteConfig,
) *agentmodel.AgentRemoteConfig

MapAPIToAgentRemoteConfig maps an API model AgentRemoteConfig to a domain model.

func (*Mapper) MapAPIToCertificate added in v0.1.28

func (mapper *Mapper) MapAPIToCertificate(api *v1.Certificate) *agentmodel.Certificate

MapAPIToCertificate maps an API model Certificate to a domain model Certificate.

func (*Mapper) MapAPIToNamespace added in v0.1.30

func (mapper *Mapper) MapAPIToNamespace(
	apiModel *v1.Namespace,
) *agentmodel.Namespace

MapAPIToNamespace maps an API Namespace to a domain Namespace.

func (*Mapper) MapAPIToRoleBinding added in v0.1.30

func (mapper *Mapper) MapAPIToRoleBinding(apiRB *v1.RoleBinding) *usermodel.RoleBinding

MapAPIToRoleBinding maps an API model RoleBinding to a domain model RoleBinding.

func (*Mapper) MapAgentGroupToAPI

func (mapper *Mapper) MapAgentGroupToAPI(domainAgentGroup *agentmodel.AgentGroup) *v1.AgentGroup

MapAgentGroupToAPI maps a domain model AgentGroup to an API model AgentGroup.

func (*Mapper) MapAgentPackageToAPI added in v0.1.28

func (mapper *Mapper) MapAgentPackageToAPI(agentPackage *agentmodel.AgentPackage) *v1.AgentPackage

MapAgentPackageToAPI maps a domain model AgentPackage to an API model AgentPackage.

func (*Mapper) MapAgentRemoteConfigToAPI added in v0.1.30

func (mapper *Mapper) MapAgentRemoteConfigToAPI(
	domain *agentmodel.AgentRemoteConfig,
) *v1.AgentRemoteConfig

MapAgentRemoteConfigToAPI maps a domain model AgentRemoteConfig to an API model.

func (*Mapper) MapAgentToAPI

func (mapper *Mapper) MapAgentToAPI(agent *agentmodel.Agent) *v1.Agent

MapAgentToAPI maps a domain model Agent to an API model Agent.

func (*Mapper) MapCertificateToAPI added in v0.1.28

func (mapper *Mapper) MapCertificateToAPI(domain *agentmodel.Certificate) *v1.Certificate

MapCertificateToAPI maps a domain model Certificate to an API model Certificate.

func (*Mapper) MapNamespaceToAPI added in v0.1.30

func (mapper *Mapper) MapNamespaceToAPI(
	namespace *agentmodel.Namespace,
) *v1.Namespace

MapNamespaceToAPI maps a domain Namespace to an API Namespace.

func (*Mapper) MapRoleBindingToAPI added in v0.1.30

func (mapper *Mapper) MapRoleBindingToAPI(domain *usermodel.RoleBinding) *v1.RoleBinding

MapRoleBindingToAPI maps a domain model RoleBinding to an API model RoleBinding.

func (*Mapper) MapRoleToAPI added in v0.1.30

func (mapper *Mapper) MapRoleToAPI(domain *usermodel.Role) *v1.Role

MapRoleToAPI maps a domain model Role to an API model Role.

func (*Mapper) MapUserToAPI added in v0.1.30

func (mapper *Mapper) MapUserToAPI(domain *usermodel.User) *v1.User

MapUserToAPI maps a domain model User to an API model User.

Jump to

Keyboard shortcuts

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