From ecc30f7b4726b03ab173fe8086ab00ed2c1bf81a Mon Sep 17 00:00:00 2001 From: Ciprian Hacman <ciprian.hacman@sematext.com> Date: Wed, 12 Aug 2020 15:35:02 +0300 Subject: [PATCH] Fix update and verify goimports --- hack/update-goimports | 2 +- hack/verify-goimports | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/hack/update-goimports b/hack/update-goimports index 589d665939151..930cd434187dd 100755 --- a/hack/update-goimports +++ b/hack/update-goimports @@ -36,4 +36,4 @@ for package in packages: print("packages %s" % paths) -subprocess.call(['go', 'run', 'golang.org/x/tools/cmd/goimports', '-w'] + paths, cwd=path.join(gopath, 'src')) +subprocess.call(['go', 'run', 'k8s.io/kops/vendor/golang.org/x/tools/cmd/goimports', '-w'] + paths, cwd=path.join(gopath, 'src')) diff --git a/hack/verify-goimports b/hack/verify-goimports index 92fb895a12138..dbe7094885667 100755 --- a/hack/verify-goimports +++ b/hack/verify-goimports @@ -47,13 +47,19 @@ if process.returncode != 0: print("packages %s" % paths) env = os.environ -env["GO111MODULE"] = "on" -process = subprocess.Popen(['go', 'run', 'golang.org/x/tools/cmd/goimports', '-l'] + paths, stdout=subprocess.PIPE, cwd=path.join(gopath, 'src'), env=env) +process = subprocess.Popen( + ['go', 'run', 'k8s.io/kops/vendor/golang.org/x/tools/cmd/goimports', '-l'] + paths, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd=path.join(gopath, 'src'), + env=env +) stdout, stderr = process.communicate() -if stdout.strip().decode('ascii') != "": +if stdout.strip().decode('ascii') != "" or stderr.strip().decode('ascii') != "": print("FAIL: 'goimports -w' needs to be run on the following files: ") - print(stdout.decode('ascii')) + print("STDOUT:\n" + stdout.decode('ascii')) + print("STDERR:\n" + stderr.decode('ascii')) print('FAIL: Please run the following command: make goimports') sys.exit(1)