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
2b43ecd4
Unverified
Commit
2b43ecd4
authored
Oct 11, 2017
by
Adam Reese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ref(*): kubernetes v1.8 support
parent
3410a690
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
60 additions
and
93 deletions
+60
-93
helm.go
cmd/helm/helm.go
+4
-4
init_test.go
cmd/helm/init_test.go
+2
-2
install.go
cmd/helm/installer/install.go
+2
-2
install_test.go
cmd/helm/installer/install_test.go
+2
-2
options.go
cmd/helm/installer/options.go
+1
-1
uninstall.go
cmd/helm/installer/uninstall.go
+1
-1
reset.go
cmd/helm/reset.go
+1
-1
glide.lock
glide.lock
+0
-0
glide.yaml
glide.yaml
+1
-31
pod.go
pkg/helm/portforwarder/pod.go
+1
-1
portforwarder.go
pkg/helm/portforwarder/portforwarder.go
+1
-1
portforwarder_test.go
pkg/helm/portforwarder/portforwarder_test.go
+1
-1
client.go
pkg/kube/client.go
+15
-13
client_test.go
pkg/kube/client_test.go
+1
-1
tunnel.go
pkg/kube/tunnel.go
+4
-2
wait.go
pkg/kube/wait.go
+23
-30
No files found.
cmd/helm/helm.go
View file @
2b43ecd4
...
@@ -239,16 +239,16 @@ func getKubeClient(context string) (*rest.Config, kubernetes.Interface, error) {
...
@@ -239,16 +239,16 @@ func getKubeClient(context string) (*rest.Config, kubernetes.Interface, error) {
// getInternalKubeClient creates a Kubernetes config and an "internal" client for a given kubeconfig context.
// 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.
// Prefer the similar getKubeClient if you don't need to use such an internal client.
func
getInternalKubeClient
(
context
string
)
(
*
rest
.
Config
,
internalclientset
.
Interface
,
error
)
{
func
getInternalKubeClient
(
context
string
)
(
internalclientset
.
Interface
,
error
)
{
config
,
err
:=
configForContext
(
context
)
config
,
err
:=
configForContext
(
context
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
err
}
}
client
,
err
:=
internalclientset
.
NewForConfig
(
config
)
client
,
err
:=
internalclientset
.
NewForConfig
(
config
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
fmt
.
Errorf
(
"could not get Kubernetes client: %s"
,
err
)
return
nil
,
fmt
.
Errorf
(
"could not get Kubernetes client: %s"
,
err
)
}
}
return
c
onfig
,
c
lient
,
nil
return
client
,
nil
}
}
// ensureHelmClient returns a new helm client impl. if h is not nil.
// ensureHelmClient returns a new helm client impl. if h is not nil.
...
...
cmd/helm/init_test.go
View file @
2b43ecd4
...
@@ -27,12 +27,12 @@ import (
...
@@ -27,12 +27,12 @@ import (
"github.com/ghodss/yaml"
"github.com/ghodss/yaml"
"k8s.io/api/core/v1"
"k8s.io/api/extensions/v1beta1"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes/fake"
"k8s.io/client-go/kubernetes/fake"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/apis/extensions/v1beta1"
testcore
"k8s.io/client-go/testing"
testcore
"k8s.io/client-go/testing"
"encoding/json"
"encoding/json"
...
...
cmd/helm/installer/install.go
View file @
2b43ecd4
...
@@ -22,14 +22,14 @@ import (
...
@@ -22,14 +22,14 @@ import (
"strings"
"strings"
"github.com/ghodss/yaml"
"github.com/ghodss/yaml"
"k8s.io/api/core/v1"
"k8s.io/api/extensions/v1beta1"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes"
corev1
"k8s.io/client-go/kubernetes/typed/core/v1"
corev1
"k8s.io/client-go/kubernetes/typed/core/v1"
extensionsclient
"k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
extensionsclient
"k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/apis/extensions/v1beta1"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/chartutil"
)
)
...
...
cmd/helm/installer/install_test.go
View file @
2b43ecd4
...
@@ -23,11 +23,11 @@ import (
...
@@ -23,11 +23,11 @@ import (
"testing"
"testing"
"github.com/ghodss/yaml"
"github.com/ghodss/yaml"
"k8s.io/api/core/v1"
"k8s.io/api/extensions/v1beta1"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes/fake"
"k8s.io/client-go/kubernetes/fake"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/apis/extensions/v1beta1"
testcore
"k8s.io/client-go/testing"
testcore
"k8s.io/client-go/testing"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/chartutil"
...
...
cmd/helm/installer/options.go
View file @
2b43ecd4
...
@@ -19,7 +19,7 @@ package installer // import "k8s.io/helm/cmd/helm/installer"
...
@@ -19,7 +19,7 @@ package installer // import "k8s.io/helm/cmd/helm/installer"
import
(
import
(
"fmt"
"fmt"
"k8s.io/
client-go/pkg/api
/v1"
"k8s.io/
api/core
/v1"
"k8s.io/helm/pkg/strvals"
"k8s.io/helm/pkg/strvals"
"k8s.io/helm/pkg/version"
"k8s.io/helm/pkg/version"
)
)
...
...
cmd/helm/installer/uninstall.go
View file @
2b43ecd4
...
@@ -19,7 +19,7 @@ package installer // import "k8s.io/helm/cmd/helm/installer"
...
@@ -19,7 +19,7 @@ package installer // import "k8s.io/helm/cmd/helm/installer"
import
(
import
(
apierrors
"k8s.io/apimachinery/pkg/api/errors"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/
client-go
/pkg/apis/extensions"
"k8s.io/
kubernetes
/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
coreclient
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
coreclient
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
"k8s.io/kubernetes/pkg/kubectl"
"k8s.io/kubernetes/pkg/kubectl"
...
...
cmd/helm/reset.go
View file @
2b43ecd4
...
@@ -86,7 +86,7 @@ func newResetCmd(client helm.Interface, out io.Writer) *cobra.Command {
...
@@ -86,7 +86,7 @@ func newResetCmd(client helm.Interface, out io.Writer) *cobra.Command {
// runReset uninstalls tiller from Kubernetes Cluster and deletes local config
// runReset uninstalls tiller from Kubernetes Cluster and deletes local config
func
(
d
*
resetCmd
)
run
()
error
{
func
(
d
*
resetCmd
)
run
()
error
{
if
d
.
kubeClient
==
nil
{
if
d
.
kubeClient
==
nil
{
_
,
c
,
err
:=
getInternalKubeClient
(
settings
.
KubeContext
)
c
,
err
:=
getInternalKubeClient
(
settings
.
KubeContext
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"could not get kubernetes client: %s"
,
err
)
return
fmt
.
Errorf
(
"could not get kubernetes client: %s"
,
err
)
}
}
...
...
glide.lock
View file @
2b43ecd4
This diff is collapsed.
Click to expand it.
glide.yaml
View file @
2b43ecd4
...
@@ -28,7 +28,7 @@ import:
...
@@ -28,7 +28,7 @@ import:
-
package
:
google.golang.org/grpc
-
package
:
google.golang.org/grpc
version
:
1.2.1
version
:
1.2.1
-
package
:
k8s.io/kubernetes
-
package
:
k8s.io/kubernetes
version
:
~1.
7
.0
version
:
~1.
8
.0
-
package
:
github.com/gosuri/uitable
-
package
:
github.com/gosuri/uitable
-
package
:
github.com/asaskevich/govalidator
-
package
:
github.com/asaskevich/govalidator
version
:
^4.0.0
version
:
^4.0.0
...
@@ -48,37 +48,7 @@ import:
...
@@ -48,37 +48,7 @@ import:
-
package
:
vbom.ml/util
-
package
:
vbom.ml/util
repo
:
https://github.com/fvbommel/util.git
repo
:
https://github.com/fvbommel/util.git
vcs
:
git
vcs
:
git
-
package
:
github.com/docker/distribution
version
:
~2.4.0
# hacks for kubernetes v1.7
-
package
:
cloud.google.com/go
-
package
:
github.com/Azure/go-autorest
version
:
v8.0.0
-
package
:
github.com/dgrijalva/jwt-go
-
package
:
github.com/docker/spdystream
-
package
:
github.com/go-openapi/analysis
version
:
b44dc874b601d9e4e2f6e19140e794ba24bead3b
-
package
:
github.com/go-openapi/errors
version
:
d24ebc2075bad502fac3a8ae27aa6dd58e1952dc
-
package
:
github.com/go-openapi/loads
version
:
18441dfa706d924a39a030ee2c3b1d8d81917b38
-
package
:
github.com/go-openapi/spec
version
:
6aced65f8501fe1217321abf0749d354824ba2ff
-
package
:
github.com/google/gofuzz
-
package
:
github.com/hashicorp/golang-lru
-
package
:
github.com/howeyc/gopass
-
package
:
github.com/juju/ratelimit
version
:
5b9ff866471762aa2ab2dced63c9fb6f53921342
-
package
:
github.com/pborman/uuid
-
package
:
golang.org/x/oauth2
-
package
:
gopkg.in/inf.v0
-
package
:
github.com/go-openapi/strfmt
-
package
:
github.com/mitchellh/mapstructure
-
package
:
gopkg.in/mgo.v2/bson
ignore
:
-
k8s.io/client-go
-
k8s.io/apimachinery
testImports
:
testImports
:
-
package
:
github.com/stretchr/testify
-
package
:
github.com/stretchr/testify
version
:
^1.1.4
version
:
^1.1.4
...
...
pkg/helm/portforwarder/pod.go
View file @
2b43ecd4
...
@@ -17,7 +17,7 @@ limitations under the License.
...
@@ -17,7 +17,7 @@ limitations under the License.
package
portforwarder
package
portforwarder
import
(
import
(
"k8s.io/
client-go/pkg/api
/v1"
"k8s.io/
api/core
/v1"
)
)
// These functions are adapted from the "kubernetes" repository's file
// These functions are adapted from the "kubernetes" repository's file
...
...
pkg/helm/portforwarder/portforwarder.go
View file @
2b43ecd4
...
@@ -19,11 +19,11 @@ package portforwarder
...
@@ -19,11 +19,11 @@ package portforwarder
import
(
import
(
"fmt"
"fmt"
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes"
corev1
"k8s.io/client-go/kubernetes/typed/core/v1"
corev1
"k8s.io/client-go/kubernetes/typed/core/v1"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/rest"
"k8s.io/client-go/rest"
"k8s.io/helm/pkg/kube"
"k8s.io/helm/pkg/kube"
...
...
pkg/helm/portforwarder/portforwarder_test.go
View file @
2b43ecd4
...
@@ -19,9 +19,9 @@ package portforwarder
...
@@ -19,9 +19,9 @@ package portforwarder
import
(
import
(
"testing"
"testing"
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/fake"
"k8s.io/client-go/kubernetes/fake"
"k8s.io/client-go/pkg/api/v1"
)
)
func
mockTillerPod
()
v1
.
Pod
{
func
mockTillerPod
()
v1
.
Pod
{
...
...
pkg/kube/client.go
View file @
2b43ecd4
...
@@ -27,6 +27,10 @@ import (
...
@@ -27,6 +27,10 @@ import (
"time"
"time"
jsonpatch
"github.com/evanphx/json-patch"
jsonpatch
"github.com/evanphx/json-patch"
apps
"k8s.io/api/apps/v1beta2"
batch
"k8s.io/api/batch/v1"
"k8s.io/api/core/v1"
"k8s.io/api/extensions/v1beta1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
@@ -40,15 +44,12 @@ import (
...
@@ -40,15 +44,12 @@ import (
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/helper"
"k8s.io/kubernetes/pkg/api/helper"
"k8s.io/kubernetes/pkg/api/v1"
apps
"k8s.io/kubernetes/pkg/apis/apps/v1beta1"
batchinternal
"k8s.io/kubernetes/pkg/apis/batch"
batchinternal
"k8s.io/kubernetes/pkg/apis/batch"
batch
"k8s.io/kubernetes/pkg/apis/batch/v1"
"k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
conditions
"k8s.io/kubernetes/pkg/client/unversioned"
conditions
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/kubectl"
"k8s.io/kubernetes/pkg/kubectl"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/kubectl/validation"
"k8s.io/kubernetes/pkg/printers"
"k8s.io/kubernetes/pkg/printers"
)
)
...
@@ -103,13 +104,9 @@ func (c *Client) Create(namespace string, reader io.Reader, timeout int64, shoul
...
@@ -103,13 +104,9 @@ func (c *Client) Create(namespace string, reader io.Reader, timeout int64, shoul
}
}
func
(
c
*
Client
)
newBuilder
(
namespace
string
,
reader
io
.
Reader
)
*
resource
.
Result
{
func
(
c
*
Client
)
newBuilder
(
namespace
string
,
reader
io
.
Reader
)
*
resource
.
Result
{
schema
,
err
:=
c
.
Validator
(
true
,
c
.
SchemaCacheDir
)
if
err
!=
nil
{
c
.
Log
(
"warning: failed to load schema: %s"
,
err
)
}
return
c
.
NewBuilder
(
true
)
.
return
c
.
NewBuilder
(
true
)
.
ContinueOnError
()
.
ContinueOnError
()
.
Schema
(
schema
)
.
Schema
(
c
.
validator
()
)
.
NamespaceParam
(
namespace
)
.
NamespaceParam
(
namespace
)
.
DefaultNamespace
()
.
DefaultNamespace
()
.
Stream
(
reader
,
""
)
.
Stream
(
reader
,
""
)
.
...
@@ -117,20 +114,25 @@ func (c *Client) newBuilder(namespace string, reader io.Reader) *resource.Result
...
@@ -117,20 +114,25 @@ func (c *Client) newBuilder(namespace string, reader io.Reader) *resource.Result
Do
()
Do
()
}
}
// BuildUnstructured validates for Kubernetes objects and returns unstructured infos.
func
(
c
*
Client
)
validator
()
validation
.
Schema
{
func
(
c
*
Client
)
BuildUnstructured
(
namespace
string
,
reader
io
.
Reader
)
(
Result
,
error
)
{
const
openapi
=
false
// only works on v1.8 clusters
schema
,
err
:=
c
.
Validator
(
true
,
c
.
SchemaCacheDir
)
schema
,
err
:=
c
.
Validator
(
true
,
openapi
,
c
.
SchemaCacheDir
)
if
err
!=
nil
{
if
err
!=
nil
{
c
.
Log
(
"warning: failed to load schema: %s"
,
err
)
c
.
Log
(
"warning: failed to load schema: %s"
,
err
)
}
}
return
schema
}
// BuildUnstructured validates for Kubernetes objects and returns unstructured infos.
func
(
c
*
Client
)
BuildUnstructured
(
namespace
string
,
reader
io
.
Reader
)
(
Result
,
error
)
{
var
result
Result
var
result
Result
b
,
err
:=
c
.
NewUnstructuredBuilder
(
true
)
b
,
err
:=
c
.
NewUnstructuredBuilder
(
true
)
if
err
!=
nil
{
if
err
!=
nil
{
return
result
,
err
return
result
,
err
}
}
result
,
err
=
b
.
ContinueOnError
()
.
result
,
err
=
b
.
ContinueOnError
()
.
Schema
(
schema
)
.
Schema
(
c
.
validator
()
)
.
NamespaceParam
(
namespace
)
.
NamespaceParam
(
namespace
)
.
DefaultNamespace
()
.
DefaultNamespace
()
.
Stream
(
reader
,
""
)
.
Stream
(
reader
,
""
)
.
...
...
pkg/kube/client_test.go
View file @
2b43ecd4
...
@@ -35,11 +35,11 @@ import (
...
@@ -35,11 +35,11 @@ import (
"k8s.io/client-go/rest/fake"
"k8s.io/client-go/rest/fake"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/validation"
"k8s.io/kubernetes/pkg/kubectl"
"k8s.io/kubernetes/pkg/kubectl"
cmdtesting
"k8s.io/kubernetes/pkg/kubectl/cmd/testing"
cmdtesting
"k8s.io/kubernetes/pkg/kubectl/cmd/testing"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/kubectl/validation"
"k8s.io/kubernetes/pkg/printers"
"k8s.io/kubernetes/pkg/printers"
watchjson
"k8s.io/kubernetes/pkg/watch/json"
watchjson
"k8s.io/kubernetes/pkg/watch/json"
)
)
...
...
pkg/kube/tunnel.go
View file @
2b43ecd4
...
@@ -21,11 +21,12 @@ import (
...
@@ -21,11 +21,12 @@ import (
"io"
"io"
"io/ioutil"
"io/ioutil"
"net"
"net"
"net/http"
"strconv"
"strconv"
"k8s.io/client-go/rest"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/portforward"
"k8s.io/client-go/tools/portforward"
"k8s.io/client-go/t
ools/remotecommand
"
"k8s.io/client-go/t
ransport/spdy
"
)
)
// Tunnel describes a ssh-like tunnel to a kubernetes pod
// Tunnel describes a ssh-like tunnel to a kubernetes pod
...
@@ -71,10 +72,11 @@ func (t *Tunnel) ForwardPort() error {
...
@@ -71,10 +72,11 @@ func (t *Tunnel) ForwardPort() error {
Name
(
t
.
PodName
)
.
Name
(
t
.
PodName
)
.
SubResource
(
"portforward"
)
.
URL
()
SubResource
(
"portforward"
)
.
URL
()
dialer
,
err
:=
remotecommand
.
NewExecutor
(
t
.
config
,
"POST"
,
u
)
transport
,
upgrader
,
err
:=
spdy
.
RoundTripperFor
(
t
.
config
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
dialer
:=
spdy
.
NewDialer
(
upgrader
,
&
http
.
Client
{
Transport
:
transport
},
"POST"
,
u
)
local
,
err
:=
getAvailablePort
()
local
,
err
:=
getAvailablePort
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/kube/wait.go
View file @
2b43ecd4
...
@@ -19,20 +19,18 @@ package kube // import "k8s.io/helm/pkg/kube"
...
@@ -19,20 +19,18 @@ package kube // import "k8s.io/helm/pkg/kube"
import
(
import
(
"time"
"time"
appsv1beta1
"k8s.io/api/apps/v1beta1"
appsv1beta2
"k8s.io/api/apps/v1beta2"
"k8s.io/api/core/v1"
extensions
"k8s.io/api/extensions/v1beta1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/
kubernetes/pkg/api/v1
"
"k8s.io/
client-go/kubernetes
"
"k8s.io/kubernetes/pkg/api/v1/helper"
"k8s.io/kubernetes/pkg/api/v1/helper"
podutil
"k8s.io/kubernetes/pkg/api/v1/pod"
podutil
"k8s.io/kubernetes/pkg/api/v1/pod"
apps
"k8s.io/kubernetes/pkg/apis/apps/v1beta1"
extensions
"k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
core
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset/typed/core/v1"
extensionsclient
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset/typed/extensions/v1beta1"
internalclientset
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
deploymentutil
"k8s.io/kubernetes/pkg/controller/deployment/util"
deploymentutil
"k8s.io/kubernetes/pkg/controller/deployment/util"
)
)
...
@@ -47,11 +45,10 @@ type deployment struct {
...
@@ -47,11 +45,10 @@ type deployment struct {
func
(
c
*
Client
)
waitForResources
(
timeout
time
.
Duration
,
created
Result
)
error
{
func
(
c
*
Client
)
waitForResources
(
timeout
time
.
Duration
,
created
Result
)
error
{
c
.
Log
(
"beginning wait for %d resources with timeout of %v"
,
len
(
created
),
timeout
)
c
.
Log
(
"beginning wait for %d resources with timeout of %v"
,
len
(
created
),
timeout
)
cs
,
err
:=
c
.
ClientSet
()
kcs
,
err
:=
c
.
Kubernetes
ClientSet
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
client
:=
versionedClientsetForDeployment
(
cs
)
return
wait
.
Poll
(
2
*
time
.
Second
,
timeout
,
func
()
(
bool
,
error
)
{
return
wait
.
Poll
(
2
*
time
.
Second
,
timeout
,
func
()
(
bool
,
error
)
{
pods
:=
[]
v1
.
Pod
{}
pods
:=
[]
v1
.
Pod
{}
services
:=
[]
v1
.
Service
{}
services
:=
[]
v1
.
Service
{}
...
@@ -64,24 +61,24 @@ func (c *Client) waitForResources(timeout time.Duration, created Result) error {
...
@@ -64,24 +61,24 @@ func (c *Client) waitForResources(timeout time.Duration, created Result) error {
}
}
switch
value
:=
obj
.
(
type
)
{
switch
value
:=
obj
.
(
type
)
{
case
(
*
v1
.
ReplicationController
)
:
case
(
*
v1
.
ReplicationController
)
:
list
,
err
:=
getPods
(
client
,
value
.
Namespace
,
value
.
Spec
.
Selector
)
list
,
err
:=
getPods
(
kcs
,
value
.
Namespace
,
value
.
Spec
.
Selector
)
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
false
,
err
}
}
pods
=
append
(
pods
,
list
...
)
pods
=
append
(
pods
,
list
...
)
case
(
*
v1
.
Pod
)
:
case
(
*
v1
.
Pod
)
:
pod
,
err
:=
client
.
Core
()
.
Pods
(
value
.
Namespace
)
.
Get
(
value
.
Name
,
metav1
.
GetOptions
{})
pod
,
err
:=
kcs
.
Core
()
.
Pods
(
value
.
Namespace
)
.
Get
(
value
.
Name
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
false
,
err
}
}
pods
=
append
(
pods
,
*
pod
)
pods
=
append
(
pods
,
*
pod
)
case
(
*
extensions
.
Deployment
)
:
case
(
*
extensions
.
Deployment
)
:
currentDeployment
,
err
:=
client
.
Extensions
()
.
Deployments
(
value
.
Namespace
)
.
Get
(
value
.
Name
,
metav1
.
GetOptions
{})
currentDeployment
,
err
:=
kcs
.
Extensions
()
.
Deployments
(
value
.
Namespace
)
.
Get
(
value
.
Name
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
false
,
err
}
}
// Find RS associated with deployment
// Find RS associated with deployment
newReplicaSet
,
err
:=
deploymentutil
.
GetNewReplicaSet
(
currentDeployment
,
client
)
newReplicaSet
,
err
:=
deploymentutil
.
GetNewReplicaSet
(
currentDeployment
,
kcs
.
ExtensionsV1beta1
()
)
if
err
!=
nil
||
newReplicaSet
==
nil
{
if
err
!=
nil
||
newReplicaSet
==
nil
{
return
false
,
err
return
false
,
err
}
}
...
@@ -91,31 +88,37 @@ func (c *Client) waitForResources(timeout time.Duration, created Result) error {
...
@@ -91,31 +88,37 @@ func (c *Client) waitForResources(timeout time.Duration, created Result) error {
}
}
deployments
=
append
(
deployments
,
newDeployment
)
deployments
=
append
(
deployments
,
newDeployment
)
case
(
*
extensions
.
DaemonSet
)
:
case
(
*
extensions
.
DaemonSet
)
:
list
,
err
:=
getPods
(
client
,
value
.
Namespace
,
value
.
Spec
.
Selector
.
MatchLabels
)
list
,
err
:=
getPods
(
kcs
,
value
.
Namespace
,
value
.
Spec
.
Selector
.
MatchLabels
)
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
false
,
err
}
}
pods
=
append
(
pods
,
list
...
)
pods
=
append
(
pods
,
list
...
)
case
(
*
apps
.
StatefulSet
)
:
case
(
*
appsv1beta1
.
StatefulSet
)
:
list
,
err
:=
getPods
(
client
,
value
.
Namespace
,
value
.
Spec
.
Selector
.
MatchLabels
)
list
,
err
:=
getPods
(
kcs
,
value
.
Namespace
,
value
.
Spec
.
Selector
.
MatchLabels
)
if
err
!=
nil
{
return
false
,
err
}
pods
=
append
(
pods
,
list
...
)
case
(
*
appsv1beta2
.
StatefulSet
)
:
list
,
err
:=
getPods
(
kcs
,
value
.
Namespace
,
value
.
Spec
.
Selector
.
MatchLabels
)
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
false
,
err
}
}
pods
=
append
(
pods
,
list
...
)
pods
=
append
(
pods
,
list
...
)
case
(
*
extensions
.
ReplicaSet
)
:
case
(
*
extensions
.
ReplicaSet
)
:
list
,
err
:=
getPods
(
client
,
value
.
Namespace
,
value
.
Spec
.
Selector
.
MatchLabels
)
list
,
err
:=
getPods
(
kcs
,
value
.
Namespace
,
value
.
Spec
.
Selector
.
MatchLabels
)
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
false
,
err
}
}
pods
=
append
(
pods
,
list
...
)
pods
=
append
(
pods
,
list
...
)
case
(
*
v1
.
PersistentVolumeClaim
)
:
case
(
*
v1
.
PersistentVolumeClaim
)
:
claim
,
err
:=
client
.
Core
()
.
PersistentVolumeClaims
(
value
.
Namespace
)
.
Get
(
value
.
Name
,
metav1
.
GetOptions
{})
claim
,
err
:=
kcs
.
Core
()
.
PersistentVolumeClaims
(
value
.
Namespace
)
.
Get
(
value
.
Name
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
false
,
err
}
}
pvc
=
append
(
pvc
,
*
claim
)
pvc
=
append
(
pvc
,
*
claim
)
case
(
*
v1
.
Service
)
:
case
(
*
v1
.
Service
)
:
svc
,
err
:=
client
.
Core
()
.
Services
(
value
.
Namespace
)
.
Get
(
value
.
Name
,
metav1
.
GetOptions
{})
svc
,
err
:=
kcs
.
Core
()
.
Services
(
value
.
Namespace
)
.
Get
(
value
.
Name
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
false
,
err
}
}
...
@@ -178,20 +181,10 @@ func (c *Client) deploymentsReady(deployments []deployment) bool {
...
@@ -178,20 +181,10 @@ func (c *Client) deploymentsReady(deployments []deployment) bool {
return
true
return
true
}
}
func
getPods
(
client
clientset
.
Interface
,
namespace
string
,
selector
map
[
string
]
string
)
([]
v1
.
Pod
,
error
)
{
func
getPods
(
client
kubernetes
.
Interface
,
namespace
string
,
selector
map
[
string
]
string
)
([]
v1
.
Pod
,
error
)
{
list
,
err
:=
client
.
Core
()
.
Pods
(
namespace
)
.
List
(
metav1
.
ListOptions
{
list
,
err
:=
client
.
Core
()
.
Pods
(
namespace
)
.
List
(
metav1
.
ListOptions
{
FieldSelector
:
fields
.
Everything
()
.
String
(),
FieldSelector
:
fields
.
Everything
()
.
String
(),
LabelSelector
:
labels
.
Set
(
selector
)
.
AsSelector
()
.
String
(),
LabelSelector
:
labels
.
Set
(
selector
)
.
AsSelector
()
.
String
(),
})
})
return
list
.
Items
,
err
return
list
.
Items
,
err
}
}
func
versionedClientsetForDeployment
(
internalClient
internalclientset
.
Interface
)
clientset
.
Interface
{
if
internalClient
==
nil
{
return
&
clientset
.
Clientset
{}
}
return
&
clientset
.
Clientset
{
CoreV1Client
:
core
.
New
(
internalClient
.
Core
()
.
RESTClient
()),
ExtensionsV1beta1Client
:
extensionsclient
.
New
(
internalClient
.
Extensions
()
.
RESTClient
()),
}
}
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