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
de5a6a93
Unverified
Commit
de5a6a93
authored
Oct 11, 2018
by
Adam Reese
Committed by
GitHub
Oct 11, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4734 from adamreese/ref/kube-1.12
ref(*): kubernetes v1.12 support
parents
e7d93f23
dbf84cd2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
200 additions
and
213 deletions
+200
-213
helm.go
cmd/helm/helm.go
+1
-16
uninstall.go
cmd/helm/installer/uninstall.go
+6
-6
uninstall_test.go
cmd/helm/installer/uninstall_test.go
+8
-8
reset.go
cmd/helm/reset.go
+4
-3
reset_test.go
cmd/helm/reset_test.go
+3
-3
rudder.go
cmd/rudder/rudder.go
+4
-4
tiller.go
cmd/tiller/tiller.go
+4
-3
glide.lock
glide.lock
+0
-0
glide.yaml
glide.yaml
+35
-40
portforwarder_test.go
pkg/helm/portforwarder/portforwarder_test.go
+1
-1
client.go
pkg/kube/client.go
+32
-28
client_test.go
pkg/kube/client_test.go
+15
-15
namespace.go
pkg/kube/namespace.go
+8
-8
namespace_test.go
pkg/kube/namespace_test.go
+2
-2
result.go
pkg/kube/result.go
+1
-1
result_test.go
pkg/kube/result_test.go
+1
-1
environment.go
pkg/releasetesting/environment.go
+2
-2
test_suite.go
pkg/releasetesting/test_suite.go
+5
-5
test_suite_test.go
pkg/releasetesting/test_suite_test.go
+5
-5
cfgmaps.go
pkg/storage/driver/cfgmaps.go
+6
-6
cfgmaps_test.go
pkg/storage/driver/cfgmaps_test.go
+2
-2
mock_test.go
pkg/storage/driver/mock_test.go
+27
-26
secrets.go
pkg/storage/driver/secrets.go
+6
-6
secrets_test.go
pkg/storage/driver/secrets_test.go
+2
-2
environment.go
pkg/tiller/environment/environment.go
+5
-5
environment_test.go
pkg/tiller/environment/environment_test.go
+5
-5
release_modules.go
pkg/tiller/release_modules.go
+2
-2
release_server.go
pkg/tiller/release_server.go
+3
-3
release_server_test.go
pkg/tiller/release_server_test.go
+5
-5
No files found.
cmd/helm/helm.go
View file @
de5a6a93
...
...
@@ -28,10 +28,10 @@ import (
"google.golang.org/grpc/status"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
// Import to initialize client auth plugins.
_
"k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/helm/pkg/helm"
helm_env
"k8s.io/helm/pkg/helm/environment"
"k8s.io/helm/pkg/helm/portforwarder"
...
...
@@ -256,21 +256,6 @@ func getKubeClient(context string, kubeconfig string) (*rest.Config, kubernetes.
return
config
,
client
,
nil
}
// getInternalKubeClient creates a Kubernetes config and an "internal" client for a given kubeconfig context.
//
// Prefer the similar getKubeClient if you don't need to use such an internal client.
func
getInternalKubeClient
(
context
string
,
kubeconfig
string
)
(
internalclientset
.
Interface
,
error
)
{
config
,
err
:=
configForContext
(
context
,
kubeconfig
)
if
err
!=
nil
{
return
nil
,
err
}
client
,
err
:=
internalclientset
.
NewForConfig
(
config
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"could not get Kubernetes client: %s"
,
err
)
}
return
client
,
nil
}
// ensureHelmClient returns a new helm client impl. if h is not nil.
func
ensureHelmClient
(
h
helm
.
Interface
)
helm
.
Interface
{
if
h
!=
nil
{
...
...
cmd/helm/installer/uninstall.go
View file @
de5a6a93
...
...
@@ -19,8 +19,8 @@ package installer // import "k8s.io/helm/cmd/helm/installer"
import
(
apierrors
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/
kubernetes/pkg/client/clientset_generated/internalclientset
"
core
client
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion
"
"k8s.io/
client-go/kubernetes
"
core
v1
"k8s.io/client-go/kubernetes/typed/core/v1
"
)
const
(
...
...
@@ -30,7 +30,7 @@ const (
)
// Uninstall uses Kubernetes client to uninstall Tiller.
func
Uninstall
(
client
internalclientset
.
Interface
,
opts
*
Options
)
error
{
func
Uninstall
(
client
kubernetes
.
Interface
,
opts
*
Options
)
error
{
if
err
:=
deleteService
(
client
.
Core
(),
opts
.
Namespace
);
err
!=
nil
{
return
err
}
...
...
@@ -41,7 +41,7 @@ func Uninstall(client internalclientset.Interface, opts *Options) error {
}
// deleteService deletes the Tiller Service resource
func
deleteService
(
client
core
client
.
ServicesGetter
,
namespace
string
)
error
{
func
deleteService
(
client
core
v1
.
ServicesGetter
,
namespace
string
)
error
{
err
:=
client
.
Services
(
namespace
)
.
Delete
(
serviceName
,
&
metav1
.
DeleteOptions
{})
return
ingoreNotFound
(
err
)
}
...
...
@@ -49,13 +49,13 @@ func deleteService(client coreclient.ServicesGetter, namespace string) error {
// deleteDeployment deletes the Tiller Deployment resource
// We need to use the reaper instead of the kube API because GC for deployment dependents
// is not yet supported at the k8s server level (<= 1.5)
func
deleteDeployment
(
client
internalclientset
.
Interface
,
namespace
string
)
error
{
func
deleteDeployment
(
client
kubernetes
.
Interface
,
namespace
string
)
error
{
err
:=
client
.
Extensions
()
.
Deployments
(
namespace
)
.
Delete
(
deploymentName
,
&
metav1
.
DeleteOptions
{})
return
ingoreNotFound
(
err
)
}
// deleteSecret deletes the Tiller Secret resource
func
deleteSecret
(
client
core
client
.
SecretsGetter
,
namespace
string
)
error
{
func
deleteSecret
(
client
core
v1
.
SecretsGetter
,
namespace
string
)
error
{
err
:=
client
.
Secrets
(
namespace
)
.
Delete
(
secretName
,
&
metav1
.
DeleteOptions
{})
return
ingoreNotFound
(
err
)
}
...
...
cmd/helm/installer/uninstall_test.go
View file @
de5a6a93
...
...
@@ -19,17 +19,17 @@ package installer // import "k8s.io/helm/cmd/helm/installer"
import
(
"testing"
"k8s.io/api/core/v1"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/kubernetes/fake"
testcore
"k8s.io/client-go/testing"
"k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake"
)
func
TestUninstall
(
t
*
testing
.
T
)
{
fc
:=
&
fake
.
Clientset
{}
opts
:=
&
Options
{
Namespace
:
core
.
NamespaceDefault
}
opts
:=
&
Options
{
Namespace
:
v1
.
NamespaceDefault
}
if
err
:=
Uninstall
(
fc
,
opts
);
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %#+v"
,
err
)
}
...
...
@@ -45,7 +45,7 @@ func TestUninstall_serviceNotFound(t *testing.T) {
return
true
,
nil
,
apierrors
.
NewNotFound
(
schema
.
GroupResource
{
Resource
:
"services"
},
"1"
)
})
opts
:=
&
Options
{
Namespace
:
core
.
NamespaceDefault
}
opts
:=
&
Options
{
Namespace
:
v1
.
NamespaceDefault
}
if
err
:=
Uninstall
(
fc
,
opts
);
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %#+v"
,
err
)
}
...
...
@@ -58,10 +58,10 @@ func TestUninstall_serviceNotFound(t *testing.T) {
func
TestUninstall_deploymentNotFound
(
t
*
testing
.
T
)
{
fc
:=
&
fake
.
Clientset
{}
fc
.
AddReactor
(
"delete"
,
"deployments"
,
func
(
action
testcore
.
Action
)
(
bool
,
runtime
.
Object
,
error
)
{
return
true
,
nil
,
apierrors
.
NewNotFound
(
core
.
Resource
(
"deployments"
)
,
"1"
)
return
true
,
nil
,
apierrors
.
NewNotFound
(
schema
.
GroupResource
{
Resource
:
"deployments"
}
,
"1"
)
})
opts
:=
&
Options
{
Namespace
:
core
.
NamespaceDefault
}
opts
:=
&
Options
{
Namespace
:
v1
.
NamespaceDefault
}
if
err
:=
Uninstall
(
fc
,
opts
);
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %#+v"
,
err
)
}
...
...
@@ -74,10 +74,10 @@ func TestUninstall_deploymentNotFound(t *testing.T) {
func
TestUninstall_secretNotFound
(
t
*
testing
.
T
)
{
fc
:=
&
fake
.
Clientset
{}
fc
.
AddReactor
(
"delete"
,
"secrets"
,
func
(
action
testcore
.
Action
)
(
bool
,
runtime
.
Object
,
error
)
{
return
true
,
nil
,
apierrors
.
NewNotFound
(
core
.
Resource
(
"secrets"
)
,
"1"
)
return
true
,
nil
,
apierrors
.
NewNotFound
(
schema
.
GroupResource
{
Resource
:
"secrets"
}
,
"1"
)
})
opts
:=
&
Options
{
Namespace
:
core
.
NamespaceDefault
}
opts
:=
&
Options
{
Namespace
:
v1
.
NamespaceDefault
}
if
err
:=
Uninstall
(
fc
,
opts
);
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %#+v"
,
err
)
}
...
...
cmd/helm/reset.go
View file @
de5a6a93
...
...
@@ -23,7 +23,8 @@ import (
"os"
"github.com/spf13/cobra"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/client-go/kubernetes"
"k8s.io/helm/cmd/helm/installer"
"k8s.io/helm/pkg/helm"
...
...
@@ -44,7 +45,7 @@ type resetCmd struct {
out
io
.
Writer
home
helmpath
.
Home
client
helm
.
Interface
kubeClient
internalclientset
.
Interface
kubeClient
kubernetes
.
Interface
}
func
newResetCmd
(
client
helm
.
Interface
,
out
io
.
Writer
)
*
cobra
.
Command
{
...
...
@@ -90,7 +91,7 @@ func newResetCmd(client helm.Interface, out io.Writer) *cobra.Command {
// runReset uninstalls tiller from Kubernetes Cluster and deletes local config
func
(
d
*
resetCmd
)
run
()
error
{
if
d
.
kubeClient
==
nil
{
c
,
err
:=
getInternal
KubeClient
(
settings
.
KubeContext
,
settings
.
KubeConfig
)
_
,
c
,
err
:=
get
KubeClient
(
settings
.
KubeContext
,
settings
.
KubeConfig
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"could not get kubernetes client: %s"
,
err
)
}
...
...
cmd/helm/reset_test.go
View file @
de5a6a93
...
...
@@ -23,8 +23,8 @@ import (
"strings"
"testing"
"k8s.io/
kubernetes/pkg/apis/core
"
"k8s.io/
kubernetes/pkg/client/clientset_generated/internalclientset
/fake"
"k8s.io/
api/core/v1
"
"k8s.io/
client-go/kubernetes
/fake"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/helm/helmpath"
...
...
@@ -101,7 +101,7 @@ func verifyResetCmd(t *testing.T, tc resetCase) {
home
:
helmpath
.
Home
(
home
),
client
:
c
,
kubeClient
:
fc
,
namespace
:
core
.
NamespaceDefault
,
namespace
:
v1
.
NamespaceDefault
,
}
err
=
cmd
.
run
()
...
...
cmd/rudder/rudder.go
View file @
de5a6a93
...
...
@@ -21,12 +21,12 @@ import (
"fmt"
"net"
"github.com/spf13/pflag"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/grpclog"
"k8s.io/
kubernetes/pkg/client/clientset_generated/internalclientset
"
"k8s.io/
client-go/kubernetes
"
"github.com/spf13/pflag"
"k8s.io/helm/pkg/kube"
rudderAPI
"k8s.io/helm/pkg/proto/hapi/rudder"
"k8s.io/helm/pkg/tiller"
...
...
@@ -34,7 +34,7 @@ import (
)
var
kubeClient
*
kube
.
Client
var
clientset
internalclientset
.
Interface
var
clientset
kubernetes
.
Interface
type
options
struct
{
listen
string
...
...
@@ -59,7 +59,7 @@ func main() {
opts
.
regAndParseFlags
()
var
err
error
kubeClient
=
kube
.
New
(
nil
)
clientset
,
err
=
kubeClient
.
ClientSet
()
clientset
,
err
=
kubeClient
.
Kubernetes
ClientSet
()
if
err
!=
nil
{
grpclog
.
Fatalf
(
"Cannot initialize Kubernetes connection: %s"
,
err
)
}
...
...
cmd/tiller/tiller.go
View file @
de5a6a93
...
...
@@ -39,6 +39,7 @@ import (
// Import to initialize client auth plugins.
_
"k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/helm/pkg/kube"
"k8s.io/helm/pkg/proto/hapi/services"
"k8s.io/helm/pkg/storage"
...
...
@@ -120,7 +121,7 @@ func start() {
healthSrv
:=
health
.
NewServer
()
healthSrv
.
SetServingStatus
(
"Tiller"
,
healthpb
.
HealthCheckResponse_NOT_SERVING
)
clientset
,
err
:=
kube
.
New
(
nil
)
.
ClientSet
()
clientset
,
err
:=
kube
.
New
(
nil
)
.
Kubernetes
ClientSet
()
if
err
!=
nil
{
logger
.
Fatalf
(
"Cannot initialize Kubernetes connection: %s"
,
err
)
}
...
...
@@ -129,13 +130,13 @@ func start() {
case
storageMemory
:
env
.
Releases
=
storage
.
Init
(
driver
.
NewMemory
())
case
storageConfigMap
:
cfgmaps
:=
driver
.
NewConfigMaps
(
clientset
.
Core
()
.
ConfigMaps
(
namespace
()))
cfgmaps
:=
driver
.
NewConfigMaps
(
clientset
.
Core
V1
()
.
ConfigMaps
(
namespace
()))
cfgmaps
.
Log
=
newLogger
(
"storage/driver"
)
.
Printf
env
.
Releases
=
storage
.
Init
(
cfgmaps
)
env
.
Releases
.
Log
=
newLogger
(
"storage"
)
.
Printf
case
storageSecret
:
secrets
:=
driver
.
NewSecrets
(
clientset
.
Core
()
.
Secrets
(
namespace
()))
secrets
:=
driver
.
NewSecrets
(
clientset
.
Core
V1
()
.
Secrets
(
namespace
()))
secrets
.
Log
=
newLogger
(
"storage/driver"
)
.
Printf
env
.
Releases
=
storage
.
Init
(
secrets
)
...
...
glide.lock
View file @
de5a6a93
This diff is collapsed.
Click to expand it.
glide.yaml
View file @
de5a6a93
package
:
k8s.io/helm
import
:
-
package
:
golang.org/x/net
-
package
:
golang.org/x/net
subpackages
:
-
context
-
package
:
github.com/spf13/cobra
-
package
:
github.com/spf13/cobra
version
:
c439c4fa093711d42e1b01acb1235b52004753c1
-
package
:
github.com/spf13/pflag
version
:
583c0c0531f06d5278b7d917446061adc344b5cd
-
package
:
github.com/Masterminds/vcs
version
:
~1.11.0
-
package
:
github.com/spf13/pflag
version
:
~1.0.1
-
package
:
github.com/Masterminds/vcs
# Pin version of mergo that is compatible with both sprig and Kubernetes
-
package
:
github.com/imdario/mergo
version
:
6633656539c1639d9d78127b7d47c622b5d7b6dc
-
package
:
github.com/Masterminds/sprig
-
package
:
github.com/imdario/mergo
version
:
v0.3.5
-
package
:
github.com/Masterminds/sprig
version
:
^2.16.0
-
package
:
github.com/ghodss/yaml
-
package
:
github.com/Masterminds/semver
-
package
:
github.com/ghodss/yaml
-
package
:
github.com/Masterminds/semver
version
:
~1.3.1
-
package
:
github.com/technosophos/moniker
-
package
:
github.com/technosophos/moniker
version
:
~0.2
-
package
:
github.com/golang/protobuf
-
package
:
github.com/golang/protobuf
version
:
1643683e1b54a9e88ad26d98f81400c8c9d9f4f9
subpackages
:
-
proto
-
ptypes/any
-
ptypes/timestamp
-
package
:
google.golang.org/grpc
-
package
:
google.golang.org/grpc
version
:
1.7.2
-
package
:
github.com/gosuri/uitable
-
package
:
github.com/asaskevich/govalidator
-
package
:
github.com/gosuri/uitable
-
package
:
github.com/asaskevich/govalidator
version
:
^4.0.0
-
package
:
golang.org/x/crypto
-
package
:
golang.org/x/crypto
subpackages
:
-
openpgp
-
ssh/terminal
# pin version of golang.org/x/sys that is compatible with golang.org/x/crypto
-
package
:
golang.org/x/sys
version
:
43eea11
subpackages
:
-
unix
-
windows
-
package
:
github.com/gobwas/glob
-
package
:
github.com/gobwas/glob
version
:
^0.2.1
-
package
:
github.com/evanphx/json-patch
-
package
:
github.com/BurntSushi/toml
-
package
:
github.com/evanphx/json-patch
-
package
:
github.com/BurntSushi/toml
version
:
~0.3.0
-
package
:
github.com/prometheus/client_golang
-
package
:
github.com/prometheus/client_golang
version
:
0.8.0
-
package
:
github.com/grpc-ecosystem/go-grpc-prometheus
-
package
:
github.com/grpc-ecosystem/go-grpc-prometheus
-
package
:
k8s.io/kubernetes
version
:
release-1.11
-
package
:
k8s.io/client-go
version
:
kubernetes-1.11.1
-
package
:
k8s.io/api
version
:
kubernetes-1.11.1
-
package
:
k8s.io/apimachinery
version
:
kubernetes-1.11.1
-
package
:
k8s.io/apiserver
version
:
kubernetes-1.11.1
-
package
:
github.com/cyphar/filepath-securejoin
-
package
:
k8s.io/kubernetes
version
:
release-1.12
-
package
:
k8s.io/client-go
version
:
kubernetes-1.12.0
-
package
:
k8s.io/api
version
:
kubernetes-1.12.0
-
package
:
k8s.io/apimachinery
version
:
kubernetes-1.12.0
-
package
:
k8s.io/apiserver
version
:
kubernetes-1.12.0
-
package
:
k8s.io/cli-runtime
version
:
kubernetes-1.12.0
-
package
:
github.com/cyphar/filepath-securejoin
version
:
^0.2.1
testImports
:
-
package
:
github.com/stretchr/testify
-
package
:
github.com/stretchr/testify
version
:
^1.1.4
subpackages
:
-
assert
pkg/helm/portforwarder/portforwarder_test.go
View file @
de5a6a93
...
...
@@ -76,7 +76,7 @@ func TestGetFirstPod(t *testing.T) {
for
_
,
tt
:=
range
tests
{
client
:=
fake
.
NewSimpleClientset
(
&
v1
.
PodList
{
Items
:
tt
.
pods
})
name
,
err
:=
GetTillerPodName
(
client
.
Core
(),
v1
.
NamespaceDefault
)
name
,
err
:=
GetTillerPodName
(
client
.
Core
V1
(),
v1
.
NamespaceDefault
)
if
(
err
!=
nil
)
!=
tt
.
err
{
t
.
Errorf
(
"%q. expected error: %v, got %v"
,
tt
.
name
,
tt
.
err
,
err
)
}
...
...
pkg/kube/client.go
View file @
de5a6a93
...
...
@@ -18,6 +18,7 @@ package kube // import "k8s.io/helm/pkg/kube"
import
(
"bytes"
"context"
"encoding/json"
goerrors
"errors"
"fmt"
...
...
@@ -42,20 +43,19 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/strategicpatch"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericclioptions/resource"
watchtools
"k8s.io/client-go/tools/watch"
"k8s.io/kubernetes/pkg/api/legacyscheme"
batchinternal
"k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/kubectl/cmd/get"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/resource"
"k8s.io/kubernetes/pkg/kubectl/validation"
)
const
(
// MissingGetHeader is added to Get's output when a resource is not found.
MissingGetHeader
=
"==> MISSING
\n
KIND
\t\t
NAME
\n
"
)
// MissingGetHeader is added to Get's output when a resource is not found.
const
MissingGetHeader
=
"==> MISSING
\n
KIND
\t\t
NAME
\n
"
// ErrNoObjectsVisited indicates that during a visit operation, no matching objects were found.
var
ErrNoObjectsVisited
=
goerrors
.
New
(
"no objects visited"
)
...
...
@@ -86,7 +86,7 @@ type ResourceActorFunc func(*resource.Info) error
//
// Namespace will set the namespace.
func
(
c
*
Client
)
Create
(
namespace
string
,
reader
io
.
Reader
,
timeout
int64
,
shouldWait
bool
)
error
{
client
,
err
:=
c
.
ClientSet
()
client
,
err
:=
c
.
Kubernetes
ClientSet
()
if
err
!=
nil
{
return
err
}
...
...
@@ -163,7 +163,7 @@ func (c *Client) Get(namespace string, reader io.Reader) (string, error) {
return
""
,
err
}
var
objPods
=
make
(
map
[
string
][]
core
.
Pod
)
var
objPods
=
make
(
map
[
string
][]
v1
.
Pod
)
missing
:=
[]
string
{}
err
=
perform
(
infos
,
func
(
info
*
resource
.
Info
)
error
{
...
...
@@ -368,7 +368,7 @@ func perform(infos Result, fn ResourceActorFunc) error {
}
func
createResource
(
info
*
resource
.
Info
)
error
{
obj
,
err
:=
resource
.
NewHelper
(
info
.
Client
,
info
.
Mapping
)
.
Create
(
info
.
Namespace
,
true
,
info
.
Object
)
obj
,
err
:=
resource
.
NewHelper
(
info
.
Client
,
info
.
Mapping
)
.
Create
(
info
.
Namespace
,
true
,
info
.
Object
,
nil
)
if
err
!=
nil
{
return
err
}
...
...
@@ -438,7 +438,7 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object,
// send patch to server
helper
:=
resource
.
NewHelper
(
target
.
Client
,
target
.
Mapping
)
obj
,
err
:=
helper
.
Patch
(
target
.
Namespace
,
target
.
Name
,
patchType
,
patch
)
obj
,
err
:=
helper
.
Patch
(
target
.
Namespace
,
target
.
Name
,
patchType
,
patch
,
nil
)
if
err
!=
nil
{
kind
:=
target
.
Mapping
.
GroupVersionKind
.
Kind
log
.
Printf
(
"Cannot patch %s: %q (%v)"
,
kind
,
target
.
Name
,
err
)
...
...
@@ -479,12 +479,12 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object,
return
nil
}
client
,
err
:=
c
.
ClientSet
()
client
,
err
:=
c
.
Kubernetes
ClientSet
()
if
err
!=
nil
{
return
err
}
pods
,
err
:=
client
.
Core
()
.
Pods
(
target
.
Namespace
)
.
List
(
metav1
.
ListOptions
{
pods
,
err
:=
client
.
Core
V1
()
.
Pods
(
target
.
Namespace
)
.
List
(
metav1
.
ListOptions
{
FieldSelector
:
fields
.
Everything
()
.
String
(),
LabelSelector
:
labels
.
Set
(
selector
)
.
AsSelector
()
.
String
(),
})
...
...
@@ -497,7 +497,7 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object,
c
.
Log
(
"Restarting pod: %v/%v"
,
pod
.
Namespace
,
pod
.
Name
)
// Delete each pod for get them restarted with changed spec.
if
err
:=
client
.
Core
()
.
Pods
(
pod
.
Namespace
)
.
Delete
(
pod
.
Name
,
metav1
.
NewPreconditionDeleteOptions
(
string
(
pod
.
UID
)));
err
!=
nil
{
if
err
:=
client
.
Core
V1
()
.
Pods
(
pod
.
Namespace
)
.
Delete
(
pod
.
Name
,
metav1
.
NewPreconditionDeleteOptions
(
string
(
pod
.
UID
)));
err
!=
nil
{
return
err
}
}
...
...
@@ -561,7 +561,9 @@ func (c *Client) watchUntilReady(timeout time.Duration, info *resource.Info) err
// In the future, we might want to add some special logic for types
// like Ingress, Volume, etc.
_
,
err
=
watch
.
Until
(
timeout
,
w
,
func
(
e
watch
.
Event
)
(
bool
,
error
)
{
ctx
,
cancel
:=
watchtools
.
ContextWithOptionalTimeout
(
context
.
Background
(),
timeout
)
defer
cancel
()
_
,
err
=
watchtools
.
UntilWithoutRetry
(
ctx
,
w
,
func
(
e
watch
.
Event
)
(
bool
,
error
)
{
switch
e
.
Type
{
case
watch
.
Added
,
watch
.
Modified
:
// For things like a secret or a config map, this is the best indicator
...
...
@@ -623,26 +625,26 @@ func scrubValidationError(err error) error {
// WaitAndGetCompletedPodPhase waits up to a timeout until a pod enters a completed phase
// and returns said phase (PodSucceeded or PodFailed qualify).
func
(
c
*
Client
)
WaitAndGetCompletedPodPhase
(
namespace
string
,
reader
io
.
Reader
,
timeout
time
.
Duration
)
(
core
.
PodPhase
,
error
)
{
func
(
c
*
Client
)
WaitAndGetCompletedPodPhase
(
namespace
string
,
reader
io
.
Reader
,
timeout
time
.
Duration
)
(
v1
.
PodPhase
,
error
)
{
infos
,
err
:=
c
.
Build
(
namespace
,
reader
)
if
err
!=
nil
{
return
core
.
PodUnknown
,
err
return
v1
.
PodUnknown
,
err
}
info
:=
infos
[
0
]
kind
:=
info
.
Mapping
.
GroupVersionKind
.
Kind
if
kind
!=
"Pod"
{
return
core
.
PodUnknown
,
fmt
.
Errorf
(
"%s is not a Pod"
,
info
.
Name
)
return
v1
.
PodUnknown
,
fmt
.
Errorf
(
"%s is not a Pod"
,
info
.
Name
)
}
if
err
:=
c
.
watchPodUntilComplete
(
timeout
,
info
);
err
!=
nil
{
return
core
.
PodUnknown
,
err
return
v1
.
PodUnknown
,
err
}
if
err
:=
info
.
Get
();
err
!=
nil
{
return
core
.
PodUnknown
,
err
return
v1
.
PodUnknown
,
err
}
status
:=
info
.
Object
.
(
*
core
.
Pod
)
.
Status
.
Phase
status
:=
info
.
Object
.
(
*
v1
.
Pod
)
.
Status
.
Phase
return
status
,
nil
}
...
...
@@ -654,7 +656,9 @@ func (c *Client) watchPodUntilComplete(timeout time.Duration, info *resource.Inf
}
c
.
Log
(
"Watching pod %s for completion with timeout of %v"
,
info
.
Name
,
timeout
)
_
,
err
=
watch
.
Until
(
timeout
,
w
,
func
(
e
watch
.
Event
)
(
bool
,
error
)
{
ctx
,
cancel
:=
watchtools
.
ContextWithOptionalTimeout
(
context
.
Background
(),
timeout
)
defer
cancel
()
_
,
err
=
watchtools
.
UntilWithoutRetry
(
ctx
,
w
,
func
(
e
watch
.
Event
)
(
bool
,
error
)
{
return
isPodComplete
(
e
)
})
...
...
@@ -662,15 +666,15 @@ func (c *Client) watchPodUntilComplete(timeout time.Duration, info *resource.Inf
}
func
isPodComplete
(
event
watch
.
Event
)
(
bool
,
error
)
{
o
,
ok
:=
event
.
Object
.
(
*
core
.
Pod
)
o
,
ok
:=
event
.
Object
.
(
*
v1
.
Pod
)
if
!
ok
{
return
true
,
fmt
.
Errorf
(
"expected a *
core
.Pod, got %T"
,
event
.
Object
)
return
true
,
fmt
.
Errorf
(
"expected a *
v1
.Pod, got %T"
,
event
.
Object
)
}
if
event
.
Type
==
watch
.
Deleted
{
return
false
,
fmt
.
Errorf
(
"pod not found"
)
}
switch
o
.
Status
.
Phase
{
case
core
.
PodFailed
,
core
.
PodSucceeded
:
case
v1
.
PodFailed
,
v1
.
PodSucceeded
:
return
true
,
nil
}
return
false
,
nil
...
...
@@ -678,7 +682,7 @@ func isPodComplete(event watch.Event) (bool, error) {
//get a kubernetes resources' relation pods
// kubernetes resource used select labels to relate pods
func
(
c
*
Client
)
getSelectRelationPod
(
info
*
resource
.
Info
,
objPods
map
[
string
][]
core
.
Pod
)
(
map
[
string
][]
core
.
Pod
,
error
)
{
func
(
c
*
Client
)
getSelectRelationPod
(
info
*
resource
.
Info
,
objPods
map
[
string
][]
v1
.
Pod
)
(
map
[
string
][]
v1
.
Pod
,
error
)
{
if
info
==
nil
{
return
objPods
,
nil
}
...
...
@@ -691,9 +695,9 @@ func (c *Client) getSelectRelationPod(info *resource.Info, objPods map[string][]
return
objPods
,
nil
}
client
,
_
:=
c
.
ClientSet
()
client
,
_
:=
c
.
Kubernetes
ClientSet
()
pods
,
err
:=
client
.
Core
()
.
Pods
(
info
.
Namespace
)
.
List
(
metav1
.
ListOptions
{
pods
,
err
:=
client
.
Core
V1
()
.
Pods
(
info
.
Namespace
)
.
List
(
metav1
.
ListOptions
{
FieldSelector
:
fields
.
Everything
()
.
String
(),
LabelSelector
:
labels
.
Set
(
selector
)
.
AsSelector
()
.
String
(),
})
...
...
@@ -718,7 +722,7 @@ func (c *Client) getSelectRelationPod(info *resource.Info, objPods map[string][]
return
objPods
,
nil
}
func
isFoundPod
(
podItem
[]
core
.
Pod
,
pod
core
.
Pod
)
bool
{
func
isFoundPod
(
podItem
[]
v1
.
Pod
,
pod
v1
.
Pod
)
bool
{
for
_
,
value
:=
range
podItem
{
if
(
value
.
Namespace
==
pod
.
Namespace
)
&&
(
value
.
Name
==
pod
.
Name
)
{
return
true
...
...
pkg/kube/client_test.go
View file @
de5a6a93
...
...
@@ -24,15 +24,15 @@ import (
"strings"
"testing"
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/cli-runtime/pkg/genericclioptions/resource"
"k8s.io/client-go/rest/fake"
"k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/apis/core"
cmdtesting
"k8s.io/kubernetes/pkg/kubectl/cmd/testing"
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/resource"
"k8s.io/kubernetes/pkg/kubectl/scheme"
)
...
...
@@ -42,34 +42,34 @@ func objBody(codec runtime.Codec, obj runtime.Object) io.ReadCloser {
return
ioutil
.
NopCloser
(
bytes
.
NewReader
([]
byte
(
runtime
.
EncodeOrDie
(
codec
,
obj
))))
}
func
newPod
(
name
string
)
core
.
Pod
{
return
newPodWithStatus
(
name
,
core
.
PodStatus
{},
""
)
func
newPod
(
name
string
)
v1
.
Pod
{
return
newPodWithStatus
(
name
,
v1
.
PodStatus
{},
""
)
}
func
newPodWithStatus
(
name
string
,
status
core
.
PodStatus
,
namespace
string
)
core
.
Pod
{
ns
:=
core
.
NamespaceDefault
func
newPodWithStatus
(
name
string
,
status
v1
.
PodStatus
,
namespace
string
)
v1
.
Pod
{
ns
:=
v1
.
NamespaceDefault
if
namespace
!=
""
{
ns
=
namespace
}
return
core
.
Pod
{
return
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
name
,
Namespace
:
ns
,
SelfLink
:
"/api/v1/namespaces/default/pods/"
+
name
,
},
Spec
:
core
.
PodSpec
{
Containers
:
[]
core
.
Container
{{
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{{
Name
:
"app:v4"
,
Image
:
"abc/app:v4"
,
Ports
:
[]
core
.
ContainerPort
{{
Name
:
"http"
,
ContainerPort
:
80
}},
Ports
:
[]
v1
.
ContainerPort
{{
Name
:
"http"
,
ContainerPort
:
80
}},
}},
},
Status
:
status
,
}
}
func
newPodList
(
names
...
string
)
core
.
PodList
{
var
list
core
.
PodList
func
newPodList
(
names
...
string
)
v1
.
PodList
{
var
list
v1
.
PodList
for
_
,
name
:=
range
names
{
list
.
Items
=
append
(
list
.
Items
,
newPod
(
name
))
}
...
...
@@ -114,8 +114,8 @@ func TestUpdate(t *testing.T) {
listA
:=
newPodList
(
"starfish"
,
"otter"
,
"squid"
)
listB
:=
newPodList
(
"starfish"
,
"otter"
,
"dolphin"
)
listC
:=
newPodList
(
"starfish"
,
"otter"
,
"dolphin"
)
listB
.
Items
[
0
]
.
Spec
.
Containers
[
0
]
.
Ports
=
[]
core
.
ContainerPort
{{
Name
:
"https"
,
ContainerPort
:
443
}}
listC
.
Items
[
0
]
.
Spec
.
Containers
[
0
]
.
Ports
=
[]
core
.
ContainerPort
{{
Name
:
"https"
,
ContainerPort
:
443
}}
listB
.
Items
[
0
]
.
Spec
.
Containers
[
0
]
.
Ports
=
[]
v1
.
ContainerPort
{{
Name
:
"https"
,
ContainerPort
:
443
}}
listC
.
Items
[
0
]
.
Spec
.
Containers
[
0
]
.
Ports
=
[]
v1
.
ContainerPort
{{
Name
:
"https"
,
ContainerPort
:
443
}}
var
actions
[]
string
...
...
@@ -163,7 +163,7 @@ func TestUpdate(t *testing.T) {
}
codec
:=
legacyscheme
.
Codecs
.
LegacyCodec
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
if
err
:=
c
.
Update
(
core
.
NamespaceDefault
,
objBody
(
codec
,
&
listA
),
objBody
(
codec
,
&
listB
),
false
,
false
,
0
,
false
);
err
!=
nil
{
if
err
:=
c
.
Update
(
v1
.
NamespaceDefault
,
objBody
(
codec
,
&
listA
),
objBody
(
codec
,
&
listB
),
false
,
false
,
0
,
false
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
// TODO: Find a way to test methods that use Client Set
...
...
pkg/kube/namespace.go
View file @
de5a6a93
...
...
@@ -17,14 +17,14 @@ limitations under the License.
package
kube
// import "k8s.io/helm/pkg/kube"
import
(
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/client-go/kubernetes"
)
func
createNamespace
(
client
internalclientset
.
Interface
,
namespace
string
)
error
{
ns
:=
&
core
.
Namespace
{
func
createNamespace
(
client
kubernetes
.
Interface
,
namespace
string
)
error
{
ns
:=
&
v1
.
Namespace
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
namespace
,
Labels
:
map
[
string
]
string
{
...
...
@@ -32,15 +32,15 @@ func createNamespace(client internalclientset.Interface, namespace string) error
},
},
}
_
,
err
:=
client
.
Core
()
.
Namespaces
()
.
Create
(
ns
)
_
,
err
:=
client
.
Core
V1
()
.
Namespaces
()
.
Create
(
ns
)
return
err
}
func
getNamespace
(
client
internalclientset
.
Interface
,
namespace
string
)
(
*
core
.
Namespace
,
error
)
{
return
client
.
Core
()
.
Namespaces
()
.
Get
(
namespace
,
metav1
.
GetOptions
{})
func
getNamespace
(
client
kubernetes
.
Interface
,
namespace
string
)
(
*
v1
.
Namespace
,
error
)
{
return
client
.
Core
V1
()
.
Namespaces
()
.
Get
(
namespace
,
metav1
.
GetOptions
{})
}
func
ensureNamespace
(
client
internalclientset
.
Interface
,
namespace
string
)
error
{
func
ensureNamespace
(
client
kubernetes
.
Interface
,
namespace
string
)
error
{
_
,
err
:=
getNamespace
(
client
,
namespace
)
if
err
!=
nil
&&
errors
.
IsNotFound
(
err
)
{
err
=
createNamespace
(
client
,
namespace
)
...
...
pkg/kube/namespace_test.go
View file @
de5a6a93
...
...
@@ -20,7 +20,7 @@ import (
"testing"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/
kubernetes/pkg/client/clientset_generated/internalclientset
/fake"
"k8s.io/
client-go/kubernetes
/fake"
)
func
TestEnsureNamespace
(
t
*
testing
.
T
)
{
...
...
@@ -31,7 +31,7 @@ func TestEnsureNamespace(t *testing.T) {
if
err
:=
ensureNamespace
(
client
,
"foo"
);
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %s"
,
err
)
}
if
_
,
err
:=
client
.
Core
()
.
Namespaces
()
.
Get
(
"foo"
,
metav1
.
GetOptions
{});
err
!=
nil
{
if
_
,
err
:=
client
.
Core
V1
()
.
Namespaces
()
.
Get
(
"foo"
,
metav1
.
GetOptions
{});
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %s"
,
err
)
}
}
pkg/kube/result.go
View file @
de5a6a93
...
...
@@ -16,7 +16,7 @@ limitations under the License.
package
kube
// import "k8s.io/helm/pkg/kube"
import
"k8s.io/
kubernetes/pkg/kubectl
/genericclioptions/resource"
import
"k8s.io/
cli-runtime/pkg
/genericclioptions/resource"
// Result provides convenience methods for comparing collections of Infos.
type
Result
[]
*
resource
.
Info
...
...
pkg/kube/result_test.go
View file @
de5a6a93
...
...
@@ -21,7 +21,7 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/
kubernetes/pkg/kubectl
/genericclioptions/resource"
"k8s.io/
cli-runtime/pkg
/genericclioptions/resource"
)
func
TestResult
(
t
*
testing
.
T
)
{
...
...
pkg/releasetesting/environment.go
View file @
de5a6a93
...
...
@@ -22,7 +22,7 @@ import (
"log"
"time"
"k8s.io/
kubernetes/pkg/apis/core
"
"k8s.io/
api/core/v1
"
"k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/helm/pkg/proto/hapi/services"
...
...
@@ -49,7 +49,7 @@ func (env *Environment) createTestPod(test *test) error {
return
nil
}
func
(
env
*
Environment
)
getTestPodStatus
(
test
*
test
)
(
core
.
PodPhase
,
error
)
{
func
(
env
*
Environment
)
getTestPodStatus
(
test
*
test
)
(
v1
.
PodPhase
,
error
)
{
b
:=
bytes
.
NewBufferString
(
test
.
manifest
)
status
,
err
:=
env
.
KubeClient
.
WaitAndGetCompletedPodPhase
(
env
.
Namespace
,
b
,
time
.
Duration
(
env
.
Timeout
)
*
time
.
Second
)
if
err
!=
nil
{
...
...
pkg/releasetesting/test_suite.go
View file @
de5a6a93
...
...
@@ -22,7 +22,7 @@ import (
"github.com/ghodss/yaml"
"github.com/golang/protobuf/ptypes/timestamp"
"k8s.io/
kubernetes/pkg/apis/core
"
"k8s.io/
api/core/v1
"
"k8s.io/helm/pkg/hooks"
"k8s.io/helm/pkg/proto/hapi/release"
...
...
@@ -90,7 +90,7 @@ func (ts *TestSuite) Run(env *Environment) error {
}
resourceCleanExit
:=
true
status
:=
core
.
PodUnknown
status
:=
v1
.
PodUnknown
if
resourceCreated
{
status
,
err
=
env
.
getTestPodStatus
(
test
)
if
err
!=
nil
{
...
...
@@ -119,15 +119,15 @@ func (ts *TestSuite) Run(env *Environment) error {
return
nil
}
func
(
t
*
test
)
assignTestResult
(
podStatus
core
.
PodPhase
)
error
{
func
(
t
*
test
)
assignTestResult
(
podStatus
v1
.
PodPhase
)
error
{
switch
podStatus
{
case
core
.
PodSucceeded
:
case
v1
.
PodSucceeded
:
if
t
.
expectedSuccess
{
t
.
result
.
Status
=
release
.
TestRun_SUCCESS
}
else
{
t
.
result
.
Status
=
release
.
TestRun_FAILURE
}
case
core
.
PodFailed
:
case
v1
.
PodFailed
:
if
!
t
.
expectedSuccess
{
t
.
result
.
Status
=
release
.
TestRun_SUCCESS
}
else
{
...
...
pkg/releasetesting/test_suite_test.go
View file @
de5a6a93
...
...
@@ -26,7 +26,7 @@ import (
"golang.org/x/net/context"
grpc
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
"k8s.io/
kubernetes/pkg/apis/core
"
"k8s.io/
api/core/v1
"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/proto/hapi/chart"
...
...
@@ -324,8 +324,8 @@ func newPodSucceededKubeClient() *podSucceededKubeClient {
}
}
func
(
p
*
podSucceededKubeClient
)
WaitAndGetCompletedPodPhase
(
ns
string
,
r
io
.
Reader
,
timeout
time
.
Duration
)
(
core
.
PodPhase
,
error
)
{
return
core
.
PodSucceeded
,
nil
func
(
p
*
podSucceededKubeClient
)
WaitAndGetCompletedPodPhase
(
ns
string
,
r
io
.
Reader
,
timeout
time
.
Duration
)
(
v1
.
PodPhase
,
error
)
{
return
v1
.
PodSucceeded
,
nil
}
type
podFailedKubeClient
struct
{
...
...
@@ -338,6 +338,6 @@ func newPodFailedKubeClient() *podFailedKubeClient {
}
}
func
(
p
*
podFailedKubeClient
)
WaitAndGetCompletedPodPhase
(
ns
string
,
r
io
.
Reader
,
timeout
time
.
Duration
)
(
core
.
PodPhase
,
error
)
{
return
core
.
PodFailed
,
nil
func
(
p
*
podFailedKubeClient
)
WaitAndGetCompletedPodPhase
(
ns
string
,
r
io
.
Reader
,
timeout
time
.
Duration
)
(
v1
.
PodPhase
,
error
)
{
return
v1
.
PodFailed
,
nil
}
pkg/storage/driver/cfgmaps.go
View file @
de5a6a93
...
...
@@ -22,12 +22,12 @@ import (
"strings"
"time"
"k8s.io/api/core/v1"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
kblabels
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
corev1
"k8s.io/client-go/kubernetes/typed/core/v1"
rspb
"k8s.io/helm/pkg/proto/hapi/release"
storageerrors
"k8s.io/helm/pkg/storage/errors"
...
...
@@ -41,13 +41,13 @@ const ConfigMapsDriverName = "ConfigMap"
// ConfigMaps is a wrapper around an implementation of a kubernetes
// ConfigMapsInterface.
type
ConfigMaps
struct
{
impl
internalversion
.
ConfigMapInterface
impl
corev1
.
ConfigMapInterface
Log
func
(
string
,
...
interface
{})
}
// NewConfigMaps initializes a new ConfigMaps wrapping an implementation of
// the kubernetes ConfigMapsInterface.
func
NewConfigMaps
(
impl
internalversion
.
ConfigMapInterface
)
*
ConfigMaps
{
func
NewConfigMaps
(
impl
corev1
.
ConfigMapInterface
)
*
ConfigMaps
{
return
&
ConfigMaps
{
impl
:
impl
,
Log
:
func
(
_
string
,
_
...
interface
{})
{},
...
...
@@ -229,7 +229,7 @@ func (cfgmaps *ConfigMaps) Delete(key string) (rls *rspb.Release, err error) {
// "OWNER" - owner of the configmap, currently "TILLER".
// "NAME" - name of the release.
//
func
newConfigMapsObject
(
key
string
,
rls
*
rspb
.
Release
,
lbs
labels
)
(
*
core
.
ConfigMap
,
error
)
{
func
newConfigMapsObject
(
key
string
,
rls
*
rspb
.
Release
,
lbs
labels
)
(
*
v1
.
ConfigMap
,
error
)
{
const
owner
=
"TILLER"
// encode the release
...
...
@@ -249,7 +249,7 @@ func newConfigMapsObject(key string, rls *rspb.Release, lbs labels) (*core.Confi
lbs
.
set
(
"VERSION"
,
strconv
.
Itoa
(
int
(
rls
.
Version
)))
// create and return configmap object
return
&
core
.
ConfigMap
{
return
&
v1
.
ConfigMap
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
key
,
Labels
:
lbs
.
toMap
(),
...
...
pkg/storage/driver/cfgmaps_test.go
View file @
de5a6a93
...
...
@@ -19,7 +19,7 @@ import (
"testing"
"github.com/gogo/protobuf/proto"
"k8s.io/
kubernetes/pkg/apis/core
"
"k8s.io/
api/core/v1
"
rspb
"k8s.io/helm/pkg/proto/hapi/release"
)
...
...
@@ -69,7 +69,7 @@ func TestUNcompressedConfigMapGet(t *testing.T) {
}
cfgmap
.
Data
[
"release"
]
=
base64
.
StdEncoding
.
EncodeToString
(
b
)
var
mock
MockConfigMapsInterface
mock
.
objects
=
map
[
string
]
*
core
.
ConfigMap
{
key
:
cfgmap
}
mock
.
objects
=
map
[
string
]
*
v1
.
ConfigMap
{
key
:
cfgmap
}
cfgmaps
:=
NewConfigMaps
(
&
mock
)
// get release with key
...
...
pkg/storage/driver/mock_test.go
View file @
de5a6a93
...
...
@@ -20,10 +20,11 @@ import (
"fmt"
"testing"
"k8s.io/api/core/v1"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/
kubernetes/pkg/apis/core
"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion
"
"k8s.io/
apimachinery/pkg/runtime/schema
"
corev1
"k8s.io/client-go/kubernetes/typed/core/v1
"
rspb
"k8s.io/helm/pkg/proto/hapi/release"
)
...
...
@@ -76,14 +77,14 @@ func newTestFixtureCfgMaps(t *testing.T, releases ...*rspb.Release) *ConfigMaps
// MockConfigMapsInterface mocks a kubernetes ConfigMapsInterface
type
MockConfigMapsInterface
struct
{
internalversion
.
ConfigMapInterface
corev1
.
ConfigMapInterface
objects
map
[
string
]
*
core
.
ConfigMap
objects
map
[
string
]
*
v1
.
ConfigMap
}
// Init initializes the MockConfigMapsInterface with the set of releases.
func
(
mock
*
MockConfigMapsInterface
)
Init
(
t
*
testing
.
T
,
releases
...*
rspb
.
Release
)
{
mock
.
objects
=
map
[
string
]
*
core
.
ConfigMap
{}
mock
.
objects
=
map
[
string
]
*
v1
.
ConfigMap
{}
for
_
,
rls
:=
range
releases
{
objkey
:=
testKey
(
rls
.
Name
,
rls
.
Version
)
...
...
@@ -97,17 +98,17 @@ func (mock *MockConfigMapsInterface) Init(t *testing.T, releases ...*rspb.Releas
}
// Get returns the ConfigMap by name.
func
(
mock
*
MockConfigMapsInterface
)
Get
(
name
string
,
options
metav1
.
GetOptions
)
(
*
core
.
ConfigMap
,
error
)
{
func
(
mock
*
MockConfigMapsInterface
)
Get
(
name
string
,
options
metav1
.
GetOptions
)
(
*
v1
.
ConfigMap
,
error
)
{
object
,
ok
:=
mock
.
objects
[
name
]
if
!
ok
{
return
nil
,
apierrors
.
NewNotFound
(
core
.
Resource
(
"tests"
)
,
name
)
return
nil
,
apierrors
.
NewNotFound
(
schema
.
GroupResource
{
Resource
:
"tests"
}
,
name
)
}
return
object
,
nil
}
// List returns the a of ConfigMaps.
func
(
mock
*
MockConfigMapsInterface
)
List
(
opts
metav1
.
ListOptions
)
(
*
core
.
ConfigMapList
,
error
)
{
var
list
core
.
ConfigMapList
func
(
mock
*
MockConfigMapsInterface
)
List
(
opts
metav1
.
ListOptions
)
(
*
v1
.
ConfigMapList
,
error
)
{
var
list
v1
.
ConfigMapList
for
_
,
cfgmap
:=
range
mock
.
objects
{
list
.
Items
=
append
(
list
.
Items
,
*
cfgmap
)
}
...
...
@@ -115,20 +116,20 @@ func (mock *MockConfigMapsInterface) List(opts metav1.ListOptions) (*core.Config
}
// Create creates a new ConfigMap.
func
(
mock
*
MockConfigMapsInterface
)
Create
(
cfgmap
*
core
.
ConfigMap
)
(
*
core
.
ConfigMap
,
error
)
{
func
(
mock
*
MockConfigMapsInterface
)
Create
(
cfgmap
*
v1
.
ConfigMap
)
(
*
v1
.
ConfigMap
,
error
)
{
name
:=
cfgmap
.
ObjectMeta
.
Name
if
object
,
ok
:=
mock
.
objects
[
name
];
ok
{
return
object
,
apierrors
.
NewAlreadyExists
(
core
.
Resource
(
"tests"
)
,
name
)
return
object
,
apierrors
.
NewAlreadyExists
(
schema
.
GroupResource
{
Resource
:
"tests"
}
,
name
)
}
mock
.
objects
[
name
]
=
cfgmap
return
cfgmap
,
nil
}
// Update updates a ConfigMap.
func
(
mock
*
MockConfigMapsInterface
)
Update
(
cfgmap
*
core
.
ConfigMap
)
(
*
core
.
ConfigMap
,
error
)
{
func
(
mock
*
MockConfigMapsInterface
)
Update
(
cfgmap
*
v1
.
ConfigMap
)
(
*
v1
.
ConfigMap
,
error
)
{
name
:=
cfgmap
.
ObjectMeta
.
Name
if
_
,
ok
:=
mock
.
objects
[
name
];
!
ok
{
return
nil
,
apierrors
.
NewNotFound
(
core
.
Resource
(
"tests"
),
name
)
return
nil
,
apierrors
.
NewNotFound
(
v1
.
Resource
(
"tests"
),
name
)
}
mock
.
objects
[
name
]
=
cfgmap
return
cfgmap
,
nil
...
...
@@ -137,7 +138,7 @@ func (mock *MockConfigMapsInterface) Update(cfgmap *core.ConfigMap) (*core.Confi
// Delete deletes a ConfigMap by name.
func
(
mock
*
MockConfigMapsInterface
)
Delete
(
name
string
,
opts
*
metav1
.
DeleteOptions
)
error
{
if
_
,
ok
:=
mock
.
objects
[
name
];
!
ok
{
return
apierrors
.
NewNotFound
(
core
.
Resource
(
"tests"
),
name
)
return
apierrors
.
NewNotFound
(
v1
.
Resource
(
"tests"
),
name
)
}
delete
(
mock
.
objects
,
name
)
return
nil
...
...
@@ -154,14 +155,14 @@ func newTestFixtureSecrets(t *testing.T, releases ...*rspb.Release) *Secrets {
// MockSecretsInterface mocks a kubernetes SecretsInterface
type
MockSecretsInterface
struct
{
internalversion
.
SecretInterface
corev1
.
SecretInterface
objects
map
[
string
]
*
core
.
Secret
objects
map
[
string
]
*
v1
.
Secret
}
// Init initializes the MockSecretsInterface with the set of releases.
func
(
mock
*
MockSecretsInterface
)
Init
(
t
*
testing
.
T
,
releases
...*
rspb
.
Release
)
{
mock
.
objects
=
map
[
string
]
*
core
.
Secret
{}
mock
.
objects
=
map
[
string
]
*
v1
.
Secret
{}
for
_
,
rls
:=
range
releases
{
objkey
:=
testKey
(
rls
.
Name
,
rls
.
Version
)
...
...
@@ -175,17 +176,17 @@ func (mock *MockSecretsInterface) Init(t *testing.T, releases ...*rspb.Release)
}
// Get returns the Secret by name.
func
(
mock
*
MockSecretsInterface
)
Get
(
name
string
,
options
metav1
.
GetOptions
)
(
*
core
.
Secret
,
error
)
{
func
(
mock
*
MockSecretsInterface
)
Get
(
name
string
,
options
metav1
.
GetOptions
)
(
*
v1
.
Secret
,
error
)
{
object
,
ok
:=
mock
.
objects
[
name
]
if
!
ok
{
return
nil
,
apierrors
.
NewNotFound
(
core
.
Resource
(
"tests"
)
,
name
)
return
nil
,
apierrors
.
NewNotFound
(
schema
.
GroupResource
{
Resource
:
"tests"
}
,
name
)
}
return
object
,
nil
}
// List returns the a of Secret.
func
(
mock
*
MockSecretsInterface
)
List
(
opts
metav1
.
ListOptions
)
(
*
core
.
SecretList
,
error
)
{
var
list
core
.
SecretList
func
(
mock
*
MockSecretsInterface
)
List
(
opts
metav1
.
ListOptions
)
(
*
v1
.
SecretList
,
error
)
{
var
list
v1
.
SecretList
for
_
,
secret
:=
range
mock
.
objects
{
list
.
Items
=
append
(
list
.
Items
,
*
secret
)
}
...
...
@@ -193,20 +194,20 @@ func (mock *MockSecretsInterface) List(opts metav1.ListOptions) (*core.SecretLis
}
// Create creates a new Secret.
func
(
mock
*
MockSecretsInterface
)
Create
(
secret
*
core
.
Secret
)
(
*
core
.
Secret
,
error
)
{
func
(
mock
*
MockSecretsInterface
)
Create
(
secret
*
v1
.
Secret
)
(
*
v1
.
Secret
,
error
)
{
name
:=
secret
.
ObjectMeta
.
Name
if
object
,
ok
:=
mock
.
objects
[
name
];
ok
{
return
object
,
apierrors
.
NewAlreadyExists
(
core
.
Resource
(
"tests"
)
,
name
)
return
object
,
apierrors
.
NewAlreadyExists
(
schema
.
GroupResource
{
Resource
:
"tests"
}
,
name
)
}
mock
.
objects
[
name
]
=
secret
return
secret
,
nil
}
// Update updates a Secret.
func
(
mock
*
MockSecretsInterface
)
Update
(
secret
*
core
.
Secret
)
(
*
core
.
Secret
,
error
)
{
func
(
mock
*
MockSecretsInterface
)
Update
(
secret
*
v1
.
Secret
)
(
*
v1
.
Secret
,
error
)
{
name
:=
secret
.
ObjectMeta
.
Name
if
_
,
ok
:=
mock
.
objects
[
name
];
!
ok
{
return
nil
,
apierrors
.
NewNotFound
(
core
.
Resource
(
"tests"
)
,
name
)
return
nil
,
apierrors
.
NewNotFound
(
schema
.
GroupResource
{
Resource
:
"tests"
}
,
name
)
}
mock
.
objects
[
name
]
=
secret
return
secret
,
nil
...
...
@@ -215,7 +216,7 @@ func (mock *MockSecretsInterface) Update(secret *core.Secret) (*core.Secret, err
// Delete deletes a Secret by name.
func
(
mock
*
MockSecretsInterface
)
Delete
(
name
string
,
opts
*
metav1
.
DeleteOptions
)
error
{
if
_
,
ok
:=
mock
.
objects
[
name
];
!
ok
{
return
apierrors
.
NewNotFound
(
core
.
Resource
(
"tests"
)
,
name
)
return
apierrors
.
NewNotFound
(
schema
.
GroupResource
{
Resource
:
"tests"
}
,
name
)
}
delete
(
mock
.
objects
,
name
)
return
nil
...
...
pkg/storage/driver/secrets.go
View file @
de5a6a93
...
...
@@ -22,12 +22,12 @@ import (
"strings"
"time"
"k8s.io/api/core/v1"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
kblabels
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
corev1
"k8s.io/client-go/kubernetes/typed/core/v1"
rspb
"k8s.io/helm/pkg/proto/hapi/release"
storageerrors
"k8s.io/helm/pkg/storage/errors"
...
...
@@ -41,13 +41,13 @@ const SecretsDriverName = "Secret"
// Secrets is a wrapper around an implementation of a kubernetes
// SecretsInterface.
type
Secrets
struct
{
impl
internalversion
.
SecretInterface
impl
corev1
.
SecretInterface
Log
func
(
string
,
...
interface
{})
}
// NewSecrets initializes a new Secrets wrapping an implmenetation of
// the kubernetes SecretsInterface.
func
NewSecrets
(
impl
internalversion
.
SecretInterface
)
*
Secrets
{
func
NewSecrets
(
impl
corev1
.
SecretInterface
)
*
Secrets
{
return
&
Secrets
{
impl
:
impl
,
Log
:
func
(
_
string
,
_
...
interface
{})
{},
...
...
@@ -229,7 +229,7 @@ func (secrets *Secrets) Delete(key string) (rls *rspb.Release, err error) {
// "OWNER" - owner of the secret, currently "TILLER".
// "NAME" - name of the release.
//
func
newSecretsObject
(
key
string
,
rls
*
rspb
.
Release
,
lbs
labels
)
(
*
core
.
Secret
,
error
)
{
func
newSecretsObject
(
key
string
,
rls
*
rspb
.
Release
,
lbs
labels
)
(
*
v1
.
Secret
,
error
)
{
const
owner
=
"TILLER"
// encode the release
...
...
@@ -249,7 +249,7 @@ func newSecretsObject(key string, rls *rspb.Release, lbs labels) (*core.Secret,
lbs
.
set
(
"VERSION"
,
strconv
.
Itoa
(
int
(
rls
.
Version
)))
// create and return secret object
return
&
core
.
Secret
{
return
&
v1
.
Secret
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
key
,
Labels
:
lbs
.
toMap
(),
...
...
pkg/storage/driver/secrets_test.go
View file @
de5a6a93
...
...
@@ -19,7 +19,7 @@ import (
"testing"
"github.com/gogo/protobuf/proto"
"k8s.io/
kubernetes/pkg/apis/core
"
"k8s.io/
api/core/v1
"
rspb
"k8s.io/helm/pkg/proto/hapi/release"
)
...
...
@@ -69,7 +69,7 @@ func TestUNcompressedSecretGet(t *testing.T) {
}
secret
.
Data
[
"release"
]
=
[]
byte
(
base64
.
StdEncoding
.
EncodeToString
(
b
))
var
mock
MockSecretsInterface
mock
.
objects
=
map
[
string
]
*
core
.
Secret
{
key
:
secret
}
mock
.
objects
=
map
[
string
]
*
v1
.
Secret
{
key
:
secret
}
secrets
:=
NewSecrets
(
&
mock
)
// get release with key
...
...
pkg/tiller/environment/environment.go
View file @
de5a6a93
...
...
@@ -26,8 +26,8 @@ import (
"io"
"time"
"k8s.io/
kubernetes/pkg/apis/core
"
"k8s.io/
kubernetes/pkg/kubectl
/genericclioptions/resource"
"k8s.io/
api/core/v1
"
"k8s.io/
cli-runtime/pkg
/genericclioptions/resource"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/engine"
...
...
@@ -140,7 +140,7 @@ type KubeClient interface {
// WaitAndGetCompletedPodPhase waits up to a timeout until a pod enters a completed phase
// and returns said phase (PodSucceeded or PodFailed qualify).
WaitAndGetCompletedPodPhase
(
namespace
string
,
reader
io
.
Reader
,
timeout
time
.
Duration
)
(
core
.
PodPhase
,
error
)
WaitAndGetCompletedPodPhase
(
namespace
string
,
reader
io
.
Reader
,
timeout
time
.
Duration
)
(
v1
.
PodPhase
,
error
)
}
// PrintingKubeClient implements KubeClient, but simply prints the reader to
...
...
@@ -192,9 +192,9 @@ func (p *PrintingKubeClient) BuildUnstructured(ns string, reader io.Reader) (kub
}
// WaitAndGetCompletedPodPhase implements KubeClient WaitAndGetCompletedPodPhase.
func
(
p
*
PrintingKubeClient
)
WaitAndGetCompletedPodPhase
(
namespace
string
,
reader
io
.
Reader
,
timeout
time
.
Duration
)
(
core
.
PodPhase
,
error
)
{
func
(
p
*
PrintingKubeClient
)
WaitAndGetCompletedPodPhase
(
namespace
string
,
reader
io
.
Reader
,
timeout
time
.
Duration
)
(
v1
.
PodPhase
,
error
)
{
_
,
err
:=
io
.
Copy
(
p
.
Out
,
reader
)
return
core
.
PodUnknown
,
err
return
v1
.
PodUnknown
,
err
}
// Environment provides the context for executing a client request.
...
...
pkg/tiller/environment/environment_test.go
View file @
de5a6a93
...
...
@@ -22,8 +22,8 @@ import (
"testing"
"time"
"k8s.io/
kubernetes/pkg/apis/core
"
"k8s.io/
kubernetes/pkg/kubectl
/genericclioptions/resource"
"k8s.io/
api/core/v1
"
"k8s.io/
cli-runtime/pkg
/genericclioptions/resource"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/kube"
...
...
@@ -61,11 +61,11 @@ func (k *mockKubeClient) Build(ns string, reader io.Reader) (kube.Result, error)
func
(
k
*
mockKubeClient
)
BuildUnstructured
(
ns
string
,
reader
io
.
Reader
)
(
kube
.
Result
,
error
)
{
return
[]
*
resource
.
Info
{},
nil
}
func
(
k
*
mockKubeClient
)
WaitAndGetCompletedPodPhase
(
namespace
string
,
reader
io
.
Reader
,
timeout
time
.
Duration
)
(
core
.
PodPhase
,
error
)
{
return
core
.
PodUnknown
,
nil
func
(
k
*
mockKubeClient
)
WaitAndGetCompletedPodPhase
(
namespace
string
,
reader
io
.
Reader
,
timeout
time
.
Duration
)
(
v1
.
PodPhase
,
error
)
{
return
v1
.
PodUnknown
,
nil
}
func
(
k
*
mockKubeClient
)
WaitAndGetCompletedPodStatus
(
namespace
string
,
reader
io
.
Reader
,
timeout
time
.
Duration
)
(
core
.
PodPhase
,
error
)
{
func
(
k
*
mockKubeClient
)
WaitAndGetCompletedPodStatus
(
namespace
string
,
reader
io
.
Reader
,
timeout
time
.
Duration
)
(
v1
.
PodPhase
,
error
)
{
return
""
,
nil
}
...
...
pkg/tiller/release_modules.go
View file @
de5a6a93
...
...
@@ -23,7 +23,7 @@ import (
"log"
"strings"
"k8s.io/
kubernetes/pkg/client/clientset_generated/internalclientset
"
"k8s.io/
client-go/kubernetes
"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/kube"
...
...
@@ -46,7 +46,7 @@ type ReleaseModule interface {
// LocalReleaseModule is a local implementation of ReleaseModule
type
LocalReleaseModule
struct
{
clientset
internalclientset
.
Interface
clientset
kubernetes
.
Interface
}
// Create creates a release via kubeclient from provided environment
...
...
pkg/tiller/release_server.go
View file @
de5a6a93
...
...
@@ -28,7 +28,7 @@ import (
"gopkg.in/yaml.v2"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/discovery"
"k8s.io/
kubernetes/pkg/client/clientset_generated/internalclientset
"
"k8s.io/
client-go/kubernetes
"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/hooks"
...
...
@@ -83,12 +83,12 @@ var ValidName = regexp.MustCompile("^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])+
type
ReleaseServer
struct
{
ReleaseModule
env
*
environment
.
Environment
clientset
internalclientset
.
Interface
clientset
kubernetes
.
Interface
Log
func
(
string
,
...
interface
{})
}
// NewReleaseServer creates a new release server.
func
NewReleaseServer
(
env
*
environment
.
Environment
,
clientset
internalclientset
.
Interface
,
useRemote
bool
)
*
ReleaseServer
{
func
NewReleaseServer
(
env
*
environment
.
Environment
,
clientset
kubernetes
.
Interface
,
useRemote
bool
)
*
ReleaseServer
{
var
releaseModule
ReleaseModule
if
useRemote
{
releaseModule
=
&
RemoteReleaseModule
{}
...
...
pkg/tiller/release_server_test.go
View file @
de5a6a93
...
...
@@ -31,9 +31,9 @@ import (
"github.com/technosophos/moniker"
"golang.org/x/net/context"
"google.golang.org/grpc/metadata"
"k8s.io/
kubernetes/pkg/apis/core
"
"k8s.io/
kubernetes/pkg/client/clientset_generated/internalclientset/fak
e"
"k8s.io/
kubernetes/pkg/kubectl/genericclioptions/resourc
e"
"k8s.io/
api/core/v1
"
"k8s.io/
cli-runtime/pkg/genericclioptions/resourc
e"
"k8s.io/
client-go/kubernetes/fak
e"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/hooks"
...
...
@@ -605,8 +605,8 @@ func (kc *mockHooksKubeClient) Build(ns string, reader io.Reader) (kube.Result,
func
(
kc
*
mockHooksKubeClient
)
BuildUnstructured
(
ns
string
,
reader
io
.
Reader
)
(
kube
.
Result
,
error
)
{
return
[]
*
resource
.
Info
{},
nil
}
func
(
kc
*
mockHooksKubeClient
)
WaitAndGetCompletedPodPhase
(
namespace
string
,
reader
io
.
Reader
,
timeout
time
.
Duration
)
(
core
.
PodPhase
,
error
)
{
return
core
.
PodUnknown
,
nil
func
(
kc
*
mockHooksKubeClient
)
WaitAndGetCompletedPodPhase
(
namespace
string
,
reader
io
.
Reader
,
timeout
time
.
Duration
)
(
v1
.
PodPhase
,
error
)
{
return
v1
.
PodUnknown
,
nil
}
func
deletePolicyStub
(
kubeClient
*
mockHooksKubeClient
)
*
ReleaseServer
{
...
...
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