-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #195 from nats-io/nats-v2-default
Update to use NATS v2 image by default
- Loading branch information
Showing
12 changed files
with
118 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package versionCheck | ||
|
||
import ( | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
const ( | ||
// OldNatsBinaryPath is the path to the NATS binary inside the | ||
// main container, before NATS Server v2. | ||
OldNatsBinaryPath = "/gnatsd" | ||
|
||
// NatsBinaryPath after v2 release. | ||
NatsBinaryPath = "/nats-server" | ||
) | ||
|
||
func ServerBinaryPath(version string) string { | ||
v := strings.Split(version, ".") | ||
if len(v) > 0 { | ||
majorVersion, err := strconv.Atoi(v[0]) | ||
if err != nil { | ||
return NatsBinaryPath | ||
} | ||
if majorVersion < 2 { | ||
return OldNatsBinaryPath | ||
} | ||
} | ||
return NatsBinaryPath | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package versionCheck | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestServerBinaryPath(t *testing.T) { | ||
got := ServerBinaryPath("2.0.0") | ||
expected := NatsBinaryPath | ||
if got != expected { | ||
t.Fatalf("Expected %q, got: %q", expected, got) | ||
} | ||
|
||
got = ServerBinaryPath("2.1.8") | ||
expected = NatsBinaryPath | ||
if got != expected { | ||
t.Fatalf("Expected %q, got: %q", expected, got) | ||
} | ||
|
||
got = ServerBinaryPath("2.1.8-RC18") | ||
expected = NatsBinaryPath | ||
if got != expected { | ||
t.Fatalf("Expected %q, got: %q", expected, got) | ||
} | ||
|
||
got = ServerBinaryPath("0.1.8") | ||
expected = OldNatsBinaryPath | ||
if got != expected { | ||
t.Fatalf("Expected %q, got: %q", expected, got) | ||
} | ||
|
||
got = ServerBinaryPath("1.4.1") | ||
expected = OldNatsBinaryPath | ||
if got != expected { | ||
t.Fatalf("Expected %q, got: %q", expected, got) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters