model

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2022 License: Apache-2.0 Imports: 28 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// LabelBindPlaneAgentID is the label name for agent id
	LabelBindPlaneAgentID = "bindplane/agent-id"

	// LabelBindPlaneAgentName is the label name for agent name
	LabelBindPlaneAgentName = "bindplane/agent-name"

	// LabelBindPlaneAgentType is the label for the agent type
	LabelBindPlaneAgentType = "bindplane/agent-type"

	// LabelBindPlaneAgentVersion is the label name for agent version
	LabelBindPlaneAgentVersion = "bindplane/agent-version"

	// LabelBindPlaneAgentHost is the label name for agent host
	LabelBindPlaneAgentHost = "bindplane/agent-host"

	// LabelBindPlaneAgentOS is the label name for agent operating system
	LabelBindPlaneAgentOS = "bindplane/agent-os"

	// LabelBindPlaneAgentArch is the label name for agent cpu architecture
	LabelBindPlaneAgentArch = "bindplane/agent-arch"
)
View Source
const (
	// MetadataName TODO(doc)
	MetadataName = "name"
	// MetadataID TODO(doc)
	MetadataID = "id"
)
View Source
const (
	// V1Alpha is the version for the initial resources defined for BindPlane
	V1Alpha = "bindplane.observiq.com/v1beta"
)

Variables

This section is empty.

Functions

func PrintResourceUpdates

func PrintResourceUpdates(writer io.Writer, resourceStatuses []*AnyResourceStatus)

PrintResourceUpdates TODO(doc)

func PrintableFieldValues

func PrintableFieldValues(p Printable) []string

PrintableFieldValues uses PrintableFieldTitles and PrintableFieldValue of the specified Printable to assemble the list of values to print

func PrintableFieldValuesForTitles

func PrintableFieldValuesForTitles(p Printable, titles []string) []string

PrintableFieldValuesForTitles uses PrintableFieldValue of the specified Printable to assemble the list of values to print for the specified titles

func SortAgentsByName

func SortAgentsByName(agents []*Agent)

SortAgentsByName TODO(doc)

Types

type Agent

type Agent struct {
	ID              string `json:"id" yaml:"id"`
	Name            string `json:"name" yaml:"name"`
	Type            string `json:"type" yaml:"type"`
	Architecture    string `json:"arch" yaml:"arch"`
	HostName        string `json:"hostname" yaml:"hostname"`
	Labels          Labels `json:"labels,omitempty" yaml:"labels"`
	Version         string `json:"version" yaml:"version"`
	Home            string `json:"home" yaml:"home"`
	Platform        string `json:"platform" yaml:"platform"`
	OperatingSystem string `json:"operatingSystem" yaml:"operatingSystem"`
	MacAddress      string `json:"macAddress" yaml:"macAddress"`
	RemoteAddress   string `json:"remoteAddress,omitempty" yaml:"remoteAddress,omitempty"`

	// SecretKey is provided by the agent to authenticate
	SecretKey string `json:"-" yaml:"-"`

	// reported by Status messages
	Status       AgentStatus `json:"status"`
	ErrorMessage string      `json:"errorMessage,omitempty" yaml:"errorMessage,omitempty"`

	// tracked by BindPlane
	Configuration  interface{} `json:"configuration,omitempty" yaml:"configuration,omitempty"`
	ConnectedAt    *time.Time  `json:"connectedAt,omitempty" yaml:"connectedAt,omitempty"`
	DisconnectedAt *time.Time  `json:"disconnectedAt,omitempty" yaml:"disconnectedAt,omitempty"`
}

Agent TODO(doc)

func (*Agent) Connect

func (a *Agent) Connect(newAgentVersion string)

Connect updates the ConnectedAt and DisconnectedAt fields of the agent and should be called when the agent connects.

func (*Agent) ConnectedDurationDisplayText

func (a *Agent) ConnectedDurationDisplayText() string

ConnectedDurationDisplayText TODO(doc)

func (*Agent) Disconnect

func (a *Agent) Disconnect()

Disconnect updates the DisconnectedAt and Status fields of the agent and should be called when the agent disconnects.

func (*Agent) DisconnectedDurationDisplayText

func (a *Agent) DisconnectedDurationDisplayText() string

DisconnectedDurationDisplayText TODO(doc) What RFC?

func (*Agent) DisconnectedSince

func (a *Agent) DisconnectedSince(since time.Time) bool

DisconnectedSince returns true if the agent has been disconnected since a given time.

func (*Agent) GetLabels

func (a *Agent) GetLabels() Labels

GetLabels implements the Labeled interface for Agents

func (*Agent) IndexFields

func (a *Agent) IndexFields(index search.Indexer)

IndexFields returns a map of field name to field value to be stored in the index

func (*Agent) IndexID

func (a *Agent) IndexID() string

IndexID returns an ID used to identify the resource that is indexed

func (*Agent) IndexLabels

func (a *Agent) IndexLabels(index search.Indexer)

IndexLabels returns a map of label name to label value to be stored in the index

func (*Agent) MatchesSelector

func (a *Agent) MatchesSelector(selector Selector) bool

MatchesSelector returns true if the given selector matches the agent's labels.

func (*Agent) PrintableFieldTitles

func (a *Agent) PrintableFieldTitles() []string

PrintableFieldTitles returns the list of field titles, used for printing a table of resources

func (*Agent) PrintableFieldValue

func (a *Agent) PrintableFieldValue(title string) string

PrintableFieldValue returns the field value for a title, used for printing a table of resources

func (*Agent) PrintableKindPlural

