Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
kube-bench
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
aquasecurity
kube-bench
Commits
e93bfc1a
Commit
e93bfc1a
authored
6 years ago
by
nshauli
Browse files
Options
Downloads
Patches
Plain Diff
search for the kubelet binary when it is not in the path
parent
da09e651
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/util.go
+6
-0
6 additions, 0 deletions
cmd/util.go
with
6 additions
and
0 deletions
cmd/util.go
+
6
−
0
View file @
e93bfc1a
...
@@ -289,6 +289,12 @@ func getKubeVersion() (string, error) {
...
@@ -289,6 +289,12 @@ func getKubeVersion() (string, error) {
if
err
!=
nil
{
if
err
!=
nil
{
_
,
err
=
exec
.
LookPath
(
"kubelet"
)
_
,
err
=
exec
.
LookPath
(
"kubelet"
)
if
err
!=
nil
{
if
err
!=
nil
{
// Search for the kubelet binary all over the filesystem and run the first match to get the kubernetes version
cmd
:=
exec
.
Command
(
"/bin/sh"
,
"-c"
,
"`find / -type f -executable -name kubelet 2>/dev/null | grep -m1 .` --version"
)
out
,
err
:=
cmd
.
CombinedOutput
()
if
err
==
nil
{
return
getVersionFromKubeletOutput
(
string
(
out
)),
nil
}
return
""
,
fmt
.
Errorf
(
"need kubectl or kubelet binaries to get kubernetes version"
)
return
""
,
fmt
.
Errorf
(
"need kubectl or kubelet binaries to get kubernetes version"
)
}
}
return
getKubeVersionFromKubelet
(),
nil
return
getKubeVersionFromKubelet
(),
nil
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment