Skip to content

Commit e0979b3

Browse files
thaJeztahvvoland
authored andcommitted
cli/command: remove ValidateMountWithAPIVersion
This validation is now handled by the API-client since [moby@5d6b566], so no longer needed to be done in the cli. This function was only used internally and has no external consumers, so removing it without deprecating first. [moby@5d6b566]: moby/moby@5d6b566 Signed-off-by: Sebastiaan van Stijn <[email protected]> Signed-off-by: Paweł Gronowski <[email protected]>
1 parent cab5164 commit e0979b3

File tree

6 files changed

+0
-52
lines changed

6 files changed

+0
-52
lines changed

cli/command/container/create.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,6 @@ func runCreate(ctx context.Context, dockerCli command.Cli, flags *pflag.FlagSet,
115115
StatusCode: 125,
116116
}
117117
}
118-
if err = validateAPIVersion(containerCfg, dockerCli.Client().ClientVersion()); err != nil {
119-
return cli.StatusError{
120-
Status: withHelp(err, "create").Error(),
121-
StatusCode: 125,
122-
}
123-
}
124118
id, err := createContainer(ctx, dockerCli, containerCfg, options)
125119
if err != nil {
126120
return err

cli/command/container/opts.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"strings"
1414
"time"
1515

16-
"github.com/docker/cli/cli/command"
1716
"github.com/docker/cli/cli/compose/loader"
1817
"github.com/docker/cli/opts"
1918
"github.com/docker/docker/api/types/container"
@@ -1135,12 +1134,3 @@ func validateAttach(val string) (string, error) {
11351134
}
11361135
return val, errors.Errorf("valid streams are STDIN, STDOUT and STDERR")
11371136
}
1138-
1139-
func validateAPIVersion(c *containerConfig, serverAPIVersion string) error {
1140-
for _, m := range c.HostConfig.Mounts {
1141-
if err := command.ValidateMountWithAPIVersion(m, serverAPIVersion); err != nil {
1142-
return err
1143-
}
1144-
}
1145-
return nil
1146-
}

cli/command/container/run.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,6 @@ func runRun(ctx context.Context, dockerCli command.Cli, flags *pflag.FlagSet, ro
107107
StatusCode: 125,
108108
}
109109
}
110-
if err = validateAPIVersion(containerCfg, dockerCli.CurrentVersion()); err != nil {
111-
return cli.StatusError{
112-
Status: withHelp(err, "run").Error(),
113-
StatusCode: 125,
114-
}
115-
}
116110
return runContainer(ctx, dockerCli, ropts, copts, containerCfg)
117111
}
118112

cli/command/service/create.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,6 @@ func runCreate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet,
109109
return err
110110
}
111111

112-
if err = validateAPIVersion(service, dockerCLI.Client().ClientVersion()); err != nil {
113-
return err
114-
}
115-
116112
specifiedSecrets := opts.secrets.Value()
117113
if len(specifiedSecrets) > 0 {
118114
// parse and validate secrets

cli/command/service/opts.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"strings"
1212
"time"
1313

14-
"github.com/docker/cli/cli/command"
1514
"github.com/docker/cli/opts"
1615
"github.com/docker/cli/opts/swarmopts"
1716
"github.com/docker/docker/api/types/container"
@@ -1048,12 +1047,3 @@ const (
10481047
flagUlimitRemove = "ulimit-rm"
10491048
flagOomScoreAdj = "oom-score-adj"
10501049
)
1051-
1052-
func validateAPIVersion(c swarm.ServiceSpec, serverAPIVersion string) error {
1053-
for _, m := range c.TaskTemplate.ContainerSpec.Mounts {
1054-
if err := command.ValidateMountWithAPIVersion(m, serverAPIVersion); err != nil {
1055-
return err
1056-
}
1057-
}
1058-
return nil
1059-
}

cli/command/utils.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ import (
1616
"github.com/docker/cli/cli/config"
1717
"github.com/docker/cli/cli/streams"
1818
"github.com/docker/docker/api/types/filters"
19-
mounttypes "github.com/docker/docker/api/types/mount"
20-
"github.com/docker/docker/api/types/versions"
2119
"github.com/docker/docker/errdefs"
2220
"github.com/moby/sys/sequential"
2321
"github.com/moby/term"
@@ -217,17 +215,3 @@ func ValidateOutputPathFileMode(fileMode os.FileMode) error {
217215
}
218216
return nil
219217
}
220-
221-
// ValidateMountWithAPIVersion validates a mount with the server API version.
222-
func ValidateMountWithAPIVersion(m mounttypes.Mount, serverAPIVersion string) error {
223-
if m.BindOptions != nil {
224-
if m.BindOptions.NonRecursive && versions.LessThan(serverAPIVersion, "1.40") {
225-
return errors.Errorf("bind-recursive=disabled requires API v1.40 or later")
226-
}
227-
// ReadOnlyNonRecursive can be safely ignored when API < 1.44
228-
if m.BindOptions.ReadOnlyForceRecursive && versions.LessThan(serverAPIVersion, "1.44") {
229-
return errors.Errorf("bind-recursive=readonly requires API v1.44 or later")
230-
}
231-
}
232-
return nil
233-
}

0 commit comments

Comments
 (0)