diff --git a/api/server/router/system/system_routes.go b/api/server/router/system/system_routes.go index 56839b883c..c7902e1f9a 100644 --- a/api/server/router/system/system_routes.go +++ b/api/server/router/system/system_routes.go @@ -67,24 +67,16 @@ func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *ht version := httputils.VersionFromContext(ctx) if versions.LessThan(version, "1.25") { // TODO: handle this conversion in engine-api - type oldInfo struct { - *types.Info - ExecutionDriver string - } - old := &oldInfo{ - Info: info, - ExecutionDriver: "", - } - nameOnlySecurityOptions := []string{} - kvSecOpts, err := types.DecodeSecurityOptions(old.SecurityOptions) + kvSecOpts, err := types.DecodeSecurityOptions(info.SecurityOptions) if err != nil { - return err + info.Warnings = append(info.Warnings, err.Error()) } - for _, s := range kvSecOpts { - nameOnlySecurityOptions = append(nameOnlySecurityOptions, s.Name) + var nameOnly []string + for _, so := range kvSecOpts { + nameOnly = append(nameOnly, so.Name) } - old.SecurityOptions = nameOnlySecurityOptions - return httputils.WriteJSON(w, http.StatusOK, old) + info.SecurityOptions = nameOnly + info.ExecutionDriver = "" //nolint:staticcheck // ignore SA1019 (ExecutionDriver is deprecated) } if versions.LessThan(version, "1.39") { if info.KernelVersion == "" { diff --git a/api/types/types.go b/api/types/types.go index 60bc14c1aa..02cc394bc8 100644 --- a/api/types/types.go +++ b/api/types/types.go @@ -307,6 +307,9 @@ type Info struct { ProductLicense string `json:",omitempty"` DefaultAddressPools []NetworkAddressPool `json:",omitempty"` + // Legacy API fields for older API versions. + legacyFields + // Warnings contains a slice of warnings that occurred while collecting // system information. These warnings are intended to be informational // messages for the user, and are not intended to be parsed / used for @@ -314,6 +317,10 @@ type Info struct { Warnings []string } +type legacyFields struct { + ExecutionDriver string `json:",omitempty"` // Deprecated: deprecated since API v1.25, but returned for older versions. +} + // KeyValue holds a key/value pair type KeyValue struct { Key, Value string