From 9477941c208d74508f0faf2abcbe111af5363c80 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 1 Sep 2025 10:22:28 +0200 Subject: [PATCH] cli/command/context: remove deprecated types and functions These functions and types are shallow wrappers around the context store and were intended for internal use as implementation for the CLI itself. They were exported in 3126920af14ea5127e00a2f8f9d8e07a6c3f6ff9 to be used by plugins and Docker Desktop. However, there's currently no public uses of this, and Docker Desktop does not use these functions. These were deprecated in 95eeafa5514aea3ebe00b9f19c86c097a9eaf0b6 and are no longer used. This patch removes the deprecated functions as they were meant to be implementation specific for the CLI. If there's a need to provide utilities for manipulating the context-store other than through the CLI itself, we can consider creating an SDK for that purpose. This removes: - `RunCreate` and `CreateOptions` - `RunExport` and `ExportOptions` - `RunImport` - `RunRemove` and `RemoveOptions` - `RunUpdate` and `UpdateOptions` - `RunUse` Signed-off-by: Sebastiaan van Stijn --- cli/command/context/create.go | 30 ------------------------------ cli/command/context/export.go | 18 ------------------ cli/command/context/import.go | 7 ------- cli/command/context/remove.go | 14 -------------- cli/command/context/update.go | 23 ----------------------- cli/command/context/use.go | 7 ------- 6 files changed, 99 deletions(-) diff --git a/cli/command/context/create.go b/cli/command/context/create.go index 32dfb00d27c2..a00fedce7845 100644 --- a/cli/command/context/create.go +++ b/cli/command/context/create.go @@ -17,20 +17,6 @@ import ( "github.com/spf13/cobra" ) -// CreateOptions are the options used for creating a context -// -// Deprecated: this type was for internal use and will be removed in the next release. -type CreateOptions struct { - Name string - Description string - Docker map[string]string - From string - - // Additional Metadata to store in the context. This option is not - // currently exposed to the user. - metaData map[string]any -} - // createOptions are the options used for creating a context type createOptions struct { name string @@ -76,22 +62,6 @@ func newCreateCommand(dockerCLI command.Cli) *cobra.Command { return cmd } -// RunCreate creates a Docker context - -// Deprecated: this function was for internal use and will be removed in the next release. -func RunCreate(dockerCLI command.Cli, o *CreateOptions) error { - if o == nil { - o = &CreateOptions{} - } - - return runCreate(dockerCLI, &createOptions{ - name: o.Name, - description: o.Description, - endpoint: o.Docker, - metaData: o.metaData, - }) -} - // runCreate creates a Docker context func runCreate(dockerCLI command.Cli, opts *createOptions) error { s := dockerCLI.ContextStore() diff --git a/cli/command/context/export.go b/cli/command/context/export.go index 90d5b723203d..a34722e7f8fc 100644 --- a/cli/command/context/export.go +++ b/cli/command/context/export.go @@ -12,14 +12,6 @@ import ( "github.com/spf13/cobra" ) -// ExportOptions are the options used for exporting a context -// -// Deprecated: this type was for internal use and will be removed in the next release. -type ExportOptions struct { - ContextName string - Dest string -} - func newExportCommand(dockerCLI command.Cli) *cobra.Command { return &cobra.Command{ Use: "export [OPTIONS] CONTEXT [FILE|-]", @@ -65,16 +57,6 @@ func writeTo(dockerCli command.Cli, reader io.Reader, dest string) error { return nil } -// RunExport exports a Docker context -// -// Deprecated: this function was for internal use and will be removed in the next release. -func RunExport(dockerCli command.Cli, opts *ExportOptions) error { - if opts == nil { - opts = &ExportOptions{} - } - return runExport(dockerCli, opts.ContextName, opts.Dest) -} - // runExport exports a Docker context. func runExport(dockerCLI command.Cli, contextName string, dest string) error { if err := store.ValidateContextName(contextName); err != nil && contextName != command.DefaultContextName { diff --git a/cli/command/context/import.go b/cli/command/context/import.go index aa7a728e1c78..ce0b317ad123 100644 --- a/cli/command/context/import.go +++ b/cli/command/context/import.go @@ -26,13 +26,6 @@ func newImportCommand(dockerCli command.Cli) *cobra.Command { return cmd } -// RunImport imports a Docker context -// -// Deprecated: this function was for internal use and will be removed in the next release. -func RunImport(dockerCLI command.Cli, name string, source string) error { - return runImport(dockerCLI, name, source) -} - // runImport imports a Docker context. func runImport(dockerCLI command.Cli, name string, source string) error { if err := checkContextNameForCreation(dockerCLI.ContextStore(), name); err != nil { diff --git a/cli/command/context/remove.go b/cli/command/context/remove.go index c3397e8b9c76..423c28679db2 100644 --- a/cli/command/context/remove.go +++ b/cli/command/context/remove.go @@ -10,13 +10,6 @@ import ( "github.com/spf13/cobra" ) -// RemoveOptions are the options used to remove contexts -// -// Deprecated: this type was for internal use and will be removed in the next release. -type RemoveOptions struct { - Force bool -} - // removeOptions are the options used to remove contexts. type removeOptions struct { force bool @@ -38,13 +31,6 @@ func newRemoveCommand(dockerCLI command.Cli) *cobra.Command { return cmd } -// RunRemove removes one or more contexts -// -// Deprecated: this function was for internal use and will be removed in the next release. -func RunRemove(dockerCLI command.Cli, opts removeOptions, names []string) error { - return runRemove(dockerCLI, opts, names) -} - // runRemove removes one or more contexts. func runRemove(dockerCLI command.Cli, opts removeOptions, names []string) error { var errs []error diff --git a/cli/command/context/update.go b/cli/command/context/update.go index 2c6a54eda03a..041e9115eb6d 100644 --- a/cli/command/context/update.go +++ b/cli/command/context/update.go @@ -12,15 +12,6 @@ import ( "github.com/spf13/cobra" ) -// UpdateOptions are the options used to update a context -// -// Deprecated: this type was for internal use and will be removed in the next release. -type UpdateOptions struct { - Name string - Description string - Docker map[string]string -} - // updateOptions are the options used to update a context. type updateOptions struct { name string @@ -60,20 +51,6 @@ func newUpdateCommand(dockerCLI command.Cli) *cobra.Command { return cmd } -// RunUpdate updates a Docker context -// -// Deprecated: this function was for internal use and will be removed in the next release. -func RunUpdate(dockerCLI command.Cli, o *UpdateOptions) error { - if o == nil { - o = &UpdateOptions{} - } - return runUpdate(dockerCLI, &updateOptions{ - name: o.Name, - description: o.Description, - endpoint: o.Docker, - }) -} - // runUpdate updates a Docker context. func runUpdate(dockerCLI command.Cli, opts *updateOptions) error { if err := store.ValidateContextName(opts.name); err != nil { diff --git a/cli/command/context/use.go b/cli/command/context/use.go index 0095a0dc93b8..3ded6d01ae74 100644 --- a/cli/command/context/use.go +++ b/cli/command/context/use.go @@ -24,13 +24,6 @@ func newUseCommand(dockerCLI command.Cli) *cobra.Command { return cmd } -// RunUse set the current Docker context -// -// Deprecated: this function was for internal use and will be removed in the next release. -func RunUse(dockerCLI command.Cli, name string) error { - return runUse(dockerCLI, name) -} - // runUse set the current Docker context func runUse(dockerCLI command.Cli, name string) error { // configValue uses an empty string for "default"