-
Notifications
You must be signed in to change notification settings - Fork 24
/
agent-info.go
51 lines (43 loc) · 1.34 KB
/
agent-info.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// +kubebuilder:validation:Optional
package agentinfo
import "github.com/fluxninja/aperture/pkg/config"
const (
configKey = "agent_info"
)
// swagger:operation POST /agent_info common-configuration AgentInfo
// ---
// parameters:
// - in: body
// schema:
// "$ref": "#/definitions/AgentInfoConfig"
// AgentInfoConfig is the configuration for the agent group and other agent attributes.
// swagger:model
// +kubebuilder:object:generate=true
type AgentInfoConfig struct {
// All agents within an agent_group receive the same data-plane configuration (e.g. Flux Meters, Rate Limiters etc).
//
// [Read more about agent groups here](/concepts/service.md#agent-group).
AgentGroup string `json:"agent_group" default:"default"`
}
// AgentInfo is the agent info.
type AgentInfo struct {
agentGroup string
}
// ProvideAgentInfo provides the agent info via Fx.
func ProvideAgentInfo(unmarshaller config.Unmarshaller) (*AgentInfo, error) {
var config AgentInfoConfig
if err := unmarshaller.UnmarshalKey(configKey, &config); err != nil {
return nil, err
}
return NewAgentInfo(config.AgentGroup), nil
}
// NewAgentInfo creates a new agent info.
func NewAgentInfo(agentGroup string) *AgentInfo {
return &AgentInfo{
agentGroup: agentGroup,
}
}
// GetAgentGroup returns the agent group.
func (a *AgentInfo) GetAgentGroup() string {
return a.agentGroup
}