Browse code

api: move types/versions to client/pkg and daemon/internal

This change moves the api/types/versions package out into client and daemon versions.

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>

Austin Vazquez authored on 2025/10/24 09:01:49
Showing 39 changed files
1 1
deleted file mode 100644
... ...
@@ -1,65 +0,0 @@
1
-package versions
2
-
3
-import (
4
-	"strconv"
5
-	"strings"
6
-)
7
-
8
-// compare compares two version strings
9
-// returns -1 if v1 < v2, 1 if v1 > v2, 0 otherwise.
10
-func compare(v1, v2 string) int {
11
-	if v1 == v2 {
12
-		return 0
13
-	}
14
-	var (
15
-		currTab  = strings.Split(v1, ".")
16
-		otherTab = strings.Split(v2, ".")
17
-	)
18
-
19
-	maxVer := len(currTab)
20
-	if len(otherTab) > maxVer {
21
-		maxVer = len(otherTab)
22
-	}
23
-	for i := 0; i < maxVer; i++ {
24
-		var currInt, otherInt int
25
-
26
-		if len(currTab) > i {
27
-			currInt, _ = strconv.Atoi(currTab[i])
28
-		}
29
-		if len(otherTab) > i {
30
-			otherInt, _ = strconv.Atoi(otherTab[i])
31
-		}
32
-		if currInt > otherInt {
33
-			return 1
34
-		}
35
-		if otherInt > currInt {
36
-			return -1
37
-		}
38
-	}
39
-	return 0
40
-}
41
-
42
-// LessThan checks if a version is less than another
43
-func LessThan(v, other string) bool {
44
-	return compare(v, other) == -1
45
-}
46
-
47
-// LessThanOrEqualTo checks if a version is less than or equal to another
48
-func LessThanOrEqualTo(v, other string) bool {
49
-	return compare(v, other) <= 0
50
-}
51
-
52
-// GreaterThan checks if a version is greater than another
53
-func GreaterThan(v, other string) bool {
54
-	return compare(v, other) == 1
55
-}
56
-
57
-// GreaterThanOrEqualTo checks if a version is greater than or equal to another
58
-func GreaterThanOrEqualTo(v, other string) bool {
59
-	return compare(v, other) >= 0
60
-}
61
-
62
-// Equal checks if a version is equal to another
63
-func Equal(v, other string) bool {
64
-	return compare(v, other) == 0
65
-}
66 1
deleted file mode 100644
... ...
@@ -1,26 +0,0 @@
1
-package versions
2
-
3
-import (
4
-	"testing"
5
-)
6
-
7
-func assertVersion(t *testing.T, a, b string, result int) {
8
-	if r := compare(a, b); r != result {
9
-		t.Fatalf("Unexpected version comparison result. Found %d, expected %d", r, result)
10
-	}
11
-}
12
-
13
-func TestCompareVersion(t *testing.T) {
14
-	assertVersion(t, "1.12", "1.12", 0)
15
-	assertVersion(t, "1.0.0", "1", 0)
16
-	assertVersion(t, "1", "1.0.0", 0)
17
-	assertVersion(t, "1.05.00.0156", "1.0.221.9289", 1)
18
-	assertVersion(t, "1", "1.0.1", -1)
19
-	assertVersion(t, "1.0.1", "1", 1)
20
-	assertVersion(t, "1.0.1", "1.0.2", -1)
21
-	assertVersion(t, "1.0.2", "1.0.3", -1)
22
-	assertVersion(t, "1.0.3", "1.1", -1)
23
-	assertVersion(t, "1.1", "1.1.1", -1)
24
-	assertVersion(t, "1.1.1", "1.1.2", -1)
25
-	assertVersion(t, "1.1.2", "1.2", -1)
26
-}
... ...
@@ -8,7 +8,7 @@ import (
8 8
 	"strconv"
9 9
 
10 10
 	"github.com/moby/moby/api/types/build"
11
-	"github.com/moby/moby/api/types/versions"
11
+	"github.com/moby/moby/client/pkg/versions"
12 12
 )
13 13
 
14 14
 // BuildCachePruneOptions hold parameters to prune the build cache.
