Skip to content

Commit

Permalink
Merge pull request #9740 from hakman/fix-goimports
Browse files Browse the repository at this point in the history
Fix update and verify goimports
  • Loading branch information
k8s-ci-robot authored Aug 12, 2020
2 parents c10d6c4 + ecc30f7 commit 04416c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion hack/update-goimports
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
14 changes: 10 additions & 4 deletions hack/verify-goimports
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 04416c3

Please sign in to comment.