-
Notifications
You must be signed in to change notification settings - Fork 1
/
report.go
34 lines (29 loc) · 1.03 KB
/
report.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
package agent
import (
"github.com/datawire/ambassador-agent/pkg/api/agent"
diagnosticsTypes "github.com/emissary-ingress/emissary/v3/pkg/diagnostics/v1"
snapshotTypes "github.com/emissary-ingress/emissary/v3/pkg/snapshot/v1"
)
// GetIdentity returns the Agent's DCP Identity, if present, enabled, and
// configured by the user.
func GetIdentity(ambassadorMeta *snapshotTypes.AmbassadorMetaInfo, ambHost string) *agent.Identity {
if ambassadorMeta == nil || ambassadorMeta.ClusterID == "" {
// No Ambassador module -> no identity -> no reporting
return nil
}
return &agent.Identity{
ClusterId: ambassadorMeta.ClusterID,
Hostname: ambHost,
}
}
// GetIdentityFromDiagnostics returns the Agent's DCP Identity, if present.
func GetIdentityFromDiagnostics(ambSystem *diagnosticsTypes.System, ambHost string) *agent.Identity {
if ambSystem == nil || ambSystem.ClusterID == "" {
// No Ambassador module -> no identity -> no reporting
return nil
}
return &agent.Identity{
ClusterId: ambSystem.ClusterID,
Hostname: ambHost,
}
}