func (a *Agent) PrintableKindPlural() string

PrintableKindPlural returns the singular form of the Kind, e.g. "Agents"

func (*Agent) PrintableKindSingular

func (a *Agent) PrintableKindSingular() string

PrintableKindSingular returns the singular form of the Kind, e.g. "Agent"

func (*Agent) StatusDisplayText

func (a *Agent) StatusDisplayText() string

StatusDisplayText returns the string representation of the agent's status.

func (*Agent) UniqueKey

func (a *Agent) UniqueKey() string

UniqueKey returns the agent ID to uniquely identify an Agent

type AgentLabelsPayload

type AgentLabelsPayload struct {
	Labels map[string]string `json:"labels"`
}

AgentLabelsPayload is the REST API body for PATCH /v1/agents/{id}/labels

type AgentLabelsResponse

type AgentLabelsResponse struct {
	Errors []string `json:"errors"`
	Labels *Labels  `json:"labels"`
}

AgentLabelsResponse is the REST API response to GET /v1/agents/{id}/labels

type AgentResponse

type AgentResponse struct {
	Agent *Agent `json:"agent"`
}

AgentResponse is the REST API response to GET /v1/agent/:name

type AgentSelector

type AgentSelector struct {
	MatchLabels `json:"matchLabels" yaml:"matchLabels" mapstructure:"matchLabels"`
}

AgentSelector specifies a selector to use to match resources to agents

func (AgentSelector) Selector

func (s AgentSelector) Selector() Selector

Selector creates a Selector struct from an AgentSelector

type AgentStatus

type AgentStatus uint8

AgentStatus TODO(doc)

const (
	// Disconnected is the state of an agent that was formerly Connected to the management platform but is no longer
	// connected. This could mean that the agent has stopped running, the network connection has been interrupted, or that
	// the server terminated the connection.
	Disconnected AgentStatus = 0

	// Connected is the normal state of a healthy agent that is Connected to the management platform.
	Connected AgentStatus = 1

	// Error occurs if there is an error running or Configuring the agent.
	Error AgentStatus = 2

	// ComponentFailed is deprecated.
	ComponentFailed AgentStatus = 4

	// Deleted is set on a deleted Agent before notifying observers of the change.
	Deleted AgentStatus = 5

	// Configuring is set on an Agent when it is sent a new configuration that has not been applied. After successful
	// Configuring, it will transition back to Connected. If there is an error Configuring, it will transition to Error.
	Configuring AgentStatus = 6
)

type AgentsResponse

type AgentsResponse struct {
	Agents []*Agent `json:"agents"`
}

AgentsResponse is the REST API response to GET /v1/agents endpoint.

type AnyResource

type AnyResource struct {
	ResourceMeta `yaml:",inline" json:",inline" mapstructure:",squash"`
	Spec         map[string]interface{} `yaml:"spec" json:"spec" mapstructure:"spec"`
}

AnyResource is a resource not yet fully parsed and is the common structure of all Resources. The Spec, which is different for each kind of resource, is represented as a map[string]interface{} and can be further parsed using mapstructure. Use ParseResource or ParseResources to obtain a fully parsed Resource.

func ResourcesFromFile

func ResourcesFromFile(filename string) ([]*AnyResource, error)

ResourcesFromFile creates an io.Reader from reading the given file and uses unmarshalResources to return a slice of *AnyResource read from the file.

func ResourcesFromReader

func ResourcesFromReader(reader io.Reader) ([]*AnyResource, error)

ResourcesFromReader creates a yaml decoder from an io.Reader and returns a slice of *AnyResource and an error. If the decoder is able to reach the end of the reader with no error, err will be nil.

type AnyResourceStatus

type AnyResourceStatus struct {
	Resource AnyResource  `json:"resource" mapstructure:"resource"`
	Status   UpdateStatus `json:"status" mapstructure:"status"`
	Reason   string       `json:"reason" mapstructure:"reason"`
}

AnyResourceStatus TODO(doc) Same as ResourceStatus but used by cli to parse response from the rest api.

func (*AnyResourceStatus) Message

func (s *AnyResourceStatus) Message() string

Message returns the summary of the ResourceStatus, e.g. "exporter updated"

type ApplyPayload

type ApplyPayload struct {
	Resources []*AnyResource `json:"resources"`
}

ApplyPayload is the REST API body for POST /v1/apply

type ApplyResponse

type ApplyResponse struct {
	Updates []ResourceStatus `json:"updates"`
}

ApplyResponse is the REST API response to POST /v1/apply. This is used on the server side to return updates consisting of generic ResourceStatuses.

type ApplyResponseClientSide

type ApplyResponseClientSide struct {
	Updates []*AnyResourceStatus `json:"updates"`
}

ApplyResponseClientSide is the REST API Response. This is used on the client side where updates consists of AnyResourceStatuses.

type BulkAgentLabelsPayload

type BulkAgentLabelsPayload struct {
	IDs       []string          `json:"ids"`
	Labels    map[string]string `json:"labels"`
	Overwrite bool              `json:"overwrite"`
}

BulkAgentLabelsPayload is the REST API body for PATCH /v1/agents/labels

type BulkAgentLabelsResponse

type BulkAgentLabelsResponse struct {
	Errors []string `json:"errors"`
}

BulkAgentLabelsResponse is the REST API response to PATCH /v1/agents/labels

type Configuration

type Configuration struct {
	// ResourceMeta TODO(doc)
	ResourceMeta `yaml:",inline" json:",inline" mapstructure:",squash"`
	// Spec TODO(doc)
	Spec ConfigurationSpec `json:"spec" yaml:"spec" mapstructure:"spec"`
}

