Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
fdd241a8
Commit
fdd241a8
authored
Apr 05, 2019
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mark staging go module files as generated, add script to lint dependencies
parent
20cece67
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
1 deletion
+97
-1
.gitattributes
.gitattributes
+2
-0
lint-dependencies.sh
hack/lint-dependencies.sh
+69
-0
pin-dependency.sh
hack/pin-dependency.sh
+26
-1
No files found.
.gitattributes
View file @
fdd241a8
...
@@ -7,3 +7,5 @@ test/test_owners.csv merge=union
...
@@ -7,3 +7,5 @@ test/test_owners.csv merge=union
**/generated.proto
**/generated.proto
**/types_swagger_doc_generated.go linguist-generated=true
**/types_swagger_doc_generated.go linguist-generated=true
api/openapi-spec/*.json linguist-generated=true
api/openapi-spec/*.json linguist-generated=true
staging/**/go.mod linguist-generated=true
staging/**/go.sum linguist-generated=true
hack/lint-dependencies.sh
0 → 100755
View file @
fdd241a8
#!/usr/bin/env bash
# Copyright 2019 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set
-o
errexit
set
-o
nounset
set
-o
pipefail
KUBE_ROOT
=
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
/..
source
"
${
KUBE_ROOT
}
/hack/lib/init.sh"
# Explicitly opt into go modules, even though we're inside a GOPATH directory
export
GO111MODULE
=
on
# Explicitly clear GOPATH, to ensure nothing this script calls makes use of that path info
export
GOPATH
=
# Explicitly clear GOFLAGS, since GOFLAGS=-mod=vendor breaks dependency resolution while rebuilding vendor
export
GOFLAGS
=
# Detect problematic GOPROXY settings that prevent lookup of dependencies
if
[[
"
${
GOPROXY
:-}
"
==
"off"
]]
;
then
kube::log::error
"Cannot run with
\$
GOPROXY=off"
exit
1
fi
kube::golang::verify_go_version
kube::util::require-jq
outdated
=
$(
go list
-m
-json
all | jq
-r
'
select(.Replace.Version != null) |
select(.Version != .Replace.Version) |
"\(.Path)
pinned: \(.Replace.Version)
preferred: \(.Version)
hack/pin-dependency.sh \(.Path) \(.Version)"
'
)
if
[[
-n
"
${
outdated
}
"
]]
;
then
echo
"These modules are pinned to versions different than the minimal preferred version."
echo
"That means that without require directives, a different version would be selected."
echo
"The command to switch to the minimal preferred version is listed for each module."
echo
""
echo
"
${
outdated
}
"
fi
unused
=
$(
comm
-23
\
<
(
go mod edit
-json
| jq
-r
'.Replace[] | select(.New.Version != null) | .Old.Path'
|
sort
)
\
<
(
go list
-m
-json
all | jq
-r
.Path |
sort
))
if
[[
-n
"
${
unused
}
"
]]
;
then
echo
""
echo
"Pinned module versions that aren't actually used:"
echo
"
${
unused
}
"
fi
if
[[
-n
"
${
unused
}${
outdated
}
"
]]
;
then
exit
1
fi
echo
"All pinned dependencies match their preferred version."
exit
0
hack/pin-dependency.sh
View file @
fdd241a8
...
@@ -35,7 +35,7 @@ export GOPATH=
...
@@ -35,7 +35,7 @@ export GOPATH=
export
GOFLAGS
=
export
GOFLAGS
=
# Detect problematic GOPROXY settings that prevent lookup of dependencies
# Detect problematic GOPROXY settings that prevent lookup of dependencies
if
[[
"
${
GOPROXY
:-}
"
==
"off"
]]
;
then
if
[[
"
${
GOPROXY
:-}
"
==
"off"
]]
;
then
kube::log::error
"Cannot run
hack/pin-dependency.sh
with
\$
GOPROXY=off"
kube::log::error
"Cannot run with
\$
GOPROXY=off"
exit
1
exit
1
fi
fi
...
@@ -54,12 +54,37 @@ if [[ -z "${dep}" || -z "${sha}" ]]; then
...
@@ -54,12 +54,37 @@ if [[ -z "${dep}" || -z "${sha}" ]]; then
exit
1
exit
1
fi
fi
_tmp
=
"
${
KUBE_ROOT
}
/_tmp"
cleanup
()
{
rm
-rf
"
${
_tmp
}
"
}
trap
"cleanup"
EXIT SIGINT
cleanup
mkdir
-p
"
${
_tmp
}
"
# Add the require directive
# Add the require directive
echo
"Running: go get
${
dep
}
@
${
sha
}
"
echo
"Running: go get
${
dep
}
@
${
sha
}
"
go get
-d
"
${
dep
}
@
${
sha
}
"
go get
-d
"
${
dep
}
@
${
sha
}
"
# Find the resolved version
# Find the resolved version
rev
=
$(
go mod edit
-json
| jq
-r
".Require[] | select(.Path ==
\"
${
dep
}
\"
) | .Version"
)
rev
=
$(
go mod edit
-json
| jq
-r
".Require[] | select(.Path ==
\"
${
dep
}
\"
) | .Version"
)
# No entry in go.mod, we must be using the natural version indirectly
if
[[
-z
"
${
rev
}
"
]]
;
then
# backup the go.mod file, since go list modifies it
cp
go.mod
"
${
_tmp
}
/go.mod.bak"
# find the revision
rev
=
$(
go list
-m
-json
"
${
dep
}
"
| jq
-r
.Version
)
# restore the go.mod file
mv
"
${
_tmp
}
/go.mod.bak"
go.mod
fi
# No entry found
if
[[
-z
"
${
rev
}
"
]]
;
then
echo
"Could not resolve
${
sha
}
"
exit
1
fi
echo
"Resolved to
${
dep
}
@
${
rev
}
"
echo
"Resolved to
${
dep
}
@
${
rev
}
"
# Add the replace directive
# Add the replace directive
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment