8000 Allow client version to be 1 minor version greater than server version by asobti · Pull Request #50 · box/kube-applier · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Allow client version to be 1 minor version greater than server version #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion kube/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"log"
"math"
"os/exec"
"regexp"
"strconv"
Expand Down Expand Up @@ -122,7 +123,7 @@ func isCompatible(clientMajor, clientMinor, serverMajor, serverMinor string) err
}

minorDiff := serverMinorInt - clientMinorInt
if minorDiff != 0 && minorDiff != 1 {
if math.Abs(float64(minorDiff)) > 1 {
return incompatible
}
return nil
Expand Down
11 changes: 8 additions & 3 deletions kube/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package kube

import (
"fmt"
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

type testCase struct {
Expand Down Expand Up @@ -36,8 +37,12 @@ func TestClientIsCompatible(t *testing.T) {
tc = testCase{"1", "0", "1", "2", fmt.Errorf("Error: kubectl client and server versions are incompatible. Client is 1.0; server is 1.2. Client must be same minor release as server or one minor release behind server.")}
createAndAssert(t, tc)

// Client 1.2, Server 1.0
tc = testCase{"1", "2", "1", "0", fmt.Errorf("Error: kubectl client and server versions are incompatible. Client is 1.2; server is 1.0. Client must be same minor release as server or one minor release behind server.")}
createAndAssert(t, tc)

// Client 1.1, Server 1.0
tc = testCase{"1", "1", "1", "0", fmt.Errorf("Error: kubectl client and server versions are incompatible. Client is 1.1; server is 1.0. Client must be same minor release as server or one minor release behind server.")}
tc = testCase{"1", "1", "1", "0", nil}
createAndAssert(t, tc)

// Client 1.1, Server 1.1+
Expand All @@ -53,7 +58,7 @@ func TestClientIsCompatible(t *testing.T) {
createAndAssert(t, tc)

// Client 1.2, Server 1.1+
tc = testCase{"1", "2", "1", "1+", fmt.Errorf("Error: kubectl client and server versions are incompatible. Client is 1.2; server is 1.1+. Client must be same minor release as server or one minor release behind server.")}
tc = testCase{"1", "2", "1", "1+", nil}
createAndAssert(t, tc)
}

Expand Down
0