Configuration is the resource for the entire agent configuration

func NewConfiguration

func NewConfiguration(name string) *Configuration

NewConfiguration creates a new configuration with the specified name

func NewConfigurationWithSpec

func NewConfigurationWithSpec(name string, spec ConfigurationSpec) *Configuration

NewConfigurationWithSpec creates a new configuration with the specified name and spec

func NewRawConfiguration

func NewRawConfiguration(name string, raw string) *Configuration

NewRawConfiguration creates a new configuration with the specified name and raw configuration

func (*Configuration) AgentSelector

func (c *Configuration) AgentSelector() Selector

AgentSelector returns the Selector for this configuration that can be used to match this resource to agents.

func (*Configuration) GetKind

func (c *Configuration) GetKind() Kind

GetKind returns "Configuration"

func (*Configuration) IndexFields

func (c *Configuration) IndexFields(index search.Indexer)

IndexFields returns a map of field name to field value to be stored in the index

func (*Configuration) IsForAgent

func (c *Configuration) IsForAgent(agent *Agent) bool

IsForAgent returns true if this configuration matches a given agent's labels.

func (*Configuration) PrintableFieldTitles

func (c *Configuration) PrintableFieldTitles() []string

PrintableFieldTitles returns the list of field titles, used for printing a table of resources

func (*Configuration) PrintableFieldValue

func (c *Configuration) PrintableFieldValue(title string) string

PrintableFieldValue returns the field value for a title, used for printing a table of resources

func (*Configuration) Render

func (c *Configuration) Render(ctx context.Context, store ResourceStore) (string, error)

Render converts the Configuration model to a configuration that can be sent to an agent

func (*Configuration) Type

func (c *Configuration) Type() ConfigurationType

Type returns the ConfigurationType. It is based on the presence of the Raw, Sources, and Destinations fields.

func (*Configuration) Validate

func (c *Configuration) Validate() error

Validate validates most of the configuration, but if a store is available, ValidateWithStore should be used to validate the sources and destinations.

func (*Configuration) ValidateWithStore

func (c *Configuration) ValidateWithStore(store ResourceStore) error

ValidateWithStore checks that the configuration is valid, returning an error if it is not. It uses the store to retreive source types and destination types so that parameter values can be validated against the parameter defintions.

type ConfigurationResponse

type ConfigurationResponse struct {
	Configuration *Configuration `json:"configuration"`
	Raw           string         `json:"raw"`
}

ConfigurationResponse is the REST API response to GET /v1/configuration/:name

type ConfigurationSpec

type ConfigurationSpec struct {
	ContentType  string                  `json:"contentType" yaml:"contentType" mapstructure:"contentType"`
	Raw          string                  `json:"raw,omitempty" yaml:"raw,omitempty" mapstructure:"raw"`
	Sources      []ResourceConfiguration `json:"sources,omitempty" yaml:"sources,omitempty" mapstructure:"sources"`
	Destinations []ResourceConfiguration `json:"destinations,omitempty" yaml:"destinations,omitempty" mapstructure:"destinations"`
	Selector     AgentSelector           `json:"selector" yaml:"selector" mapstructure:"selector"`
}

ConfigurationSpec is the spec for a configuration resource

type ConfigurationType

type ConfigurationType string

ConfigurationType indicates the kind of configuration. It is based on the presence of the Raw, Sources, and Destinations fields.

const (
	// ConfigurationTypeRaw configurations have a configuration in the Raw field that is passed directly to the agent.
	ConfigurationTypeRaw ConfigurationType = "raw"

	// ConfigurationTypeModular configurations have Sources and Destinations that are used to generate the configuration to pass to an agent.
	ConfigurationTypeModular = "modular"
)

type ConfigurationsResponse

type ConfigurationsResponse struct {
	Configurations []*Configuration `json:"configurations"`
}

ConfigurationsResponse is the REST API response to GET /v1/configurations

type Context

type Context struct {
	// ResourceMeta TODO(doc)
	ResourceMeta `yaml:",inline" json:",inline" mapstructure:",squash"`
	// Spec TODO(doc)
	Spec ContextSpec `json:"spec" yaml:"spec,omitempty" mapstructure:"spec"`
}

Context TODO(doc)

func NewContext

func NewContext(name string, spec ContextSpec) *Context

NewContext rtakes a name and ContextSpec and returns a *Context.

func NewContextWithMetadata

func NewContextWithMetadata(metadata Metadata, spec ContextSpec) *Context

NewContextWithMetadata takes a Metadata and ContextSpec and returns a *Context.

type ContextSpec

type ContextSpec struct {
	// CurrentContext TODO(doc)
	CurrentContext string `json:"currentContext" yaml:"currentContext" mapstructure:"currentContext"`
}

ContextSpec TODO(doc)

type DeleteAgentsPayload

type DeleteAgentsPayload struct {
	IDs []string `json:"ids"`
}

DeleteAgentsPayload is the REST API body to DELETE /v1/agents

type DeleteAgentsResponse

type DeleteAgentsResponse = AgentsResponse

DeleteAgentsResponse is the REST API response to DELETE /v1/agents

type DeletePayload

type DeletePayload struct {
	Resources []*AnyResource `json:"resources"`
}

DeletePayload is the REST API body for POST /v1/delete. Though resources with full Spec can be included its only necessary for the Kind and Metadata.Name fields to be present.

type DeleteResponse

