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
ea3be9e3
Commit
ea3be9e3
authored
Dec 07, 2016
by
Adam Reese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(*): migrate to kubernetes 1.5
parent
649396e8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
135 additions
and
135 deletions
+135
-135
helm.go
cmd/helm/helm.go
+5
-5
init.go
cmd/helm/init.go
+8
-5
init_test.go
cmd/helm/init_test.go
+39
-15
install.go
cmd/helm/installer/install.go
+12
-11
install_test.go
cmd/helm/installer/install_test.go
+14
-13
tunnel.go
cmd/helm/tunnel.go
+5
-5
tunnel_test.go
cmd/helm/tunnel_test.go
+3
-3
tiller.go
cmd/tiller/tiller.go
+2
-2
glide.lock
glide.lock
+0
-0
glide.yaml
glide.yaml
+4
-23
client.go
pkg/kube/client.go
+3
-14
client_test.go
pkg/kube/client_test.go
+10
-11
tunnel.go
pkg/kube/tunnel.go
+2
-2
cfgmaps.go
pkg/storage/driver/cfgmaps.go
+6
-7
mock_test.go
pkg/storage/driver/mock_test.go
+3
-3
environment.go
pkg/tiller/environment/environment.go
+7
-7
environment_test.go
pkg/tiller/environment/environment_test.go
+4
-6
release_server.go
pkg/tiller/release_server.go
+8
-3
No files found.
cmd/helm/helm.go
View file @
ea3be9e3
...
...
@@ -28,18 +28,18 @@ import (
"github.com/spf13/cobra"
"google.golang.org/grpc"
"google.golang.org/grpc/grpclog"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/helm/cmd/helm/helmpath"
"k8s.io/helm/pkg/kube"
"k8s.io/helm/pkg/tiller/environment"
)
const
(
localRepoIndexFilePath
=
"index.yaml"
homeEnvVar
=
"HELM_HOME"
hostEnvVar
=
"HELM_HOST"
tillerNamespace
=
"kube-system"
)
var
(
...
...
@@ -145,7 +145,7 @@ func main() {
func
setupConnection
(
c
*
cobra
.
Command
,
args
[]
string
)
error
{
if
tillerHost
==
""
{
tunnel
,
err
:=
newTillerPortForwarder
(
t
illerNamespace
,
kubeContext
)
tunnel
,
err
:=
newTillerPortForwarder
(
environment
.
T
illerNamespace
,
kubeContext
)
if
err
!=
nil
{
return
err
}
...
...
@@ -199,12 +199,12 @@ func homePath() string {
// getKubeClient is a convenience method for creating kubernetes config and client
// for a given kubeconfig context
func
getKubeClient
(
context
string
)
(
*
restclient
.
Config
,
*
unversioned
.
Clien
t
,
error
)
{
func
getKubeClient
(
context
string
)
(
*
restclient
.
Config
,
*
internalclientset
.
Clientse
t
,
error
)
{
config
,
err
:=
kube
.
GetConfig
(
context
)
.
ClientConfig
()
if
err
!=
nil
{
return
nil
,
nil
,
fmt
.
Errorf
(
"could not get kubernetes config for context '%s': %s"
,
context
,
err
)
}
client
,
err
:=
unversioned
.
New
(
config
)
client
,
err
:=
internalclientset
.
NewForConfig
(
config
)
if
err
!=
nil
{
return
nil
,
nil
,
fmt
.
Errorf
(
"could not get kubernetes client: %s"
,
err
)
}
...
...
cmd/helm/init.go
View file @
ea3be9e3
...
...
@@ -24,11 +24,12 @@ import (
"github.com/spf13/cobra"
kerrors
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/client/unversioned
"
extensionsclient
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/extensions/internalversion
"
"k8s.io/helm/cmd/helm/helmpath"
"k8s.io/helm/cmd/helm/installer"
"k8s.io/helm/pkg/repo"
"k8s.io/helm/pkg/tiller/environment"
)
const
initDesc
=
`
...
...
@@ -65,15 +66,17 @@ type initCmd struct {
image
string
clientOnly
bool
canary
bool
namespace
string
dryRun
bool
out
io
.
Writer
home
helmpath
.
Home
kubeClient
unversioned
.
DeploymentsNamespac
er
kubeClient
extensionsclient
.
DeploymentsGett
er
}
func
newInitCmd
(
out
io
.
Writer
)
*
cobra
.
Command
{
i
:=
&
initCmd
{
out
:
out
,
out
:
out
,
namespace
:
environment
.
TillerNamespace
,
}
cmd
:=
&
cobra
.
Command
{
...
...
@@ -102,7 +105,7 @@ func newInitCmd(out io.Writer) *cobra.Command {
func
(
i
*
initCmd
)
run
()
error
{
if
flagDebug
{
m
,
err
:=
installer
.
DeploymentManifest
(
i
.
image
,
i
.
canary
)
m
,
err
:=
installer
.
DeploymentManifest
(
i
.
namespace
,
i
.
image
,
i
.
canary
)
if
err
!=
nil
{
return
err
}
...
...
@@ -124,7 +127,7 @@ func (i *initCmd) run() error {
}
i
.
kubeClient
=
c
}
if
err
:=
installer
.
Install
(
i
.
kubeClient
,
tillerN
amespace
,
i
.
image
,
i
.
canary
,
flagDebug
);
err
!=
nil
{
if
err
:=
installer
.
Install
(
i
.
kubeClient
,
i
.
n
amespace
,
i
.
image
,
i
.
canary
,
flagDebug
);
err
!=
nil
{
if
!
kerrors
.
IsAlreadyExists
(
err
)
{
return
fmt
.
Errorf
(
"error installing: %s"
,
err
)
}
...
...
cmd/helm/init_test.go
View file @
ea3be9e3
...
...
@@ -27,7 +27,9 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake"
testcore
"k8s.io/kubernetes/pkg/client/testing/core"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/helm/cmd/helm/helmpath"
...
...
@@ -41,14 +43,19 @@ func TestInitCmd(t *testing.T) {
defer
os
.
Remove
(
home
)
var
buf
bytes
.
Buffer
fake
:=
testclient
.
Fake
{}
cmd
:=
&
initCmd
{
out
:
&
buf
,
home
:
helmpath
.
Home
(
home
),
kubeClient
:
fake
.
Extensions
()}
fc
:=
fake
.
NewSimpleClientset
()
cmd
:=
&
initCmd
{
out
:
&
buf
,
home
:
helmpath
.
Home
(
home
),
kubeClient
:
fc
.
Extensions
(),
namespace
:
api
.
NamespaceDefault
,
}
if
err
:=
cmd
.
run
();
err
!=
nil
{
t
.
Errorf
(
"expected error: %v"
,
err
)
}
action
s
:=
fake
.
Actions
()
if
action
,
ok
:=
actions
[
0
]
.
(
testclient
.
CreateAction
);
!
ok
||
action
.
GetResource
()
!=
"deployments"
{
t
.
Errorf
(
"unexpected action: %v, expected create deployment"
,
action
s
[
0
]
)
action
:=
fc
.
Actions
()[
0
]
if
!
action
.
Matches
(
"create"
,
"deployments"
)
{
t
.
Errorf
(
"unexpected action: %v, expected create deployment"
,
action
)
}
expected
:=
"Tiller (the helm server side component) has been installed into your Kubernetes Cluster."
if
!
strings
.
Contains
(
buf
.
String
(),
expected
)
{
...
...
@@ -64,11 +71,21 @@ func TestInitCmd_exsits(t *testing.T) {
defer
os
.
Remove
(
home
)
var
buf
bytes
.
Buffer
fake
:=
testclient
.
Fake
{}
fake
.
AddReactor
(
"*"
,
"*"
,
func
(
action
testclient
.
Action
)
(
bool
,
runtime
.
Object
,
error
)
{
fc
:=
fake
.
NewSimpleClientset
(
&
extensions
.
Deployment
{
ObjectMeta
:
api
.
ObjectMeta
{
Namespace
:
api
.
NamespaceDefault
,
Name
:
"tiller-deploy"
,
},
})
fc
.
AddReactor
(
"*"
,
"*"
,
func
(
action
testcore
.
Action
)
(
bool
,
runtime
.
Object
,
error
)
{
return
true
,
nil
,
errors
.
NewAlreadyExists
(
api
.
Resource
(
"deployments"
),
"1"
)
})
cmd
:=
&
initCmd
{
out
:
&
buf
,
home
:
helmpath
.
Home
(
home
),
kubeClient
:
fake
.
Extensions
()}
cmd
:=
&
initCmd
{
out
:
&
buf
,
home
:
helmpath
.
Home
(
home
),
kubeClient
:
fc
.
Extensions
(),
namespace
:
api
.
NamespaceDefault
,
}
if
err
:=
cmd
.
run
();
err
!=
nil
{
t
.
Errorf
(
"expected error: %v"
,
err
)
}
...
...
@@ -86,12 +103,18 @@ func TestInitCmd_clientOnly(t *testing.T) {
defer
os
.
Remove
(
home
)
var
buf
bytes
.
Buffer
fake
:=
testclient
.
Fake
{}
cmd
:=
&
initCmd
{
out
:
&
buf
,
home
:
helmpath
.
Home
(
home
),
kubeClient
:
fake
.
Extensions
(),
clientOnly
:
true
}
fc
:=
fake
.
NewSimpleClientset
()
cmd
:=
&
initCmd
{
out
:
&
buf
,
home
:
helmpath
.
Home
(
home
),
kubeClient
:
fc
.
Extensions
(),
clientOnly
:
true
,
namespace
:
api
.
NamespaceDefault
,
}
if
err
:=
cmd
.
run
();
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
if
len
(
f
ake
.
Actions
())
!=
0
{
if
len
(
f
c
.
Actions
())
!=
0
{
t
.
Error
(
"expected client call"
)
}
expected
:=
"Not installing tiller due to 'client-only' flag having been set"
...
...
@@ -114,18 +137,19 @@ func TestInitCmd_dryRun(t *testing.T) {
}()
var
buf
bytes
.
Buffer
f
ake
:=
testclient
.
Fake
{}
f
c
:=
fake
.
NewSimpleClientset
()
cmd
:=
&
initCmd
{
out
:
&
buf
,
home
:
helmpath
.
Home
(
home
),
kubeClient
:
f
ake
.
Extensions
(),
kubeClient
:
f
c
.
Extensions
(),
clientOnly
:
true
,
dryRun
:
true
,
namespace
:
api
.
NamespaceDefault
,
}
if
err
:=
cmd
.
run
();
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
len
(
f
ake
.
Actions
())
!=
0
{
if
len
(
f
c
.
Actions
())
!=
0
{
t
.
Error
(
"expected no server calls"
)
}
...
...
cmd/helm/installer/install.go
View file @
ea3be9e3
...
...
@@ -23,7 +23,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/client/unversioned
"
extensionsclient
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/extensions/internalversion
"
"k8s.io/kubernetes/pkg/util/intstr"
"k8s.io/helm/pkg/version"
...
...
@@ -37,27 +37,27 @@ const defaultImage = "gcr.io/kubernetes-helm/tiller"
// command failed.
//
// If verbose is true, this will print the manifest to stdout.
func
Install
(
client
unversioned
.
DeploymentsNamespac
er
,
namespace
,
image
string
,
canary
,
verbose
bool
)
error
{
obj
:=
deployment
(
image
,
canary
)
_
,
err
:=
client
.
Deployments
(
n
amespace
)
.
Create
(
obj
)
func
Install
(
client
extensionsclient
.
DeploymentsGett
er
,
namespace
,
image
string
,
canary
,
verbose
bool
)
error
{
obj
:=
deployment
(
namespace
,
image
,
canary
)
_
,
err
:=
client
.
Deployments
(
obj
.
N
amespace
)
.
Create
(
obj
)
return
err
}
// deployment gets the deployment object that installs Tiller.
func
deployment
(
image
string
,
canary
bool
)
*
extensions
.
Deployment
{
func
deployment
(
namespace
,
image
string
,
canary
bool
)
*
extensions
.
Deployment
{
switch
{
case
canary
:
image
=
defaultImage
+
":canary"
case
image
==
""
:
image
=
fmt
.
Sprintf
(
"%s:%s"
,
defaultImage
,
version
.
Version
)
}
return
generateDeployment
(
image
)
return
generateDeployment
(
namespace
,
image
)
}
// DeploymentManifest gets the manifest (as a string) that describes the Tiller Deployment
// resource.
func
DeploymentManifest
(
image
string
,
canary
bool
)
(
string
,
error
)
{
obj
:=
deployment
(
image
,
canary
)
func
DeploymentManifest
(
namespace
,
image
string
,
canary
bool
)
(
string
,
error
)
{
obj
:=
deployment
(
namespace
,
image
,
canary
)
buf
,
err
:=
yaml
.
Marshal
(
obj
)
return
string
(
buf
),
err
...
...
@@ -68,12 +68,13 @@ func generateLabels(labels map[string]string) map[string]string {
return
labels
}
func
generateDeployment
(
image
string
)
*
extensions
.
Deployment
{
func
generateDeployment
(
namespace
,
image
string
)
*
extensions
.
Deployment
{
labels
:=
generateLabels
(
map
[
string
]
string
{
"name"
:
"tiller"
})
d
:=
&
extensions
.
Deployment
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"tiller-deploy"
,
Labels
:
labels
,
Namespace
:
namespace
,
Name
:
"tiller-deploy"
,
Labels
:
labels
,
},
Spec
:
extensions
.
DeploymentSpec
{
Replicas
:
1
,
...
...
cmd/helm/installer/install_test.go
View file @
ea3be9e3
...
...
@@ -21,12 +21,13 @@ import (
"testing"
"github.com/ghodss/yaml"
"k8s.io/helm/pkg/version"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake"
testcore
"k8s.io/kubernetes/pkg/client/testing/core"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/helm/pkg/version"
)
func
TestDeploymentManifest
(
t
*
testing
.
T
)
{
...
...
@@ -44,7 +45,7 @@ func TestDeploymentManifest(t *testing.T) {
for
_
,
tt
:=
range
tests
{
o
,
err
:=
DeploymentManifest
(
tt
.
image
,
tt
.
canary
)
o
,
err
:=
DeploymentManifest
(
api
.
NamespaceDefault
,
tt
.
image
,
tt
.
canary
)
if
err
!=
nil
{
t
.
Fatalf
(
"%s: error %q"
,
tt
.
name
,
err
)
}
...
...
@@ -62,9 +63,9 @@ func TestDeploymentManifest(t *testing.T) {
func
TestInstall
(
t
*
testing
.
T
)
{
image
:=
"gcr.io/kubernetes-helm/tiller:v2.0.0"
fake
:=
testclient
.
Fake
{}
fake
.
AddReactor
(
"create"
,
"deployments"
,
func
(
action
testc
lient
.
Action
)
(
bool
,
runtime
.
Object
,
error
)
{
obj
:=
action
.
(
testc
lient
.
CreateAction
)
.
GetObject
()
.
(
*
extensions
.
Deployment
)
fake
:=
fake
.
NewSimpleClientset
()
fake
.
AddReactor
(
"create"
,
"deployments"
,
func
(
action
testc
ore
.
Action
)
(
bool
,
runtime
.
Object
,
error
)
{
obj
:=
action
.
(
testc
ore
.
CreateAction
)
.
GetObject
()
.
(
*
extensions
.
Deployment
)
l
:=
obj
.
GetLabels
()
if
reflect
.
DeepEqual
(
l
,
map
[
string
]
string
{
"app"
:
"helm"
})
{
t
.
Errorf
(
"expected labels = '', got '%s'"
,
l
)
...
...
@@ -76,16 +77,16 @@ func TestInstall(t *testing.T) {
return
true
,
obj
,
nil
})
err
:=
Install
(
fake
.
Extensions
(),
"default"
,
image
,
false
,
false
)
err
:=
Install
(
fake
.
Extensions
(),
api
.
NamespaceDefault
,
image
,
false
,
false
)
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %#+v"
,
err
)
}
}
func
TestInstall_canary
(
t
*
testing
.
T
)
{
fake
:=
testclient
.
Fake
{}
fake
.
AddReactor
(
"create"
,
"deployments"
,
func
(
action
testc
lient
.
Action
)
(
bool
,
runtime
.
Object
,
error
)
{
obj
:=
action
.
(
testc
lient
.
CreateAction
)
.
GetObject
()
.
(
*
extensions
.
Deployment
)
fake
:=
fake
.
NewSimpleClientset
()
fake
.
AddReactor
(
"create"
,
"deployments"
,
func
(
action
testc
ore
.
Action
)
(
bool
,
runtime
.
Object
,
error
)
{
obj
:=
action
.
(
testc
ore
.
CreateAction
)
.
GetObject
()
.
(
*
extensions
.
Deployment
)
i
:=
obj
.
Spec
.
Template
.
Spec
.
Containers
[
0
]
.
Image
if
i
!=
"gcr.io/kubernetes-helm/tiller:canary"
{
t
.
Errorf
(
"expected canary image, got '%s'"
,
i
)
...
...
@@ -93,7 +94,7 @@ func TestInstall_canary(t *testing.T) {
return
true
,
obj
,
nil
})
err
:=
Install
(
fake
.
Extensions
(),
"default"
,
""
,
true
,
false
)
err
:=
Install
(
fake
.
Extensions
(),
api
.
NamespaceDefault
,
""
,
true
,
false
)
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %#+v"
,
err
)
}
...
...
cmd/helm/tunnel.go
View file @
ea3be9e3
...
...
@@ -20,7 +20,7 @@ import (
"fmt"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/client/
unversioned
"
"k8s.io/kubernetes/pkg/client/
clientset_generated/internalclientset/typed/core/internalversion
"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/helm/pkg/kube"
...
...
@@ -35,16 +35,16 @@ func newTillerPortForwarder(namespace, context string) (*kube.Tunnel, error) {
return
nil
,
err
}
podName
,
err
:=
getTillerPodName
(
client
,
namespace
)
podName
,
err
:=
getTillerPodName
(
client
.
Core
()
,
namespace
)
if
err
!=
nil
{
return
nil
,
err
}
const
tillerPort
=
44134
t
:=
kube
.
NewTunnel
(
client
.
RESTClient
,
config
,
namespace
,
podName
,
tillerPort
)
t
:=
kube
.
NewTunnel
(
client
.
Core
()
.
RESTClient
()
,
config
,
namespace
,
podName
,
tillerPort
)
return
t
,
t
.
ForwardPort
()
}
func
getTillerPodName
(
client
unversioned
.
PodsNamespac
er
,
namespace
string
)
(
string
,
error
)
{
func
getTillerPodName
(
client
internalversion
.
PodsGett
er
,
namespace
string
)
(
string
,
error
)
{
// TODO use a const for labels
selector
:=
labels
.
Set
{
"app"
:
"helm"
,
"name"
:
"tiller"
}
.
AsSelector
()
pod
,
err
:=
getFirstRunningPod
(
client
,
namespace
,
selector
)
...
...
@@ -54,7 +54,7 @@ func getTillerPodName(client unversioned.PodsNamespacer, namespace string) (stri
return
pod
.
ObjectMeta
.
GetName
(),
nil
}
func
getFirstRunningPod
(
client
unversioned
.
PodsNamespac
er
,
namespace
string
,
selector
labels
.
Selector
)
(
*
api
.
Pod
,
error
)
{
func
getFirstRunningPod
(
client
internalversion
.
PodsGett
er
,
namespace
string
,
selector
labels
.
Selector
)
(
*
api
.
Pod
,
error
)
{
options
:=
api
.
ListOptions
{
LabelSelector
:
selector
}
pods
,
err
:=
client
.
Pods
(
namespace
)
.
List
(
options
)
if
err
!=
nil
{
...
...
cmd/helm/tunnel_test.go
View file @
ea3be9e3
...
...
@@ -20,7 +20,7 @@ import (
"testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/client/
unversioned/testclient
"
"k8s.io/kubernetes/pkg/client/
clientset_generated/internalclientset/fake
"
)
func
mockTillerPod
()
api
.
Pod
{
...
...
@@ -74,8 +74,8 @@ func TestGetFirstPod(t *testing.T) {
}
for
_
,
tt
:=
range
tests
{
client
:=
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
Items
:
tt
.
pods
})
name
,
err
:=
getTillerPodName
(
client
,
api
.
NamespaceDefault
)
client
:=
fake
.
NewSimpleClientset
(
&
api
.
PodList
{
Items
:
tt
.
pods
})
name
,
err
:=
getTillerPodName
(
client
.
Core
()
,
api
.
NamespaceDefault
)
if
(
err
!=
nil
)
!=
tt
.
err
{
t
.
Errorf
(
"%q. expected error: %v, got %v"
,
tt
.
name
,
tt
.
err
,
err
)
}
...
...
cmd/tiller/tiller.go
View file @
ea3be9e3
...
...
@@ -84,11 +84,11 @@ func start(c *cobra.Command, args []string) {
case
storageMemory
:
env
.
Releases
=
storage
.
Init
(
driver
.
NewMemory
())
case
storageConfigMap
:
c
,
err
:=
env
.
KubeClient
.
APIClien
t
()
c
,
err
:=
env
.
KubeClient
.
ClientSe
t
()
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"Cannot initialize Kubernetes connection: %s"
,
err
)
}
env
.
Releases
=
storage
.
Init
(
driver
.
NewConfigMaps
(
c
.
ConfigMaps
(
environment
.
TillerNamespace
)))
env
.
Releases
=
storage
.
Init
(
driver
.
NewConfigMaps
(
c
.
Co
re
()
.
Co
nfigMaps
(
environment
.
TillerNamespace
)))
}
lstn
,
err
:=
net
.
Listen
(
"tcp"
,
grpcAddr
)
...
...
glide.lock
View file @
ea3be9e3
This diff is collapsed.
Click to expand it.
glide.yaml
View file @
ea3be9e3
...
...
@@ -5,6 +5,9 @@ import:
subpackages
:
-
context
-
package
:
github.com/spf13/cobra
version
:
f62e98d28ab7ad31d707ba837a966378465c7b57
-
package
:
github.com/spf13/pflag
version
:
5ccb023bc27df288a957c5e994cd44fd19619465
-
package
:
github.com/Masterminds/sprig
version
:
^2.7
-
package
:
github.com/ghodss/yaml
...
...
@@ -20,29 +23,7 @@ import:
-
package
:
google.golang.org/grpc
version
:
1.0.3
-
package
:
k8s.io/kubernetes
version
:
~1.4.1
subpackages
:
-
pkg/api
-
pkg/api/errors
-
pkg/api/unversioned
-
pkg/apimachinery/registered
-
pkg/apis/batch
-
pkg/apis/extensions
-
pkg/client/restclient
-
pkg/client/unversioned
-
pkg/client/unversioned/clientcmd
-
pkg/client/unversioned/portforward
-
pkg/client/unversioned/remotecommand
-
pkg/client/unversioned/testclient
-
pkg/kubectl
-
pkg/kubectl/cmd/util
-
pkg/kubectl/resource
-
pkg/labels
-
pkg/runtime
-
pkg/util/intstr
-
pkg/util/strategicpatch
-
pkg/util/yaml
-
pkg/watch
version
:
1.5.0-beta.2
-
package
:
github.com/gosuri/uitable
-
package
:
github.com/asaskevich/govalidator
version
:
^4.0.0
...
...
pkg/kube/client.go
View file @
ea3be9e3
...
...
@@ -30,7 +30,6 @@ import (
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/apimachinery/registered"
"k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
"k8s.io/kubernetes/pkg/kubectl"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
...
...
@@ -46,7 +45,7 @@ var ErrNoObjectsVisited = goerrors.New("no objects visited")
// Client represents a client capable of communicating with the Kubernetes API.
type
Client
struct
{
*
cmdutil
.
Factory
cmdutil
.
Factory
// IncludeThirdPartyAPIs indicates whether to load "dynamic" APIs.
//
// This requires additional calls to the Kubernetes API server, and these calls
...
...
@@ -82,16 +81,6 @@ func (e ErrAlreadyExists) Error() string {
return
fmt
.
Sprintf
(
"Looks like there are no changes for %s"
,
e
.
errorMsg
)
}
// APIClient returns a Kubernetes API client.
//
// This is necessary because cmdutil.Client is a field, not a method, which
// means it can't satisfy an interface's method requirement. In order to ensure
// that an implementation of environment.KubeClient can access the raw API client,
// it is necessary to add this method.
func
(
c
*
Client
)
APIClient
()
(
unversioned
.
Interface
,
error
)
{
return
c
.
Client
()
}
// Create creates kubernetes resources from an io.reader
//
// Namespace will set the namespace
...
...
@@ -107,7 +96,7 @@ func (c *Client) newBuilder(namespace string, reader io.Reader) *resource.Builde
if
err
!=
nil
{
log
.
Printf
(
"warning: failed to load schema: %s"
,
err
)
}
return
c
.
NewBuilder
(
c
.
IncludeThirdPartyAPIs
)
.
return
c
.
NewBuilder
()
.
ContinueOnError
()
.
Schema
(
schema
)
.
NamespaceParam
(
namespace
)
.
...
...
@@ -414,7 +403,7 @@ func waitForJob(e watch.Event, name string) (bool, error) {
}
func
(
c
*
Client
)
ensureNamespace
(
namespace
string
)
error
{
client
,
err
:=
c
.
Client
()
client
,
err
:=
c
.
Client
Set
()
if
err
!=
nil
{
return
err
}
...
...
pkg/kube/client_test.go
View file @
ea3be9e3
...
...
@@ -30,7 +30,8 @@ import (
"k8s.io/kubernetes/pkg/api/unversioned"
api
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/validation"
"k8s.io/kubernetes/pkg/client/unversioned/fake"
"k8s.io/kubernetes/pkg/client/restclient/fake"
cmdtesting
"k8s.io/kubernetes/pkg/kubectl/cmd/testing"
"k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/runtime"
)
...
...
@@ -110,20 +111,18 @@ func TestPerform(t *testing.T) {
return
nil
}
c
:=
New
(
nil
)
c
.
IncludeThirdPartyAPIs
=
false
c
.
ClientForMapping
=
func
(
mapping
*
meta
.
RESTMapping
)
(
resource
.
RESTClient
,
error
)
{
return
&
fake
.
RESTClient
{},
nil
}
c
.
Validator
=
func
(
validate
bool
,
cacheDir
string
)
(
validation
.
Schema
,
error
)
{
if
tt
.
swaggerFile
==
""
{
return
validation
.
NullSchema
{},
nil
}
f
,
tf
,
_
,
_
:=
cmdtesting
.
NewAPIFactory
()
c
:=
&
Client
{
Factory
:
f
}
if
tt
.
swaggerFile
!=
""
{
data
,
err
:=
ioutil
.
ReadFile
(
tt
.
swaggerFile
)
if
err
!=
nil
{
t
.
Fatalf
(
"could not read swagger spec: %s"
,
err
)
}
validator
,
err
:=
validation
.
NewSwaggerSchemaFromBytes
(
data
,
nil
)
if
err
!=
nil
{
t
.
Fatalf
(
"could not load swagger spec: %s"
,
err
)
}
return
validation
.
NewSwaggerSchemaFromBytes
(
data
,
nil
)
tf
.
Validator
=
validator
}
err
:=
perform
(
c
,
tt
.
namespace
,
tt
.
reader
,
fn
)
...
...
pkg/kube/tunnel.go
View file @
ea3be9e3
...
...
@@ -38,11 +38,11 @@ type Tunnel struct {
stopChan
chan
struct
{}
readyChan
chan
struct
{}
config
*
restclient
.
Config
client
*
restclient
.
RESTClient
client
restclient
.
Interface
}
// NewTunnel creates a new tunnel
func
NewTunnel
(
client
*
restclient
.
RESTClient
,
config
*
restclient
.
Config
,
namespace
,
podName
string
,
remote
int
)
*
Tunnel
{
func
NewTunnel
(
client
restclient
.
Interface
,
config
*
restclient
.
Config
,
namespace
,
podName
string
,
remote
int
)
*
Tunnel
{
return
&
Tunnel
{
config
:
config
,
client
:
client
,
...
...
pkg/storage/driver/cfgmaps.go
View file @
ea3be9e3
...
...
@@ -27,13 +27,12 @@ import (
"time"
"github.com/golang/protobuf/proto"
rspb
"k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/kubernetes/pkg/api"
kberrs
"k8s.io/kubernetes/pkg/api/errors"
client
"k8s.io/kubernetes/pkg/client/unversioned
"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion
"
kblabels
"k8s.io/kubernetes/pkg/labels"
rspb
"k8s.io/helm/pkg/proto/hapi/release"
)
var
_
Driver
=
(
*
ConfigMaps
)(
nil
)
...
...
@@ -48,12 +47,12 @@ var magicGzip = []byte{0x1f, 0x8b, 0x08}
// ConfigMaps is a wrapper around an implementation of a kubernetes
// ConfigMapsInterface.
type
ConfigMaps
struct
{
impl
client
.
ConfigMaps
Interface
impl
internalversion
.
ConfigMap
Interface
}
// NewConfigMaps initializes a new ConfigMaps wrapping an implmenetation of
// the kubernetes ConfigMapsInterface.
func
NewConfigMaps
(
impl
client
.
ConfigMaps
Interface
)
*
ConfigMaps
{
func
NewConfigMaps
(
impl
internalversion
.
ConfigMap
Interface
)
*
ConfigMaps
{
return
&
ConfigMaps
{
impl
:
impl
}
}
...
...
@@ -210,7 +209,7 @@ func (cfgmaps *ConfigMaps) Delete(key string) (rls *rspb.Release, err error) {
return
nil
,
err
}
// delete the release
if
err
=
cfgmaps
.
impl
.
Delete
(
key
);
err
!=
nil
{
if
err
=
cfgmaps
.
impl
.
Delete
(
key
,
&
api
.
DeleteOptions
{}
);
err
!=
nil
{
return
rls
,
err
}
return
rls
,
nil
...
...
pkg/storage/driver/mock_test.go
View file @
ea3be9e3
...
...
@@ -23,7 +23,7 @@ import (
rspb
"k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/kubernetes/pkg/api"
kberrs
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/client/
unversioned
"
"k8s.io/kubernetes/pkg/client/
clientset_generated/internalclientset/typed/core/internalversion
"
)
func
releaseStub
(
name
string
,
vers
int32
,
code
rspb
.
Status_Code
)
*
rspb
.
Release
{
...
...
@@ -73,7 +73,7 @@ func newTestFixtureCfgMaps(t *testing.T, releases ...*rspb.Release) *ConfigMaps
// MockConfigMapsInterface mocks a kubernetes ConfigMapsInterface
type
MockConfigMapsInterface
struct
{
unversioned
.
ConfigMaps
Interface
internalversion
.
ConfigMap
Interface
objects
map
[
string
]
*
api
.
ConfigMap
}
...
...
@@ -132,7 +132,7 @@ func (mock *MockConfigMapsInterface) Update(cfgmap *api.ConfigMap) (*api.ConfigM
}
// Delete deletes a ConfigMap by name.
func
(
mock
*
MockConfigMapsInterface
)
Delete
(
name
string
)
error
{
func
(
mock
*
MockConfigMapsInterface
)
Delete
(
name
string
,
opts
*
api
.
DeleteOptions
)
error
{
if
_
,
ok
:=
mock
.
objects
[
name
];
!
ok
{
return
kberrs
.
NewNotFound
(
api
.
Resource
(
"tests"
),
name
)
}
...
...
pkg/tiller/environment/environment.go
View file @
ea3be9e3
...
...
@@ -25,14 +25,14 @@ package environment
import
(
"io"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/engine"
"k8s.io/helm/pkg/kube"
"k8s.io/helm/pkg/proto/hapi/chart"
"k8s.io/helm/pkg/storage"
"k8s.io/helm/pkg/storage/driver"
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
)
// TillerNamespace is the namespace tiller is running in.
...
...
@@ -135,8 +135,8 @@ type KubeClient interface {
// by "\n---\n").
Update
(
namespace
string
,
originalReader
,
modifiedReader
io
.
Reader
)
error
//
API
Client gets a raw API client for Kubernetes.
APIClient
()
(
unversioned
.
Interface
,
error
)
// Client gets a raw API client for Kubernetes.
ClientSet
()
(
*
internalclientset
.
Clientset
,
error
)
}
// PrintingKubeClient implements KubeClient, but simply prints the reader to
...
...
@@ -145,12 +145,12 @@ type PrintingKubeClient struct {
Out
io
.
Writer
}
//
APIClien
t always returns an error.
//
ClientSe
t always returns an error.
//
// The printing client does not have access to a Kubernetes client at all. So it
// will always return an error if the client is accessed.
func
(
p
*
PrintingKubeClient
)
APIClient
()
(
unversioned
.
Interface
,
error
)
{
return
testclient
.
NewSimpleFake
(
),
nil
func
(
p
*
PrintingKubeClient
)
ClientSet
()
(
*
internalclientset
.
Clientset
,
error
)
{
return
new
(
internalclientset
.
Clientset
),
nil
}
// Create prints the values of what would be created with a real KubeClient.
...
...
pkg/tiller/environment/environment_test.go
View file @
ea3be9e3
...
...
@@ -23,8 +23,7 @@ import (
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/proto/hapi/chart"
unversionedclient
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
)
type
mockEngine
struct
{
...
...
@@ -35,11 +34,10 @@ func (e *mockEngine) Render(chrt *chart.Chart, v chartutil.Values) (map[string]s
return
e
.
out
,
nil
}
type
mockKubeClient
struct
{
}
type
mockKubeClient
struct
{}
func
(
k
*
mockKubeClient
)
APIClient
()
(
unversionedclient
.
Interface
,
error
)
{
return
testclient
.
NewSimpleFake
()
,
nil
func
(
k
*
mockKubeClient
)
ClientSet
()
(
*
internalclientset
.
Clientset
,
error
)
{
return
&
internalclientset
.
Clientset
{}
,
nil
}
func
(
k
*
mockKubeClient
)
Create
(
ns
string
,
r
io
.
Reader
)
error
{
...
...
pkg/tiller/release_server.go
View file @
ea3be9e3
...
...
@@ -695,13 +695,18 @@ func (s *ReleaseServer) prepareRelease(req *services.InstallReleaseRequest) (*re
func
(
s
*
ReleaseServer
)
getVersionSet
()
(
versionSet
,
error
)
{
defVersions
:=
newVersionSet
(
"v1"
)
cli
,
err
:=
s
.
env
.
KubeClient
.
APIClien
t
()
cli
,
err
:=
s
.
env
.
KubeClient
.
ClientSe
t
()
if
err
!=
nil
{
log
.
Printf
(
"
API C
lient for Kubernetes is missing: %s."
,
err
)
log
.
Printf
(
"
discovery c
lient for Kubernetes is missing: %s."
,
err
)
return
defVersions
,
err
}
groups
,
err
:=
cli
.
Discovery
()
.
ServerGroups
()
dc
:=
cli
.
Discovery
()
if
dc
.
RESTClient
()
==
nil
{
return
defVersions
,
nil
}
groups
,
err
:=
dc
.
ServerGroups
()
if
err
!=
nil
{
return
defVersions
,
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