Skip to content

Commit

Permalink
Merge pull request #5 from getporter/fix-ensure-kind-on-arm
Browse files Browse the repository at this point in the history
Fix EnsureKind on arm
  • Loading branch information
carolynvs committed Apr 6, 2022
2 parents 7001d7f + 98c3d46 commit 48da115
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.17

require (
github.com/Masterminds/semver/v3 v3.1.1
github.com/carolynvs/magex v0.7.0
github.com/carolynvs/magex v0.7.2
github.com/magefile/mage v1.11.0
github.com/stretchr/testify v1.7.0
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030I
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
github.com/andybalholm/brotli v1.0.0 h1:7UCwP93aiSfvWpapti8g88vVVGp2qqtGyePsSuDafo4=
github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
github.com/carolynvs/magex v0.7.0 h1:z5PaWogvA/kOHMYueXqlQBobXt32N/a7kZXPvK9V728=
github.com/carolynvs/magex v0.7.0/go.mod h1:vZB3BkRfkd5ZMtkxJkCGbdFyWGoZiuNPKhx6uEQARmY=
github.com/carolynvs/magex v0.7.2 h1:6IpoxUorSDOXtZmd72ExPCzQBxkeUj09JwJfnzf+9y8=
github.com/carolynvs/magex v0.7.2/go.mod h1:vZB3BkRfkd5ZMtkxJkCGbdFyWGoZiuNPKhx6uEQARmY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down
17 changes: 7 additions & 10 deletions tools/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package tools
import (
"fmt"
"log"
"os"
"runtime"
"strings"

Expand All @@ -16,7 +15,7 @@ import (

const (
// Version of KIND to install if not already present
DefaultKindVersion = "v0.10.0"
DefaultKindVersion = "v0.12.0"
)

// Fail if the go version doesn't match the specified constraint
Expand Down Expand Up @@ -80,19 +79,17 @@ func EnsureGitHubClient() {

// Install kind
func EnsureKind() {
EnsureKindAt(DefaultKindVersion)
}

// Install kind at the specified version
func EnsureKindAt(version string) {
if ok, _ := pkg.IsCommandAvailable("kind", ""); ok {
return
}

kindURL := "https://github.com/kubernetes-sigs/kind/releases/download/{{.VERSION}}/kind-{{.GOOS}}-{{.GOARCH}}"
mgx.Must(pkg.DownloadToGopathBin(kindURL, "kind", getKindVersion()))
}

func getKindVersion() string {
if version, ok := os.LookupEnv("KIND_VERSION"); ok {
return version
}
return DefaultKindVersion
mgx.Must(pkg.DownloadToGopathBin(kindURL, "kind", version))
}

// Install the latest version of porter
Expand Down
16 changes: 16 additions & 0 deletions tools/install_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package tools_test

import (
"get.porter.sh/magefiles/tools"
"github.com/carolynvs/magex/pkg"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)

func TestEnsureKind(t *testing.T) {
tools.EnsureKind()
found, err := pkg.IsCommandAvailable("kind", tools.DefaultKindVersion, "--version")
require.NoError(t, err)
assert.True(t, found)
}

0 comments on commit 48da115

Please sign in to comment.