type DeleteResponse struct {
	Errors  []string         `json:"errors"`
	Updates []ResourceStatus `json:"updates"`
}

DeleteResponse is the REST API response to POST /v1/delete

type DeleteResponseClientSide

type DeleteResponseClientSide struct {
	Errors  []string             `json:"errors"`
	Updates []*AnyResourceStatus `json:"updates"`
}

DeleteResponseClientSide is the REST API response to POST /v1/delete

type Destination

type Destination struct {
	// ResourceMeta TODO(doc)
	ResourceMeta `yaml:",inline" json:",inline" mapstructure:",squash"`
	// Spec TODO(doc)
	Spec ParameterizedSpec `json:"spec" yaml:"spec" mapstructure:"spec"`
}

Destination will generate an exporter and be at the end of a pipeline

func FindDestination

func FindDestination(destination *ResourceConfiguration, defaultName string, store ResourceStore) (*Destination, error)

FindDestination returns a Destination from the store if it exists. If it doesn't exist, it creates a new Destination with the specified defaultName.

func NewDestination

func NewDestination(name string, typeValue string, parameters []Parameter) *Destination

NewDestination creates a new Destination with the specified name, type, and parameters

func NewDestinationWithSpec

func NewDestinationWithSpec(name string, spec ParameterizedSpec) *Destination

NewDestinationWithSpec creates a new Destination with the specified spec

func (*Destination) ComponentID

func (d *Destination) ComponentID(name string) otel.ComponentID

ComponentID provides a unique component id for the specified component name

func (*Destination) GetKind

func (d *Destination) GetKind() Kind

GetKind returns "Destination"

func (*Destination) PrintableFieldTitles

func (d *Destination) PrintableFieldTitles() []string

PrintableFieldTitles returns the list of field titles, used for printing a table of resources

func (*Destination) PrintableFieldValue

func (d *Destination) PrintableFieldValue(title string) string

PrintableFieldValue returns the field value for a title, used for printing a table of resources

func (*Destination) ResourceParameters

func (d *Destination) ResourceParameters() []Parameter

ResourceParameters are the parameters passed to the ResourceType to generate the configuration

func (*Destination) ResourceTypeName

func (d *Destination) ResourceTypeName() string

ResourceTypeName is the name of the ResourceType that renders this resource type

func (*Destination) ValidateWithStore

func (d *Destination) ValidateWithStore(store ResourceStore) error

ValidateWithStore checks that the destination is valid, returning an error if it is not. It uses the store to retreive the destination type so that parameter values can be validated against the parameter defintions.

type DestinationResponse

type DestinationResponse struct {
	Destination *Destination `json:"destination"`
}

DestinationResponse is the REST API response to GET /v1/destinations/:name

type DestinationType

type DestinationType struct {
	ResourceType `yaml:",inline" json:",inline" mapstructure:",squash"`
}

DestinationType is a ResourceType used to define destinations

func NewDestinationType

func NewDestinationType(name string, parameters []ParameterDefinition) *DestinationType

NewDestinationType creates a new sourtype with the specified name,

func NewDestinationTypeWithSpec

func NewDestinationTypeWithSpec(name string, spec ResourceTypeSpec) *DestinationType

NewDestinationTypeWithSpec creates a new sourtype with the specified name and spec.

func (*DestinationType) GetKind

func (d *DestinationType) GetKind() Kind

GetKind returns "DestinationType"

type DestinationTypeResponse

type DestinationTypeResponse struct {
	DestinationType *DestinationType `json:"destinationType"`
}

DestinationTypeResponse is the REST API response to GET /v1/destinationType/:name

type DestinationTypesResponse

type DestinationTypesResponse struct {
	DestinationTypes []*DestinationType `json:"destinationTypes"`
}

DestinationTypesResponse is the REST API response to GET /v1/destinationTypes

type DestinationsResponse

type DestinationsResponse struct {
	Destinations []*Destination `json:"destinations"`
}

DestinationsResponse is the REST API response to GET /v1/destinations

type HasAgentSelector

type HasAgentSelector interface {
	// AgentSelector TODO(docs)
	AgentSelector() Selector
	IsForAgent(agent *Agent) bool
}

HasAgentSelector TODO(docs)

type HasUniqueKey

type HasUniqueKey interface {
	UniqueKey() string
}

HasUniqueKey is an interface that provides access to a unique key for an item. For Agents this is the ID and for Resources this is the Name.

type InstallCommandResponse

type InstallCommandResponse struct {
	Command string `json:"command"`
}

InstallCommandResponse is the REST API response to GET /v1/agent-versions/{version}/install-command

type Kind

type Kind string

Kind indicates the kind of resource, e.g. Configuration

const (
	KindProfile         Kind = "Profile"
	KindContext         Kind = "Context"
	KindConfiguration   Kind = "Configuration"
	KindAgent           Kind = "Agent"
	KindSource          Kind = "Source"
	KindDestination     Kind = "Destination"
	KindSourceType      Kind = "SourceType"
	KindDestinationType Kind = "DestinationType"
	KindUnknown         Kind = "Unknown"
)

Kind values correspond to the kinds of resources currently supported by BindPlane

func ParseKind

func ParseKind(kind string) Kind

ParseKind parses a kind from a specified string parameter, validating that it matches an existing kind. It ignores the case of the string parameter and also allows plurals, e.g. configurations => KindConfiguration. KindUnknown is returned if that specified kind does not match any known Kinds.

type Labeled

type Labeled interface {
	// GetLabels TODO(doc)
	GetLabels() Labels
}

Labeled TODO(doc)

type Labels

type Labels struct {
	labels.Set `json:"-" yaml:",inline"`
}

Labels is a wrapper around Kubernetes labels.Set struct, which is just a type definition for map[string]string.

func LabelsFromMap

func LabelsFromMap(labels map[string]string) (Labels, error)

LabelsFromMap will create a set of labels from a map of name/value pairs. It will validate that the names and values conform to the requirements, matching those of kubernetes labels. See https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/. Valid labels will be added to the Labels returned and any invalid labels will produce an error. This makes it possible for callers to ignore the errors and accept any valid values specified.

func LabelsFromMerge

func LabelsFromMerge(l Labels, o Labels) Labels

LabelsFromMerge TODO(doc)

func LabelsFromSelector

func LabelsFromSelector(selector string) (Labels, error)

LabelsFromSelector TODO(doc)

func LabelsFromValidatedMap

func LabelsFromValidatedMap(labels map[string]string) Labels

LabelsFromValidatedMap returns a set of labels from map that is assumed to already be validated.

func MakeLabels

func MakeLabels() Labels

MakeLabels TODO(doc)

func (*Labels) AsMap

func (l *Labels) AsMap() map[string]string

AsMap returns the labels as a map of name/value pairs

func (Labels) BindPlane

func (l Labels) BindPlane() Labels

BindPlane returns the BindPlane labels, i.e. labels starting with "bindplane/"

func (Labels) Conflicts

func (l Labels) Conflicts(o Labels) bool

Conflicts returns true if the specified set of labels has a label with the same name as this set of labels but with a differnet value.

func (Labels) Custom

func (l Labels) Custom() Labels

Custom returns the custom labels, i.e. labels not starting with "bindplane/"

func (*Labels) MarshalJSON

func (l *Labels) MarshalJSON() ([]byte, error)

MarshalJSON TODO(doc )

func (*Labels) UnmarshalJSON

func (l *Labels) UnmarshalJSON(b []byte) error

UnmarshalJSON TODO(doc)

type MatchLabels

type MatchLabels map[string]string

MatchLabels represents the labels used to match Pipelines with Agents.

type Metadata

type Metadata struct {
	ID          string `yaml:"id,omitempty" json:"id" mapstructure:"id"`
	Name        string `yaml:"name,omitempty" json:"name" mapstructure:"name"`
	DisplayName string `yaml:"displayName,omitempty" json:"displayName,omitempty" mapstructure:"displayName"`
	Description string `yaml:"description,omitempty" json:"description,omitempty" mapstructure:"description"`
	Icon        string `yaml:"icon,omitempty" json:"icon,omitempty" mapstructure:"icon"`
	Labels      Labels `yaml:"labels,omitempty" json:"labels" mapstructure:"labels"`
}

Metadata TODO(doc)

type Parameter

type Parameter struct {
	Name string `json:"name" yaml:"name" mapstructure:"name"`
	// This could be any of the following: string, bool, int, enum (string), float, []string
	Value interface{} `json:"value" yaml:"value" mapstructure:"value"`
}

Parameter TODO(doc)

type ParameterDefinition

type ParameterDefinition struct {
	Name        string `json:"name" yaml:"name"`
	Label       string `json:"label" yaml:"label"`
	Description string `json:"description" yaml:"description"`
	Required    bool   `json:"required" yaml:"required"`

	// "string", "int", "bool", "strings", or "enum"
	Type string `json:"type" yaml:"type"`

	// only useable if Type == "enum"
	ValidValues []string `json:"validValues,omitempty" yaml:"validValues,omitempty" mapstructure:"validValues"`

	// Must be valid according to Type & ValidValues
	Default        interface{}           `json:"default,omitempty" yaml:"default,omitempty"`
	RelevantIf     []RelevantIfCondition `json:"relevantIf,omitempty" yaml:"relevantIf,omitempty" mapstructure:"relevantIf"`
	Hidden         bool                  `json:"hidden" yaml:"hidden"`
	AdvancedConfig bool                  `json:"advancedConfig" yaml:"advancedConfig" mapstructure:"advancedConfig"`
}

ParameterDefinition is a basic description of a definition's parameter. This implementation comes directly from stanza plugin parameters with slight modifications for mapstructure.

type ParameterizedSpec

type ParameterizedSpec struct {
	Type       string      `yaml:"type" json:"type" mapstructure:"type"`
	Parameters []Parameter `yaml:"parameters" json:"parameters" mapstructure:"parameters"`
}

ParameterizedSpec is the spec for a ParamaterizedResource

type PostAgentVersionRequest

type PostAgentVersionRequest struct {
	Version string `json:"version"`
}

PostAgentVersionRequest is the REST API body for POST /v1/agents/{id}/version

type Printable

type Printable interface {
	// PrintableKindSingular returns the singular form of the Kind, e.g. "Configuration"
	PrintableKindSingular() string

	// PrintableKindPlural returns the plural form of the Kind, e.g. "Configurations"
	PrintableKindPlural() string

	// PrintableFieldTitles returns the list of field titles, used for printing a table of resources
	PrintableFieldTitles() []string

	// PrintableFieldValue returns the field value for a title, used for printing a table of resources
	PrintableFieldValue(title string) string
}

Printable is implemented for resources so that they can be printed by the CLI.

type Profile

type Profile struct {
	ResourceMeta `yaml:",inline" json:",inline" mapstructure:",squash"`
	Spec         ProfileSpec `json:"spec" yaml:"spec" mapstructure:"spec"`
}

Profile TODO(doc)

func NewProfile

func NewProfile(name string, spec ProfileSpec) *Profile

