in internal/pkg/api/handleCheckin.go [706:774]
func convertActionData(aType ActionType, raw json.RawMessage) (ad Action_Data, err error) {
switch aType {
case CANCEL:
d := ActionCancel{}
err = json.Unmarshal(raw, &d)
if err != nil {
return
}
err = ad.FromActionCancel(d)
return
case INPUTACTION:
d := ActionInputAction{}
err = json.Unmarshal(raw, &d)
if err != nil {
return
}
err = ad.FromActionInputAction(d)
return
case POLICYREASSIGN:
d := ActionPolicyReassign{}
err = json.Unmarshal(raw, &d)
if err != nil {
return
}
err = ad.FromActionPolicyReassign(d)
return
case SETTINGS:
d := ActionSettings{}
err = json.Unmarshal(raw, &d)
if err != nil {
return
}
err = ad.FromActionSettings(d)
return
case UPGRADE:
d := ActionUpgrade{}
err = json.Unmarshal(raw, &d)
if err != nil {
return
}
err = ad.FromActionUpgrade(d)
return
case REQUESTDIAGNOSTICS:
d := ActionRequestDiagnostics{}
// NOTE: action data was added to diagnostics actions in #3333
// fleet ui creates actions without a data attribute and fleet-server needs to be backwards compatible with these actions.
if raw == nil {
return
}
err = json.Unmarshal(raw, &d)
if err != nil {
return
}
err = ad.FromActionRequestDiagnostics(d)
return
case UNENROLL: // Action types with no data
return ad, nil
case MIGRATE:
d := ActionMigrate{}
err = json.Unmarshal(raw, &d)
if err != nil {
return
}
err = ad.FromActionMigrate(d)
return
default:
return ad, fmt.Errorf("data conversion unsupported action type: %s", aType)
}
}