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
9a36d556
Commit
9a36d556
authored
May 15, 2017
by
Kazuki Suda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubectl plugin: Expand environment variables in the command of plugin.yaml
This commit improves kubectl plugins to expand environment variables in the command of plugin.yaml.
parent
c873e4a8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
runner.go
pkg/kubectl/plugins/runner.go
+2
-1
runner_test.go
pkg/kubectl/plugins/runner_test.go
+9
-0
No files found.
pkg/kubectl/plugins/runner.go
View file @
9a36d556
...
@@ -18,6 +18,7 @@ package plugins
...
@@ -18,6 +18,7 @@ package plugins
import
(
import
(
"io"
"io"
"os"
"os/exec"
"os/exec"
"strings"
"strings"
...
@@ -47,7 +48,7 @@ type ExecPluginRunner struct{}
...
@@ -47,7 +48,7 @@ type ExecPluginRunner struct{}
// Run takes a given plugin and runs it in a given context using os/exec, returning
// Run takes a given plugin and runs it in a given context using os/exec, returning
// any error found while running.
// any error found while running.
func
(
r
*
ExecPluginRunner
)
Run
(
plugin
*
Plugin
,
ctx
RunningContext
)
error
{
func
(
r
*
ExecPluginRunner
)
Run
(
plugin
*
Plugin
,
ctx
RunningContext
)
error
{
command
:=
strings
.
Split
(
plugin
.
Command
,
" "
)
command
:=
strings
.
Split
(
os
.
ExpandEnv
(
plugin
.
Command
)
,
" "
)
base
:=
command
[
0
]
base
:=
command
[
0
]
args
:=
[]
string
{}
args
:=
[]
string
{}
if
len
(
command
)
>
1
{
if
len
(
command
)
>
1
{
...
...
pkg/kubectl/plugins/runner_test.go
View file @
9a36d556
...
@@ -18,6 +18,7 @@ package plugins
...
@@ -18,6 +18,7 @@ package plugins
import
(
import
(
"bytes"
"bytes"
"os"
"testing"
"testing"
)
)
...
@@ -38,8 +39,16 @@ func TestExecRunner(t *testing.T) {
...
@@ -38,8 +39,16 @@ func TestExecRunner(t *testing.T) {
command
:
"false"
,
command
:
"false"
,
expectedErr
:
"exit status 1"
,
expectedErr
:
"exit status 1"
,
},
},
{
name
:
"env"
,
command
:
"echo $KUBECTL_PLUGINS_TEST"
,
expectedMsg
:
"ok
\n
"
,
},
}
}
os
.
Setenv
(
"KUBECTL_PLUGINS_TEST"
,
"ok"
)
defer
os
.
Unsetenv
(
"KUBECTL_PLUGINS_TEST"
)
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
outBuf
:=
bytes
.
NewBuffer
([]
byte
{})
outBuf
:=
bytes
.
NewBuffer
([]
byte
{})
...
...
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