NewProfile takes a name and ProfileSpec and returns a *Profile.

func NewProfileWithMetadata

func NewProfileWithMetadata(metadata Metadata, spec ProfileSpec) *Profile

NewProfileWithMetadata takes a Metadata and ProfileSpec and returns a *Profile.

type ProfileSpec

type ProfileSpec struct {
	common.Common  `mapstructure:",squash" yaml:",inline,omitempty"`
	common.Server  `mapstructure:"server" yaml:"server,omitempty"`
	common.Client  `mapstructure:"client" yaml:"client,omitempty"`
	common.Command `mapstructure:"command" yaml:"command,omitempty"`
}

ProfileSpec TODO(doc)

type RelevantIfCondition

type RelevantIfCondition struct {
	Name     string `json:"name" yaml:"name" mapstructure:"name"`
	Operator string `json:"operator" yaml:"operator" mapstructure:"operator"`
	Value    any    `json:"value" yaml:"value" mapstructure:"value"`
}

RelevantIfCondition specifies a condition under which a parameter is deemed relevant.

type Resource

type Resource interface {
	// all resources can be labeled
	Labeled

	// all resources can be indexed
	search.Indexed

	// all resources have a unique key
	HasUniqueKey

	// ID returns the uuid for this resource
	ID() string

	// SetID replaces the uuid for this resource
	SetID(id string)

	// EnsureID generates a new uuid for a resource if none exists
	EnsureID()

	// Name returns the name for this resource
	Name() string

	// GetKind returns the Kind of this resource
	GetKind() Kind

	// Description returns a description of the resource
	Description() string

	// Validate ensures that the resource is valid
	Validate() error

	// ValidateWithStore ensures that the resource is valid and allows for extra validation given a store
	ValidateWithStore(store ResourceStore) error
}

Resource is implemented by all resources, e.g. SourceType, DestinationType, Configuration, etc.

func NewEmptyResource

func NewEmptyResource(kind Kind) (Resource, error)

NewEmptyResource will return a zero value struct for the given resource kind.

func ParseResource

func ParseResource(r *AnyResource) (Resource, error)

ParseResource maps the Spec of the provided resource to a specific type of Resource

func ParseResources

func ParseResources(resources []*AnyResource) ([]Resource, error)

ParseResources TODO(doc)

type ResourceConfiguration

type ResourceConfiguration struct {
	Name       string      `json:"name,omitempty" yaml:"name,omitempty" mapstructure:"name"`
	Type       string      `json:"type,omitempty" yaml:"type,omitempty" mapstructure:"type"`
	Parameters []Parameter `json:"parameters,omitempty" yaml:"parameters,omitempty" mapstructure:"parameters"`
}

ResourceConfiguration represents a source or destination configuration

type ResourceMeta

type ResourceMeta struct {
	APIVersion string   `yaml:"apiVersion,omitempty" json:"apiVersion"`
	Kind       Kind     `yaml:"kind,omitempty" json:"kind"`
	Metadata   Metadata `yaml:"metadata,omitempty" json:"metadata"`
}

ResourceMeta TODO(doc)

func (*ResourceMeta) Description

func (r *ResourceMeta) Description() string

Description returns the description.

func (*ResourceMeta) EnsureID

func (r *ResourceMeta) EnsureID()

EnsureID sets the ID to a random uuid if not already set.

func (*ResourceMeta) GetKind

func (r *ResourceMeta) GetKind() Kind

GetKind returns the Kind of this resource.

func (*ResourceMeta) GetLabels

func (r *ResourceMeta) GetLabels() Labels

GetLabels implements the Labeled interface for Agents

func (*ResourceMeta) ID

func (r *ResourceMeta) ID() string

ID returns the ID

func (*ResourceMeta) IndexFields

func (r *ResourceMeta) IndexFields(index search.Indexer)

IndexFields returns a map of field name to field value to be stored in the index

func (*ResourceMeta) IndexID

func (r *ResourceMeta) IndexID() string

IndexID returns an ID used to identify the resource that is indexed

func (*ResourceMeta) IndexLabels

func (r *ResourceMeta) IndexLabels(index search.Indexer)

IndexLabels returns a map of label name to label value to be stored in the index

func (*ResourceMeta) Name

func (r *ResourceMeta) Name() string

Name returns the name.

func (*ResourceMeta) PrintableFieldTitles

func (r *ResourceMeta) PrintableFieldTitles() []string

PrintableFieldTitles returns the list of field titles, used for printing a table of resources

func (*ResourceMeta) PrintableFieldValue

func (r *ResourceMeta) PrintableFieldValue(title string) string

PrintableFieldValue returns the field value for a title, used for printing a table of resources

func (*ResourceMeta) PrintableKindPlural

func (r *ResourceMeta) PrintableKindPlural() string

PrintableKindPlural returns the plural form of the Kind, e.g. "Configurations"

func (*ResourceMeta) PrintableKindSingular

func (r *ResourceMeta) PrintableKindSingular() string

PrintableKindSingular returns the singular form of the Kind, e.g. "Configuration"

func (*ResourceMeta) SetID

func (r *ResourceMeta) SetID(id string)

SetID replaces the uuid for this resource

func (*ResourceMeta) UniqueKey

func (r *ResourceMeta) UniqueKey() string

UniqueKey returns the resource Name to uniquely identify a resource

func (*ResourceMeta) Validate

func (r *ResourceMeta) Validate() error

Validate checks that the resource is valid, returning an error if it is not. This provides generic validation for all resources. Specific resources should provide their own Validate method and call this to validate the ResourceMeta.

