Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
cff2746e
Unverified
Commit
cff2746e
authored
Apr 05, 2019
by
Steven Sheehy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sub-command support to plugin downloader
Signed-off-by:
Steven Sheehy
<
ssheehy@firescope.com
>
parent
53d432fa
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
2 deletions
+36
-2
plugins.md
docs/plugins.md
+5
-0
plugingetter.go
pkg/getter/plugingetter.go
+4
-2
plugingetter_test.go
pkg/getter/plugingetter_test.go
+27
-0
No files found.
docs/plugins.md
View file @
cff2746e
...
...
@@ -144,6 +144,11 @@ The defined command will be invoked with the following scheme:
repo definition, stored in
`$HELM_HOME/repository/repositories.yaml`
. Downloader
plugin is expected to dump the raw content to stdout and report errors on stderr.
The downloader command also supports sub-commands or arguments, allowing you to specify
for example
`bin/mydownloader subcommand -d`
in the
`plugin.yaml`
. This is useful
if you want to use the same executable for the main plugin command and the downloader
command, but with a different sub-command for each.
## Environment Variables
When Helm executes a plugin, it passes the outer environment to the plugin, and
...
...
pkg/getter/plugingetter.go
View file @
cff2746e
...
...
@@ -21,6 +21,7 @@ import (
"os"
"os/exec"
"path/filepath"
"strings"
"k8s.io/helm/pkg/helm/environment"
"k8s.io/helm/pkg/plugin"
...
...
@@ -62,8 +63,9 @@ type pluginGetter struct {
// Get runs downloader plugin command
func
(
p
*
pluginGetter
)
Get
(
href
string
)
(
*
bytes
.
Buffer
,
error
)
{
argv
:=
[]
string
{
p
.
certFile
,
p
.
keyFile
,
p
.
cAFile
,
href
}
prog
:=
exec
.
Command
(
filepath
.
Join
(
p
.
base
,
p
.
command
),
argv
...
)
commands
:=
strings
.
Split
(
p
.
command
,
" "
)
argv
:=
append
(
commands
[
1
:
],
p
.
certFile
,
p
.
keyFile
,
p
.
cAFile
,
href
)
prog
:=
exec
.
Command
(
filepath
.
Join
(
p
.
base
,
commands
[
0
]),
argv
...
)
plugin
.
SetupPluginEnv
(
p
.
settings
,
p
.
name
,
p
.
base
)
prog
.
Env
=
os
.
Environ
()
buf
:=
bytes
.
NewBuffer
(
nil
)
...
...
pkg/getter/plugingetter_test.go
View file @
cff2746e
...
...
@@ -94,3 +94,30 @@ func TestPluginGetter(t *testing.T) {
t
.
Errorf
(
"Expected %q, got %q"
,
expect
,
got
)
}
}
func
TestPluginSubCommands
(
t
*
testing
.
T
)
{
if
runtime
.
GOOS
==
"windows"
{
t
.
Skip
(
"TODO: refactor this test to work on windows"
)
}
oldhh
:=
os
.
Getenv
(
"HELM_HOME"
)
defer
os
.
Setenv
(
"HELM_HOME"
,
oldhh
)
os
.
Setenv
(
"HELM_HOME"
,
""
)
env
:=
hh
(
false
)
pg
:=
newPluginGetter
(
"echo -n"
,
env
,
"test"
,
"."
)
g
,
err
:=
pg
(
"test://foo/bar"
,
""
,
""
,
""
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
data
,
err
:=
g
.
Get
(
"test://foo/bar"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
expect
:=
" test://foo/bar"
got
:=
data
.
String
()
if
got
!=
expect
{
t
.
Errorf
(
"Expected %q, got %q"
,
expect
,
got
)
}
}
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