Skip to content

Commit 2104c45

Browse files
mauri870jlind23
andauthored
use Stringer to get values for eaclient Unit types (#5400)
Co-authored-by: Julien Lind <julien.lind@elastic.co>
1 parent f1ecf4d commit 2104c45

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

internal/pkg/agent/application/gateway/fleet/fleet_gateway.go

+4-20
Original file line numberDiff line numberDiff line change
@@ -231,31 +231,15 @@ func (f *FleetGateway) convertToCheckinComponents(components []runtime.Component
231231
return nil
232232
}
233233
stateString := func(s eaclient.UnitState) string {
234-
switch s {
235-
case eaclient.UnitStateStarting:
236-
return "STARTING"
237-
case eaclient.UnitStateConfiguring:
238-
return "CONFIGURING"
239-
case eaclient.UnitStateHealthy:
240-
return "HEALTHY"
241-
case eaclient.UnitStateDegraded:
242-
return fleetStateDegraded
243-
case eaclient.UnitStateFailed:
244-
return "FAILED"
245-
case eaclient.UnitStateStopping:
246-
return "STOPPING"
247-
case eaclient.UnitStateStopped:
248-
return "STOPPED"
234+
if state := s.String(); state != "UNKNOWN" {
235+
return state
249236
}
250237
return ""
251238
}
252239

253240
unitTypeString := func(t eaclient.UnitType) string {
254-
switch t {
255-
case eaclient.UnitTypeInput:
256-
return "input"
257-
case eaclient.UnitTypeOutput:
258-
return "output"
241+
if typ := t.String(); typ != "unknown" {
242+
return typ
259243
}
260244
return ""
261245
}

0 commit comments

Comments
 (0)