func (*ResourceMeta) ValidateWithStore

func (r *ResourceMeta) ValidateWithStore(store ResourceStore) error

ValidateWithStore allows for additional validation when a store is available.

type ResourceStatus

type ResourceStatus struct {
	// Resource TODO(doc)
	Resource Resource `json:"resource" mapstructure:"resource"`
	// Status TODO(doc)
	Status UpdateStatus `json:"status" mapstructure:"status"`
	// Reason will be set if status is invalid or error
	Reason string `json:"reason" mapstructure:"reason"`
}

ResourceStatus contains a resource and its status after an update, which is of type UpdateStatus used in store and rest packages.

func NewResourceStatus

func NewResourceStatus(r Resource, s UpdateStatus) *ResourceStatus

NewResourceStatus TODO(doc)

func NewResourceStatusWithReason

func NewResourceStatusWithReason(r Resource, s UpdateStatus, reason string) *ResourceStatus

NewResourceStatusWithReason returns a status for an invalid resource

type ResourceStore

type ResourceStore interface {
	Source(name string) (*Source, error)
	SourceType(name string) (*SourceType, error)
	Destination(name string) (*Destination, error)
	DestinationType(name string) (*DestinationType, error)
}

ResourceStore provides access to resources required to render configurations that use Sources and Destinations.

type ResourceType

type ResourceType struct {
	ResourceMeta `yaml:",inline" json:",inline" mapstructure:",squash"`
	Spec         ResourceTypeSpec `json:"spec" yaml:"spec" mapstructure:"spec"`
}

ResourceType is a resource that describes a type of resource including parameters for creating that resource and a template for formatting the resource configuration.

There will be separate ResourceTypes for each type of resource, e.g. SourceType for Source resources.

func (*ResourceType) PrintableFieldTitles

func (rt *ResourceType) PrintableFieldTitles() []string

PrintableFieldTitles returns the list of field titles, used for printing a table of resources

func (*ResourceType) Validate

func (rt *ResourceType) Validate() error

Validate returns an error if any part of the ResourceType is invalid

func (*ResourceType) ValidateWithStore

func (rt *ResourceType) ValidateWithStore(store ResourceStore) error

ValidateWithStore returns an error if any part of the ResourceType is invalid

type ResourceTypeOutput

type ResourceTypeOutput struct {
	Receivers  ResourceTypeTemplate `json:"receivers,omitempty"  yaml:"receivers,omitempty"  mapstructure:"receivers"`
	Processors ResourceTypeTemplate `json:"processors,omitempty" yaml:"processors,omitempty" mapstructure:"processors"`
	Exporters  ResourceTypeTemplate `json:"exporters,omitempty"  yaml:"exporters,omitempty"  mapstructure:"exporters"`
	Extensions ResourceTypeTemplate `json:"extensions,omitempty" yaml:"extensions,omitempty" mapstructure:"extensions"`
}

ResourceTypeOutput describes the output of the resource type

func (ResourceTypeOutput) Empty

func (s ResourceTypeOutput) Empty() bool

Empty returns true if Receivers, Processors, Exporters, and Extensions are the zero value ""

type ResourceTypeSpec

type ResourceTypeSpec struct {
	Version string `json:"version" yaml:"version" mapstructure:"version"`

	// Parameters currently uses the model from stanza. Eventually we will probably create a separate definition for
	// BindPlane.
	Parameters         []ParameterDefinition `json:"parameters"  yaml:"parameters"  mapstructure:"parameters"`
	SupportedPlatforms []string              `json:"supportedPlatforms" yaml:"supportedPlatforms" mapstructure:"supportedPlatforms"`

	// individual
	Logs    ResourceTypeOutput `json:"logs,omitempty"    yaml:"logs,omitempty"    mapstructure:"logs"`
	Metrics ResourceTypeOutput `json:"metrics,omitempty" yaml:"metrics,omitempty" mapstructure:"metrics"`
	Traces  ResourceTypeOutput `json:"traces,omitempty"  yaml:"traces,omitempty"  mapstructure:"traces"`

	// pairs (alphabetical order)
	LogsMetrics   ResourceTypeOutput `json:"logs+metrics,omitempty"   yaml:"logs+metrics,omitempty"   mapstructure:"logs+metrics"`
	LogsTraces    ResourceTypeOutput `json:"logs+traces,omitempty"    yaml:"logs+traces,omitempty"    mapstructure:"logs+traces"`
	MetricsTraces ResourceTypeOutput `json:"metrics+traces,omitempty" yaml:"metrics+traces,omitempty" mapstructure:"metrics+traces"`

	// all three (alphabetical order)
	LogsMetricsTraces ResourceTypeOutput `json:"logs+metrics+traces,omitempty" yaml:"logs+metrics+traces,omitempty" mapstructure:"logs+metrics+traces"`
}

ResourceTypeSpec is the spec for a resourceType to

func (*ResourceTypeSpec) ParameterDefinition

func (s *ResourceTypeSpec) ParameterDefinition(name string) *ParameterDefinition

ParameterDefinition returns the ParameterDefinition with the specified name or nil if no such parameter exists

func (*ResourceTypeSpec) TelemetryTypes

func (s *ResourceTypeSpec) TelemetryTypes() []otel.PipelineType

TelemetryTypes returns the supported telemetry types (logs, metrics, or traces). Only applicable to SourceTypes.

type ResourceTypeTemplate

type ResourceTypeTemplate string

ResourceTypeTemplate is a go-template that evaluates to an array of OpenTelemetry resources

