diff --git a/daemon/info.go b/daemon/info.go index 624deba00c..4d143f98de 100644 --- a/daemon/info.go +++ b/daemon/info.go @@ -175,6 +175,10 @@ func (daemon *Daemon) fillPluginsInfo(ctx context.Context, v *system.Info, cfg * } } +// fillSecurityOptions fills the [system.Info.SecurityOptions] field based +// on the daemon configuration. +// +// TODO(thaJeztah): consider making [system.Info.SecurityOptions] a structured response as originally intended in https://github.com/moby/moby/pull/26276 func (daemon *Daemon) fillSecurityOptions(v *system.Info, sysInfo *sysinfo.SysInfo, cfg *config.Config) { var securityOptions []string if sysInfo.AppArmor { diff --git a/daemon/server/router/system/system_routes.go b/daemon/server/router/system/system_routes.go index 719e1651f1..34b6e9c075 100644 --- a/daemon/server/router/system/system_routes.go +++ b/daemon/server/router/system/system_routes.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "net/http" - "strings" "time" "github.com/containerd/log" @@ -22,7 +21,6 @@ import ( "github.com/moby/moby/v2/daemon/server/backend" "github.com/moby/moby/v2/daemon/server/httputils" "github.com/moby/moby/v2/daemon/server/router/build" - "github.com/moby/moby/v2/daemon/server/systembackend" "github.com/moby/moby/v2/pkg/ioutils" "github.com/pkg/errors" "golang.org/x/sync/errgroup" @@ -75,18 +73,6 @@ func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *ht info.Warnings = append(info.Warnings, info.Swarm.Warnings...) } - if versions.LessThan(version, "1.25") { - // TODO: handle this conversion in engine-api - kvSecOpts, err := decodeSecurityOptions(info.SecurityOptions) - if err != nil { - info.Warnings = append(info.Warnings, err.Error()) - } - var nameOnly []string - for _, so := range kvSecOpts { - nameOnly = append(nameOnly, so.Name) - } - info.SecurityOptions = nameOnly - } if versions.LessThan(version, "1.44") { for k, rt := range info.Runtimes { // Status field introduced in API v1.44. @@ -137,36 +123,6 @@ func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *ht return httputils.WriteJSON(w, http.StatusOK, info) } -// decodeSecurityOptions decodes a security options string slice to a -// type-safe [systembackend.SecurityOption]. -func decodeSecurityOptions(opts []string) ([]systembackend.SecurityOption, error) { - so := []systembackend.SecurityOption{} - for _, opt := range opts { - // support output from a < 1.13 docker daemon - if !strings.Contains(opt, "=") { - so = append(so, systembackend.SecurityOption{Name: opt}) - continue - } - secopt := systembackend.SecurityOption{} - for _, s := range strings.Split(opt, ",") { - k, v, ok := strings.Cut(s, "=") - if !ok { - return nil, fmt.Errorf("invalid security option %q", s) - } - if k == "" || v == "" { - return nil, errors.New("invalid empty security option") - } - if k == "name" { - secopt.Name = v - continue - } - secopt.Options = append(secopt.Options, systembackend.KeyValue{Key: k, Value: v}) - } - so = append(so, secopt) - } - return so, nil -} - func (s *systemRouter) getVersion(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { info, err := s.backend.SystemVersion(ctx) if err != nil { diff --git a/daemon/server/systembackend/security_opts.go b/daemon/server/systembackend/security_opts.go deleted file mode 100644 index 173a78b3c1..0000000000 --- a/daemon/server/systembackend/security_opts.go +++ /dev/null @@ -1,12 +0,0 @@ -package systembackend - -// SecurityOption contains the name and options of a security option -type SecurityOption struct { - Name string - Options []KeyValue -} - -// KeyValue holds a key/value pair. -type KeyValue struct { - Key, Value string -}