... ...
@@ -56,7 +56,7 @@ import (
56 56
 
57 57
 	cerrdefs "github.com/containerd/errdefs"
58 58
 	"github.com/docker/go-connections/sockets"
59
-	"github.com/moby/moby/api/types/versions"
59
+	"github.com/moby/moby/client/pkg/versions"
60 60
 	"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
61 61
 )
62 62
 
... ...
@@ -8,7 +8,7 @@ import (
8 8
 
9 9
 	cerrdefs "github.com/containerd/errdefs"
10 10
 	"github.com/containerd/errdefs/pkg/errhttp"
11
-	"github.com/moby/moby/api/types/versions"
11
+	"github.com/moby/moby/client/pkg/versions"
12 12
 )
13 13
 
14 14
 // errConnectionFailed implements an error returned when connection failed.
... ...
@@ -6,7 +6,7 @@ import (
6 6
 	"net/url"
7 7
 
8 8
 	"github.com/moby/moby/api/types/image"
9
-	"github.com/moby/moby/api/types/versions"
9
+	"github.com/moby/moby/client/pkg/versions"
10 10
 )
11 11
 
12 12
 // ImageList returns a list of images in the docker host.
13 13
new file mode 100644
... ...
@@ -0,0 +1,65 @@
0
+package versions
1
+
2
+import (
3
+	"strconv"
4
+	"strings"
5
+)
6
+
7
+// compare compares two version strings
8
+// returns -1 if v1 < v2, 1 if v1 > v2, 0 otherwise.
9
+func compare(v1, v2 string) int {
10
+	if v1 == v2 {
11
+		return 0
12
+	}
13
+	var (
14
+		currTab  = strings.Split(v1, ".")
15
+		otherTab = strings.Split(v2, ".")
16
+	)
17
+
18
+	maxVer := len(currTab)
19
+	if len(otherTab) > maxVer {
20
+		maxVer = len(otherTab)
21
+	}
22
+	for i := 0; i < maxVer; i++ {
23
+		var currInt, otherInt int
24
+
25
+		if len(currTab) > i {
26
+			currInt, _ = strconv.Atoi(currTab[i])
27
+		}
28
+		if len(otherTab) > i {
29
+			otherInt, _ = strconv.Atoi(otherTab[i])
30
+		}
31
+		if currInt > otherInt {
32
+			return 1
33
+		}
34
+		if otherInt > currInt {
35
+			return -1
36
+		}
37
+	}
38
+	return 0
39
+}
40
+
41
+// LessThan checks if a version is less than another
42
+func LessThan(v, other string) bool {
43
+	return compare(v, other) == -1
44
+}
45
+
46
+// LessThanOrEqualTo checks if a version is less than or equal to another
47
+func LessThanOrEqualTo(v, other string) bool {
48
+	return compare(v, other) <= 0
49
+}
50
+
51
+// GreaterThan checks if a version is greater than another
52
+func GreaterThan(v, other string) bool {
53
+	return compare(v, other) == 1
54
+}
55
+
56
+// GreaterThanOrEqualTo checks if a version is greater than or equal to another
57
+func GreaterThanOrEqualTo(v, other string) bool {
58
+	return compare(v, other) >= 0
59
+}
60
+
61
+// Equal checks if a version is equal to another
62
+func Equal(v, other string) bool {
63
+	return compare(v, other) == 0
64
+}
0 65
new file mode 100644
... ...
@@ -0,0 +1,26 @@
0
+package versions
1
+
2
+import (
3
+	"testing"
4
+)
5
+
6
+func assertVersion(t *testing.T, a, b string, result int) {
7
+	if r := compare(a, b); r != result {
8
+		t.Fatalf("Unexpected version comparison result. Found %d, expected %d", r, result)
9
+	}
10
+}
11
+
12
+func TestCompareVersion(t *testing.T) {
13
+	assertVersion(t, "1.12", "1.12", 0)
14
+	assertVersion(t, "1.0.0", "1", 0)
15
+	assertVersion(t, "1", "1.0.0", 0)
16
+	assertVersion(t, "1.05.00.0156", "1.0.221.9289", 1)
17
+	assertVersion(t, "1", "1.0.1", -1)
18
+	assertVersion(t, "1.0.1", "1", 1)
19
+	assertVersion(t, "1.0.1", "1.0.2", -1)
20
+	assertVersion(t, "1.0.2", "1.0.3", -1)
21
+	assertVersion(t, "1.0.3", "1.1", -1)
22
+	assertVersion(t, "1.1", "1.1.1", -1)
23
+	assertVersion(t, "1.1.1", "1.1.2", -1)
24
+	assertVersion(t, "1.1.2", "1.2", -1)
25
+}
... ...
@@ -13,8 +13,8 @@ import (
13 13
 
14 14
 	"dario.cat/mergo"
15 15
 	"github.com/containerd/log"
16
-	"github.com/moby/moby/api/types/versions"
17 16
 	dopts "github.com/moby/moby/v2/daemon/internal/opts"
17
+	"github.com/moby/moby/v2/daemon/internal/versions"
18 18
 	"github.com/moby/moby/v2/daemon/pkg/opts"
19 19
 	"github.com/moby/moby/v2/daemon/pkg/registry"
20 20
 	"github.com/pkg/errors"
21 21
new file mode 100644
... ...
@@ -0,0 +1,65 @@
0
+package versions
1
+
2
+import (
3
+	"strconv"
4
+	"strings"
5
+)
6
+
7
+// compare compares two version strings
8
+// returns -1 if v1 < v2, 1 if v1 > v2, 0 otherwise.
9
+func compare(v1, v2 string) int {
10
+	if v1 == v2 {
11
+		return 0
12
+	}
13
+	var (
14
+		currTab  = strings.Split(v1, ".")
15
+		otherTab = strings.Split(v2, ".")
16
+	)
17
+
18
+	maxVer := len(currTab)
19
+	if len(otherTab) > maxVer {
20
+		maxVer = len(otherTab)
21
+	}
22
+	for i := 0; i < maxVer; i++ {
23
+		var currInt, otherInt int
24
+
25
+		if len(currTab) > i {
26
+			currInt, _ = strconv.Atoi(currTab[i])
27
+		}
28
+		if len(otherTab) > i {
29
+			otherInt, _ = strconv.Atoi(otherTab[i])
30
+		}
31
+		if currInt > otherInt {
32
+			return 1
33
+		}
34
+		if otherInt > currInt {
35
+			return -1
36
+		}
37
+	}
38
+	return 0
39
+}
40
+
41
+// LessThan checks if a version is less than another
42
+func LessThan(v, other string) bool {
43
+	return compare(v, other) == -1
44
+}
45
+
46
+// LessThanOrEqualTo checks if a version is less than or equal to another
47
+func LessThanOrEqualTo(v, other string) bool {
48
+	return compare(v, other) <= 0
49
+}
50
+
51
+// GreaterThan checks if a version is greater than another
52
+func GreaterThan(v, other string) bool {
53
+	return compare(v, other) == 1
54
+}
55
+
56
+// GreaterThanOrEqualTo checks if a version is greater than or equal to another
57
+func GreaterThanOrEqualTo(v, other string) bool {
58
+	return compare(v, other) >= 0
59
+}
60
+
61
+// Equal checks if a version is equal to another
62
+func Equal(v, other string) bool {
63
+	return compare(v, other) == 0
64
+}
0 65
new file mode 100644
... ...
@@ -0,0 +1,26 @@
0
+package versions
1
+
2
+import (
3
+	"testing"
4
+)
5
+
6
+func assertVersion(t *testing.T, a, b string, result int) {
7
+	if r := compare(a, b); r != result {
8
+		t.Fatalf("Unexpected version comparison result. Found %d, expected %d", r, result)
9
+	}
10
+}
11
+
12
+func TestCompareVersion(t *testing.T) {
13
+	assertVersion(t, "1.12", "1.12", 0)
14
+	assertVersion(t, "1.0.0", "1", 0)
15
+	assertVersion(t, "1", "1.0.0", 0)
16
+	assertVersion(t, "1.05.00.0156", "1.0.221.9289", 1)
17
+	assertVersion(t, "1", "1.0.1", -1)
18
+	assertVersion(t, "1.0.1", "1", 1)
19
+	assertVersion(t, "1.0.1", "1.0.2", -1)
20
+	assertVersion(t, "1.0.2", "1.0.3", -1)
21
+	assertVersion(t, "1.0.3", "1.1", -1)
22
+	assertVersion(t, "1.1", "1.1.1", -1)
23
+	assertVersion(t, "1.1.1", "1.1.2", -1)
24
+	assertVersion(t, "1.1.2", "1.2", -1)
25
+}
... ...
@@ -6,8 +6,8 @@ import (
6 6
 	"net/http"
7 7
 	"runtime"
8 8
 
9
-	"github.com/moby/moby/api/types/versions"
10 9
 	"github.com/moby/moby/v2/daemon/config"
10
+	"github.com/moby/moby/v2/daemon/internal/versions"
11 11
 	"github.com/moby/moby/v2/daemon/server/httputils"
12 12
 )
13 13
 
... ...
@@ -21,8 +21,8 @@ import (
21 21
 	"github.com/moby/moby/api/types/build"
22 22
 	"github.com/moby/moby/api/types/container"
23 23
 	"github.com/moby/moby/api/types/registry"
24
-	"github.com/moby/moby/api/types/versions"
25 24
 	"github.com/moby/moby/v2/daemon/internal/filters"
25
+	"github.com/moby/moby/v2/daemon/internal/versions"
26 26
 	"github.com/moby/moby/v2/daemon/server/buildbackend"
27 27
 	"github.com/moby/moby/v2/daemon/server/httputils"
28 28
 	"github.com/moby/moby/v2/pkg/ioutils"
... ...
@@ -17,9 +17,9 @@ import (
17 17
 	"github.com/moby/moby/api/types/container"
18 18
 	"github.com/moby/moby/api/types/mount"
19 19
 	"github.com/moby/moby/api/types/network"
20
-	"github.com/moby/moby/api/types/versions"
21 20
 	"github.com/moby/moby/v2/daemon/internal/filters"
22 21
 	"github.com/moby/moby/v2/daemon/internal/runconfig"
22
+	"github.com/moby/moby/v2/daemon/internal/versions"
23 23
 	"github.com/moby/moby/v2/daemon/libnetwork/netlabel"
24 24
 	networkSettings "github.com/moby/moby/v2/daemon/network"
25 25
 	"github.com/moby/moby/v2/daemon/server/backend"
... ...
@@ -10,8 +10,8 @@ import (
10 10
 	"github.com/moby/moby/api/pkg/stdcopy"
11 11
 	"github.com/moby/moby/api/types"
12 12
 	"github.com/moby/moby/api/types/container"
13
-	"github.com/moby/moby/api/types/versions"
14 13
 	"github.com/moby/moby/v2/daemon/internal/stdcopymux"
14
+	"github.com/moby/moby/v2/daemon/internal/versions"
15 15
 	"github.com/moby/moby/v2/daemon/server/backend"
16 16
 	"github.com/moby/moby/v2/daemon/server/httputils"
17 17
 	"github.com/moby/moby/v2/errdefs"
... ...
@@ -6,9 +6,9 @@ import (
6 6
 
7 7
 	"github.com/moby/moby/api/types/container"
8 8
 	"github.com/moby/moby/api/types/storage"
9
-	"github.com/moby/moby/api/types/versions"
10 9
 	"github.com/moby/moby/v2/daemon/internal/compat"
11 10
 	"github.com/moby/moby/v2/daemon/internal/stringid"
11
+	"github.com/moby/moby/v2/daemon/internal/versions"
12 12
 	"github.com/moby/moby/v2/daemon/server/backend"
13 13
 	"github.com/moby/moby/v2/daemon/server/httputils"
14 14
 	"github.com/moby/moby/v2/internal/sliceutil"
... ...
@@ -16,11 +16,11 @@ import (
16 16
 	"github.com/moby/moby/api/pkg/progress"
17 17
 	"github.com/moby/moby/api/pkg/streamformatter"
18 18
 	"github.com/moby/moby/api/types/registry"
19
-	"github.com/moby/moby/api/types/versions"
20 19
 	"github.com/moby/moby/v2/daemon/builder/remotecontext"
21 20
 	"github.com/moby/moby/v2/daemon/internal/compat"
22 21
 	"github.com/moby/moby/v2/daemon/internal/filters"
23 22
 	"github.com/moby/moby/v2/daemon/internal/image"
23
+	"github.com/moby/moby/v2/daemon/internal/versions"
24 24
 	"github.com/moby/moby/v2/daemon/server/httputils"
25 25
 	"github.com/moby/moby/v2/daemon/server/imagebackend"
26 26
 	"github.com/moby/moby/v2/dockerversion"
... ...
@@ -4,7 +4,7 @@ import (
4 4
 	"context"
5 5
 	"net/http"
6 6
 
7
-	"github.com/moby/moby/api/types/versions"
7
+	"github.com/moby/moby/v2/daemon/internal/versions"
8 8
 	"github.com/moby/moby/v2/daemon/server/httputils"
9 9
 )
10 10
 
... ...
@@ -7,8 +7,8 @@ import (
7 7
 	"strings"
8 8
 
9 9
 	"github.com/moby/moby/api/types/network"
10
-	"github.com/moby/moby/api/types/versions"
11 10
 	"github.com/moby/moby/v2/daemon/internal/filters"
11
+	"github.com/moby/moby/v2/daemon/internal/versions"
12 12
 	"github.com/moby/moby/v2/daemon/libnetwork"
13 13
 	"github.com/moby/moby/v2/daemon/libnetwork/scope"
14 14
 	dnetwork "github.com/moby/moby/v2/daemon/network"
... ...
@@ -9,9 +9,9 @@ import (
9 9
 	"github.com/containerd/log"
10 10
 	"github.com/moby/moby/api/types/registry"
11 11
 	types "github.com/moby/moby/api/types/swarm"
12
-	"github.com/moby/moby/api/types/versions"
13 12
 	"github.com/moby/moby/v2/daemon/internal/compat"
14 13
 	"github.com/moby/moby/v2/daemon/internal/filters"
14
+	"github.com/moby/moby/v2/daemon/internal/versions"
15 15
 	"github.com/moby/moby/v2/daemon/server/backend"
16 16
 	"github.com/moby/moby/v2/daemon/server/httputils"
17 17
 	"github.com/moby/moby/v2/daemon/server/swarmbackend"
... ...
@@ -7,7 +7,7 @@ import (
7 7
 
8 8
 	basictypes "github.com/moby/moby/api/types"
9 9
 	"github.com/moby/moby/api/types/swarm"
10
-	"github.com/moby/moby/api/types/versions"
10
+	"github.com/moby/moby/v2/daemon/internal/versions"
11 11
 	"github.com/moby/moby/v2/daemon/server/backend"
12 12
 	"github.com/moby/moby/v2/daemon/server/httputils"
13 13
 )
... ...
@@ -16,10 +16,10 @@ import (
16 16
 	"github.com/moby/moby/api/types/registry"
17 17
 	"github.com/moby/moby/api/types/swarm"
18 18
 	"github.com/moby/moby/api/types/system"
19
-	"github.com/moby/moby/api/types/versions"
20 19
 	"github.com/moby/moby/v2/daemon/internal/compat"
21 20
 	"github.com/moby/moby/v2/daemon/internal/filters"
22 21
 	"github.com/moby/moby/v2/daemon/internal/timestamp"
22
+	"github.com/moby/moby/v2/daemon/internal/versions"
23 23
 	"github.com/moby/moby/v2/daemon/server/backend"
24 24
 	"github.com/moby/moby/v2/daemon/server/httputils"
25 25
 	"github.com/moby/moby/v2/daemon/server/router/build"
... ...
@@ -8,9 +8,9 @@ import (
8 8
 
9 9
 	cerrdefs "github.com/containerd/errdefs"
10 10
 	"github.com/containerd/log"
11
-	"github.com/moby/moby/api/types/versions"
12 11
 	"github.com/moby/moby/api/types/volume"
13 12
 	"github.com/moby/moby/v2/daemon/internal/filters"
13
+	"github.com/moby/moby/v2/daemon/internal/versions"
14 14
 	"github.com/moby/moby/v2/daemon/server/httputils"
15 15
 	"github.com/moby/moby/v2/daemon/server/volumebackend"
16 16
 	"github.com/moby/moby/v2/daemon/volume/service/opts"
... ...
@@ -7,8 +7,8 @@ import (
7 7
 	"github.com/containerd/log"
8 8
 	"github.com/gorilla/mux"
9 9
 	"github.com/moby/moby/api/types/common"
10
-	"github.com/moby/moby/api/types/versions"
11 10
 	"github.com/moby/moby/v2/daemon/internal/otelutil"
11
+	"github.com/moby/moby/v2/daemon/internal/versions"
12 12
 	"github.com/moby/moby/v2/daemon/server/httpstatus"
13 13
 	"github.com/moby/moby/v2/daemon/server/httputils"
14 14
 	"github.com/moby/moby/v2/daemon/server/middleware"
... ...
@@ -21,7 +21,7 @@ import (
21 21
 	"github.com/moby/buildkit/frontend/dockerfile/command"
22 22
 	"github.com/moby/go-archive"
23 23
 	"github.com/moby/go-archive/compression"
24
-	"github.com/moby/moby/api/types/versions"
24
+	"github.com/moby/moby/client/pkg/versions"
25 25
 	"github.com/moby/moby/v2/integration-cli/cli"
26 26
 	"github.com/moby/moby/v2/integration-cli/cli/build"
27 27
 	"github.com/moby/moby/v2/internal/testutil"
... ...
@@ -12,7 +12,7 @@ import (
12 12
 	"testing"
13 13
 
14 14
 	"github.com/distribution/reference"
15
-	"github.com/moby/moby/api/types/versions"
15
+	"github.com/moby/moby/client/pkg/versions"
16 16
 	"github.com/moby/moby/v2/integration-cli/cli"
17 17
 	"github.com/moby/moby/v2/integration-cli/cli/build"
18 18
 	"golang.org/x/sync/errgroup"
... ...
@@ -20,8 +20,8 @@ import (
20 20
 
21 21
 	"github.com/cloudflare/cfssl/helpers"
22 22
 	"github.com/moby/moby/api/types/swarm"
23
-	"github.com/moby/moby/api/types/versions"
24 23
 	"github.com/moby/moby/client"
24
+	"github.com/moby/moby/client/pkg/versions"
25 25
 	"github.com/moby/moby/v2/daemon/libnetwork/driverapi"
26 26
 	"github.com/moby/moby/v2/daemon/libnetwork/ipamapi"
27 27
 	remoteipam "github.com/moby/moby/v2/daemon/libnetwork/ipams/remote/api"
... ...
@@ -15,9 +15,9 @@ import (
15 15
 	"github.com/moby/moby/api/types/common"
16 16
 	"github.com/moby/moby/api/types/container"
17 17
 	"github.com/moby/moby/api/types/network"
18
-	"github.com/moby/moby/api/types/versions"
19 18
 	"github.com/moby/moby/client"
20 19
 	"github.com/moby/moby/client/pkg/stringid"
20
+	"github.com/moby/moby/client/pkg/versions"
21 21
 	"github.com/moby/moby/v2/daemon/pkg/oci"
22 22
 	testContainer "github.com/moby/moby/v2/integration/internal/container"
23 23
 	net "github.com/moby/moby/v2/integration/internal/network"
... ...
@@ -7,8 +7,8 @@ import (
7 7
 	"time"
8 8
 
9 9
 	containertypes "github.com/moby/moby/api/types/container"
10
-	"github.com/moby/moby/api/types/versions"
11 10
 	"github.com/moby/moby/client"
11
+	"github.com/moby/moby/client/pkg/versions"
12 12
 	"github.com/moby/moby/v2/integration/internal/container"
13 13
 	"github.com/moby/moby/v2/internal/testutil"
14 14
 	"github.com/moby/moby/v2/internal/testutil/request"
... ...
@@ -11,8 +11,8 @@ import (
11 11
 	containertypes "github.com/moby/moby/api/types/container"
12 12
 	mounttypes "github.com/moby/moby/api/types/mount"
13 13
 	"github.com/moby/moby/api/types/network"
14
-	"github.com/moby/moby/api/types/versions"
15 14
 	"github.com/moby/moby/client"
15
+	"github.com/moby/moby/client/pkg/versions"
16 16
 	"github.com/moby/moby/v2/daemon/config"
17 17
 	"github.com/moby/moby/v2/daemon/volume"
18 18
 	"github.com/moby/moby/v2/integration/internal/container"
... ...
@@ -12,8 +12,8 @@ import (
12 12
 	"time"
13 13
 
14 14
 	networktypes "github.com/moby/moby/api/types/network"
15
-	"github.com/moby/moby/api/types/versions"
16 15
 	"github.com/moby/moby/client"
16
+	"github.com/moby/moby/client/pkg/versions"
17 17
 	"github.com/moby/moby/v2/daemon/libnetwork/netlabel"
18 18
 	"github.com/moby/moby/v2/integration/internal/container"
19 19
 	"github.com/moby/moby/v2/integration/internal/network"
... ...
@@ -12,8 +12,8 @@ import (
12 12
 	containertypes "github.com/moby/moby/api/types/container"
13 13
 	"github.com/moby/moby/api/types/mount"
14 14
 	"github.com/moby/moby/api/types/network"
15
-	"github.com/moby/moby/api/types/versions"
16 15
 	"github.com/moby/moby/client"
16
+	"github.com/moby/moby/client/pkg/versions"
17 17
 	"github.com/moby/moby/v2/daemon/volume/safepath"
18 18
 	"github.com/moby/moby/v2/integration/internal/container"
19 19
 	"github.com/moby/moby/v2/internal/testutil/fakecontext"
20 20
deleted file mode 100644
... ...
@@ -1,65 +0,0 @@
1
-package versions
2
-
3
-import (
4
-	"strconv"
5
-	"strings"
6
-)
7
-
8
-// compare compares two version strings
9
-// returns -1 if v1 < v2, 1 if v1 > v2, 0 otherwise.
10
-func compare(v1, v2 string) int {
11
-	if v1 == v2 {
12
-		return 0
13
-	}
14
-	var (
15
-		currTab  = strings.Split(v1, ".")
16
-		otherTab = strings.Split(v2, ".")
17
-	)
18
-
19
-	maxVer := len(currTab)
20
-	if len(otherTab) > maxVer {
21
-		maxVer = len(otherTab)
22
-	}
23
-	for i := 0; i < maxVer; i++ {
24
-		var currInt, otherInt int
25
-
26
-		if len(currTab) > i {
27
-			currInt, _ = strconv.Atoi(currTab[i])
28
-		}
29
-		if len(otherTab) > i {
30
-			otherInt, _ = strconv.Atoi(otherTab[i])
31
-		}
32
-		if currInt > otherInt {
33
-			return 1
34
-		}
35
-		if otherInt > currInt {
36
-			return -1
37
-		}
38
-	}
39
-	return 0
40
-}
41
-
42
-// LessThan checks if a version is less than another
43
-func LessThan(v, other string) bool {
44
-	return compare(v, other) == -1
45
-}
46
-
47
-// LessThanOrEqualTo checks if a version is less than or equal to another
48
-func LessThanOrEqualTo(v, other string) bool {
49
-	return compare(v, other) <= 0
50
-}
51
-
52
-// GreaterThan checks if a version is greater than another
53
-func GreaterThan(v, other string) bool {
54
-	return compare(v, other) == 1
55
-}
56
-
57
-// GreaterThanOrEqualTo checks if a version is greater than or equal to another
58
-func GreaterThanOrEqualTo(v, other string) bool {
59
-	return compare(v, other) >= 0
60
-}
61
-
62
-// Equal checks if a version is equal to another
63
-func Equal(v, other string) bool {
64
-	return compare(v, other) == 0
65
-}
... ...
@@ -8,7 +8,7 @@ import (
8 8
 	"strconv"
9 9
 
10 10
 	"github.com/moby/moby/api/types/build"
11
-	"github.com/moby/moby/api/types/versions"
11
+	"github.com/moby/moby/client/pkg/versions"
12 12
 )
13 13
 
14 14
 // BuildCachePruneOptions hold parameters to prune the build cache.
... ...
@@ -56,7 +56,7 @@ import (
56 56
 
57 57
 	cerrdefs "github.com/containerd/errdefs"
58 58
 	"github.com/docker/go-connections/sockets"
59
-	"github.com/moby/moby/api/types/versions"
59
+	"github.com/moby/moby/client/pkg/versions"
60 60
 	"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
61 61
 )
62 62
 
... ...
@@ -8,7 +8,7 @@ import (
8 8
 
9 9
 	cerrdefs "github.com/containerd/errdefs"
10 10
 	"github.com/containerd/errdefs/pkg/errhttp"
11
-	"github.com/moby/moby/api/types/versions"
11
+	"github.com/moby/moby/client/pkg/versions"
12 12
 )
13 13
 
14 14
 // errConnectionFailed implements an error returned when connection failed.
... ...
@@ -6,7 +6,7 @@ import (
6 6
 	"net/url"
7 7
 
8 8
 	"github.com/moby/moby/api/types/image"
9
-	"github.com/moby/moby/api/types/versions"
9
+	"github.com/moby/moby/client/pkg/versions"
10 10
 )
11 11
 
12 12
 // ImageList returns a list of images in the docker host.
13 13
new file mode 100644
... ...
@@ -0,0 +1,65 @@
0
+package versions
1
+
2
+import (
3
+	"strconv"
4
+	"strings"
5
+)
6
+
7
+// compare compares two version strings
8
+// returns -1 if v1 < v2, 1 if v1 > v2, 0 otherwise.
9
+func compare(v1, v2 string) int {
10
+	if v1 == v2 {
11
+		return 0
12
+	}
13
+	var (
14
+		currTab  = strings.Split(v1, ".")
15
+		otherTab = strings.Split(v2, ".")
16
+	)
17
+
18
+	maxVer := len(currTab)
19
+	if len(otherTab) > maxVer {
20
+		maxVer = len(otherTab)
21
+	}
22
+	for i := 0; i < maxVer; i++ {
23
+		var currInt, otherInt int
24
+
25
+		if len(currTab) > i {
26
+			currInt, _ = strconv.Atoi(currTab[i])
27
+		}
28
+		if len(otherTab) > i {
29
+			otherInt, _ = strconv.Atoi(otherTab[i])
30
+		}
31
+		if currInt > otherInt {
32
+			return 1
33
+		}
34
+		if otherInt > currInt {
35
+			return -1
36
+		}
37
+	}
38
+	return 0
39
+}
40
+
41
+// LessThan checks if a version is less than another
42
+func LessThan(v, other string) bool {
43
+	return compare(v, other) == -1
44
+}
45
+
46
+// LessThanOrEqualTo checks if a version is less than or equal to another
47
+func LessThanOrEqualTo(v, other string) bool {
48
+	return compare(v, other) <= 0
49
+}
50
+
51
+// GreaterThan checks if a version is greater than another
52
+func GreaterThan(v, other string) bool {
53
+	return compare(v, other) == 1
54
+}
55
+
56
+// GreaterThanOrEqualTo checks if a version is greater than or equal to another
57
+func GreaterThanOrEqualTo(v, other string) bool {
58
+	return compare(v, other) >= 0
59
+}
60
+
61
+// Equal checks if a version is equal to another
62
+func Equal(v, other string) bool {
63
+	return compare(v, other) == 0
64
+}
... ...
@@ -961,7 +961,6 @@ github.com/moby/moby/api/types/registry
961 961
 github.com/moby/moby/api/types/storage
962 962
 github.com/moby/moby/api/types/swarm
963 963
 github.com/moby/moby/api/types/system
964
-github.com/moby/moby/api/types/versions
965 964
 github.com/moby/moby/api/types/volume
966 965
 # github.com/moby/moby/client v0.1.0-beta.2 => ./client
967 966
 ## explicit; go 1.23.0
... ...
@@ -970,6 +969,7 @@ github.com/moby/moby/client/internal
970 970
 github.com/moby/moby/client/internal/timestamp
971 971
 github.com/moby/moby/client/pkg/jsonmessage
972 972
 github.com/moby/moby/client/pkg/stringid
973
+github.com/moby/moby/client/pkg/versions
973 974
 # github.com/moby/patternmatcher v0.6.0
974 975
 ## explicit; go 1.19
975 976
 github.com/moby/patternmatcher