mirror of
https://github.com/rancher/rke.git
synced 2025-08-28 19:31:04 +00:00
Merge pull request #479 from galal-hussein/check_version_ranges
Accept different patches of supported docker versions
This commit is contained in:
commit
e758a9805c
@ -9,8 +9,9 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/coreos/go-semver/semver"
|
||||||
ref "github.com/docker/distribution/reference"
|
ref "github.com/docker/distribution/reference"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
@ -26,7 +27,9 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var K8sDockerVersions = map[string][]string{
|
var K8sDockerVersions = map[string][]string{
|
||||||
"1.8": {"1.12.6", "1.13.1", "17.03.2"},
|
"1.8": {"1.11.x", "1.12.x", "1.13.x", "17.03.x"},
|
||||||
|
"1.9": {"1.11.x", "1.12.x", "1.13.x", "17.03.x"},
|
||||||
|
"1.10": {"1.11.x", "1.12.x", "1.13.x", "17.03.x"},
|
||||||
}
|
}
|
||||||
|
|
||||||
func DoRunContainer(ctx context.Context, dClient *client.Client, imageCfg *container.Config, hostCfg *container.HostConfig, containerName string, hostname string, plane string, prsMap map[string]v3.PrivateRegistry) error {
|
func DoRunContainer(ctx context.Context, dClient *client.Client, imageCfg *container.Config, hostCfg *container.HostConfig, containerName string, hostname string, plane string, prsMap map[string]v3.PrivateRegistry) error {
|
||||||
@ -295,10 +298,16 @@ func sliceEqualsIgnoreOrder(left, right []string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IsSupportedDockerVersion(info types.Info, K8sVersion string) (bool, error) {
|
func IsSupportedDockerVersion(info types.Info, K8sVersion string) (bool, error) {
|
||||||
// Docker versions are not semver compliant since stable/edge version (17.03 and higher) so we need to check if the reported ServerVersion starts with a compatible version
|
dockerVersion, err := semver.NewVersion(info.ServerVersion)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
for _, DockerVersion := range K8sDockerVersions[K8sVersion] {
|
for _, DockerVersion := range K8sDockerVersions[K8sVersion] {
|
||||||
DockerVersionRegexp := regexp.MustCompile("^" + DockerVersion)
|
supportedDockerVersion, err := convertToSemver(DockerVersion)
|
||||||
if DockerVersionRegexp.MatchString(info.ServerVersion) {
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
if dockerVersion.Major == supportedDockerVersion.Major && dockerVersion.Minor == supportedDockerVersion.Minor {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,3 +368,12 @@ func GetImageRegistryConfig(image string, prsMap map[string]v3.PrivateRegistry)
|
|||||||
}
|
}
|
||||||
return "", "", nil
|
return "", "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func convertToSemver(version string) (*semver.Version, error) {
|
||||||
|
compVersion := strings.SplitN(version, ".", 3)
|
||||||
|
if len(compVersion) != 3 {
|
||||||
|
return nil, fmt.Errorf("The default version is not correct")
|
||||||
|
}
|
||||||
|
compVersion[2] = "0"
|
||||||
|
return semver.NewVersion(strings.Join(compVersion, "."))
|
||||||
|
}
|
||||||
|
@ -8,13 +8,14 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"net"
|
||||||
|
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
"github.com/rancher/rke/docker"
|
"github.com/rancher/rke/docker"
|
||||||
"github.com/rancher/rke/log"
|
"github.com/rancher/rke/log"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/crypto/ssh"
|
"golang.org/x/crypto/ssh"
|
||||||
"golang.org/x/crypto/ssh/agent"
|
"golang.org/x/crypto/ssh/agent"
|
||||||
"net"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
Loading…
Reference in New Issue
Block a user