Skip to content
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

Update tools #1072

Merged
merged 8 commits into from
Nov 7, 2019
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion hack/go_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ run_in_go_container() {
`# docker options: remove container on exit, run as the host user / group` \
--rm --user "$(id -u):$(id -g)" \
`# golang caching: mount and use the cache volume` \
-v "${CACHE_VOLUME}:/go" -e GOCACHE=/go/cache \
-v "${CACHE_VOLUME}:/go" -e GOCACHE=/go/cache -e XDG_CACHE_HOME=/go \
BenTheElder marked this conversation as resolved.
Show resolved Hide resolved
`# mount the output & source dir, set working directory to the source dir` \
-v "${OUT_DIR}:/out" -v "${SOURCE_DIR}:/src" -w "/src" \
`# pass through go settings: modules, proxy, cgo, OS / Arch` \
Expand Down
31 changes: 6 additions & 25 deletions hack/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,13 @@ module sigs.k8s.io/kind/hack/tools
go 1.13

require (
github.com/golangci/golangci-lint v1.17.2-0.20190714145355-d2b1eea2c617
github.com/spf13/pflag v1.0.3 // indirect
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 // indirect
golang.org/x/tools v0.0.0-20190606174628-0139d5756a7d // indirect
gotest.tools/gotestsum v0.3.5
github.com/golangci/golangci-lint v1.21.0
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/mattn/go-isatty v0.0.10 // indirect
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect
golang.org/x/sys v0.0.0-20191105231009-c1f44814a5cd // indirect
gotest.tools/gotestsum v0.4.0
k8s.io/code-generator v0.0.0-20190311093542-50b561225d70
k8s.io/gengo v0.0.0-20190327210449-e17681d19d3a // indirect
k8s.io/klog v0.3.0 // indirect
)

// deal with golangci-lint being broken

replace github.com/golangci/errcheck v0.0.0-20181003203344-ef45e06d44b6 => github.com/golangci/errcheck v0.0.0-20181223084120-ef45e06d44b6

replace github.com/golangci/go-tools v0.0.0-20180109140146-af6baa5dc196 => github.com/golangci/go-tools v0.0.0-20190318060251-af6baa5dc196

replace github.com/golangci/gofmt v0.0.0-20181105071733-0b8337e80d98 => github.com/golangci/gofmt v0.0.0-20181222123516-0b8337e80d98

replace github.com/golangci/gosec v0.0.0-20180901114220-66fb7fc33547 => github.com/golangci/gosec v0.0.0-20190211064107-66fb7fc33547

replace github.com/golangci/lint-1 v0.0.0-20180610141402-ee948d087217 => github.com/golangci/lint-1 v0.0.0-20190420132249-ee948d087217

replace github.com/go-critic/go-critic v0.0.0-20181204210945-1df300866540 => github.com/go-critic/go-critic v0.0.0-20190526074819-1df300866540

replace mvdan.cc/unparam v0.0.0-20190124213536-fbb59629db34 => mvdan.cc/unparam v0.0.0-20190209190245-fbb59629db34

replace github.com/golangci/ineffassign v0.0.0-20180808204949-42439a7714cc => github.com/golangci/ineffassign v0.0.0-20190609212857-42439a7714cc

replace github.com/timakin/bodyclose => github.com/golangci/bodyclose v0.0.0-20190714144026-65da19158fa2
276 changes: 210 additions & 66 deletions hack/tools/go.sum

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions hack/tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import (
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"

// kubernetes code generators
_ "k8s.io/code-generator/cmd/conversion-gen"
_ "k8s.io/code-generator/cmd/deepcopy-gen"
_ "k8s.io/code-generator/cmd/defaulter-gen"

// test runner
_ "gotest.tools/gotestsum"
Expand Down
7 changes: 1 addition & 6 deletions pkg/build/node/internal/kube/bazelbuildbits.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,7 @@ func (b *BazelBuildBits) Build() error {
b.paths = b.findPaths(bazelGoosGoarch)

// capture version info
_, err = buildVersionFile(b.logger, b.kubeRoot)
if err != nil {
return err
}

return nil
return buildVersionFile(b.logger, b.kubeRoot)
}

func (b *BazelBuildBits) findPaths(bazelGoosGoarch string) map[string]string {
Expand Down
3 changes: 1 addition & 2 deletions pkg/build/node/internal/kube/dockerbuildbits.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ func (b *DockerBuildBits) Build() error {
}

// capture version info
_, err = buildVersionFile(b.logger, b.kubeRoot)
return err
return buildVersionFile(b.logger, b.kubeRoot)
}

func dockerBuildOsAndArch(arch string) string {
Expand Down
16 changes: 8 additions & 8 deletions pkg/build/node/internal/kube/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,25 @@ import (
// ./_output/version based on hack/print-workspace-status.sh,
// these are built into the node image and consumed by the cluster tooling
// the raw version is also returned
func buildVersionFile(logger log.Logger, kubeRoot string) (string, error) {
func buildVersionFile(logger log.Logger, kubeRoot string) error {
cwd, err := os.Getwd()
if err != nil {
return "", err
return err
}
// make sure we cd back when done
defer func() {
// TODO(bentheelder): set return error?
_ = os.Chdir(cwd)
}()
if err := os.Chdir(kubeRoot); err != nil {
return "", err
return err
}

// get the version output
cmd := exec.Command("hack/print-workspace-status.sh")
output, err := exec.CombinedOutputLines(cmd)
if err != nil {
return "", err
return err
}

// we will place the file in _output with other build artifacts
Expand All @@ -66,7 +66,7 @@ func buildVersionFile(logger log.Logger, kubeRoot string) (string, error) {
parts := strings.SplitN(line, " ", 2)
if len(parts) != 2 {
logger.Error("Could not parse kubernetes version, output: " + strings.Join(output, "\n"))
return "", errors.New("could not parse kubernetes version")
return errors.New("could not parse kubernetes version")
}
if parts[0] == "gitVersion" {
version = parts[1]
Expand All @@ -75,13 +75,13 @@ func buildVersionFile(logger log.Logger, kubeRoot string) (string, error) {
[]byte(version),
0777,
); err != nil {
return "", errors.Wrap(err, "failed to write version file")
return errors.Wrap(err, "failed to write version file")
}
}
}
if version == "" {
logger.Error("Could not obtain kubernetes version, output: " + strings.Join(output, "\n"))
return "", errors.New("could not obtain kubernetes version")
return errors.New("could not obtain kubernetes version")
}
return version, nil
return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func TestPathForMerge(t *testing.T) {
assert.StringEqual(t, expected, result)
})
t.Run("KUBECONFIG select last if none exist", func(t *testing.T) {
kubeconfigEnvValue := strings.Join(append([]string{"/bogus/path", "/bogus/path/two"}), string(filepath.ListSeparator))
kubeconfigEnvValue := strings.Join([]string{"/bogus/path", "/bogus/path/two"}, string(filepath.ListSeparator))
result := PathForMerge("", func(s string) string {
return map[string]string{
"KUBECONFIG": kubeconfigEnvValue,
Expand Down