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
a2e57781
Commit
a2e57781
authored
Oct 11, 2016
by
Adam Reese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(helm): add kubeconfig context switching
closes: #1127
parent
7a5ee459
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
helm.go
cmd/helm/helm.go
+5
-3
tunnel.go
cmd/helm/tunnel.go
+12
-2
No files found.
cmd/helm/helm.go
View file @
a2e57781
...
...
@@ -35,8 +35,9 @@ const (
)
var
(
helmHome
string
tillerHost
string
helmHome
string
tillerHost
string
kubeContext
string
)
// flagDebug is a signal that the user wants additional output.
...
...
@@ -82,6 +83,7 @@ func newRootCmd(out io.Writer) *cobra.Command {
p
:=
cmd
.
PersistentFlags
()
p
.
StringVar
(
&
helmHome
,
"home"
,
home
,
"location of your Helm config. Overrides $HELM_HOME"
)
p
.
StringVar
(
&
tillerHost
,
"host"
,
thost
,
"address of tiller. Overrides $HELM_HOST"
)
p
.
StringVar
(
&
kubeContext
,
"kube-context"
,
""
,
"name of the kubeconfig context to use"
)
p
.
BoolVarP
(
&
flagDebug
,
"debug"
,
""
,
false
,
"enable verbose output"
)
rup
:=
newRepoUpdateCmd
(
out
)
...
...
@@ -124,7 +126,7 @@ func main() {
func
setupConnection
(
c
*
cobra
.
Command
,
args
[]
string
)
error
{
if
tillerHost
==
""
{
tunnel
,
err
:=
newTillerPortForwarder
(
tillerNamespace
)
tunnel
,
err
:=
newTillerPortForwarder
(
tillerNamespace
,
kubeContext
)
if
err
!=
nil
{
return
err
}
...
...
cmd/helm/tunnel.go
View file @
a2e57781
...
...
@@ -21,6 +21,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/helm/pkg/kube"
...
...
@@ -29,8 +30,17 @@ import (
// TODO refactor out this global var
var
tunnel
*
kube
.
Tunnel
func
newTillerPortForwarder
(
namespace
string
)
(
*
kube
.
Tunnel
,
error
)
{
kc
:=
kube
.
New
(
nil
)
func
getKubeConfig
(
context
string
)
clientcmd
.
ClientConfig
{
rules
:=
clientcmd
.
NewDefaultClientConfigLoadingRules
()
overrides
:=
&
clientcmd
.
ConfigOverrides
{}
if
context
!=
""
{
overrides
.
CurrentContext
=
context
}
return
clientcmd
.
NewNonInteractiveDeferredLoadingClientConfig
(
rules
,
overrides
)
}
func
newTillerPortForwarder
(
namespace
,
context
string
)
(
*
kube
.
Tunnel
,
error
)
{
kc
:=
kube
.
New
(
getKubeConfig
(
context
))
client
,
err
:=
kc
.
Client
()
if
err
!=
nil
{
return
nil
,
err
...
...
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