type Selector

type Selector struct {
	labels.Selector
}

Selector TODO(docs)

func EmptySelector

func EmptySelector() Selector

EmptySelector returns a Selector that has no labels and matches nothing

func EverythingSelector

func EverythingSelector() Selector

EverythingSelector returns a Selector that matches everything

func SelectorFromMap

func SelectorFromMap(m map[string]string) (Selector, error)

SelectorFromMap takes a map[string]string and returns a Selector and error.

func SelectorFromString

func SelectorFromString(selector string) (Selector, error)

SelectorFromString takes a string and returns a Selector and error

func (*Selector) MatchLabels

func (s *Selector) MatchLabels() (labels MatchLabels, complete bool)

MatchLabels returns the portion of the Selector that consists of simple name=value label matches. A Selector supports more complex selection and this should only be used in cases where Matches() would have terrible performance and partial selection is ok. This will return false for complete if there are selectors requirements that cannot be expressed with match labels.

type Source

type Source struct {
	// ResourceMeta TODO(doc)
	ResourceMeta `yaml:",inline" json:",inline" mapstructure:",squash"`
	// Spec TODO(doc)
	Spec ParameterizedSpec `json:"spec" yaml:"spec" mapstructure:"spec"`
}

Source will generate an exporter and be at the end of a pipeline

func FindSource

func FindSource(source *ResourceConfiguration, defaultName string, store ResourceStore) (*Source, error)

FindSource returns a Source from the store if it exists. If it doesn't exist, it creates a new Source with the specified defaultName.

func NewSource

func NewSource(name string, sourceTypeName string, parameters []Parameter) *Source

NewSource creates a new Source with the specified name, type, and parameters

func NewSourceWithSpec

func NewSourceWithSpec(name string, spec ParameterizedSpec) *Source

NewSourceWithSpec creates a new Source with the specified spec

func (*Source) ComponentID

func (s *Source) ComponentID(name string) otel.ComponentID

ComponentID provides a unique component id for the specified component name

func (*Source) GetKind

func (s *Source) GetKind() Kind

GetKind returns "Source"

func (*Source) PrintableFieldTitles

func (s *Source) PrintableFieldTitles() []string

PrintableFieldTitles returns the list of field titles, used for printing a table of resources

func (*Source) PrintableFieldValue

func (s *Source) PrintableFieldValue(title string) string

PrintableFieldValue returns the field value for a title, used for printing a table of resources

func (*Source) ResourceParameters

func (s *Source) ResourceParameters() []Parameter

ResourceParameters are the parameters passed to the ResourceType to generate the configuration

func (*Source) ResourceTypeName

func (s *Source) ResourceTypeName() string

ResourceTypeName is the name of the ResourceType that renders this resource type

func (*Source) ValidateWithStore

func (s *Source) ValidateWithStore(store ResourceStore) error

ValidateWithStore checks that the source is valid, returning an error if it is not. It uses the store to retreive the source type so that parameter values can be validated against the parameter defintions.

type SourceResponse

type SourceResponse struct {
	Source *Source `json:"source"`
}

SourceResponse is the REST API response to GET /v1/sources/:name

type SourceType

type SourceType struct {
	ResourceType `yaml:",inline" json:",inline" mapstructure:",squash"`
}

SourceType is a ResourceType used to define sources

func NewSourceType

func NewSourceType(name string, parameters []ParameterDefinition) *SourceType

NewSourceType creates a new sourtype with the specified name,

func NewSourceTypeWithSpec

func NewSourceTypeWithSpec(name string, spec ResourceTypeSpec) *SourceType

NewSourceTypeWithSpec creates a new sourtype with the specified name and spec.

func (*SourceType) GetKind

func (s *SourceType) GetKind() Kind

GetKind returns "SourceType"

type SourceTypeResponse

type SourceTypeResponse struct {
	SourceType *SourceType `json:"sourceType"`
}

SourceTypeResponse is the REST API response to GET /v1/sourceType/:name

type SourceTypesResponse

type SourceTypesResponse struct {
	SourceTypes []*SourceType `json:"sourceTypes"`
}

SourceTypesResponse is the REST API response to GET /v1/sourceTypes

type SourcesResponse

type SourcesResponse struct {
	Sources []*Source `json:"sources"`
}

SourcesResponse is the REST API response to GET /v1/sources

type TemplateErrorHandler

type TemplateErrorHandler func(error)

TemplateErrorHandler handles errors during template evaluation. Typically these will be logged but they could be accumulated and reported to the user.

type UpdateStatus

type UpdateStatus string

UpdateStatus is part of ResourceStatus that indicates the result of ApplyResources and DeleteResources on the Store.

const (
	// StatusUnchanged indicates that there were no changes to a modified resource because the existing resource is the same
	StatusUnchanged UpdateStatus = "unchanged"

	// StatusConfigured indicates that changes were applied to an existing resource
	StatusConfigured UpdateStatus = "configured"

	// StatusCreated indicates that a new resource was created
	StatusCreated UpdateStatus = "created"

	// StatusDeleted indicates that a resource was deleted, either from the store or the current filtered view of resources
	StatusDeleted UpdateStatus = "deleted"

	// StatusInvalid represents an attempt to add or update a resource with an invalid resource
	StatusInvalid UpdateStatus = "invalid"

	// StatusError is used when an individual resource cannot be applied because of an error
	StatusError UpdateStatus = "error"

	// StatusInUse is used when attempting to delete a resource that is being referenced by another
	StatusInUse UpdateStatus = "in-use"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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