refactor: move ListOptions references to metav1

This commit is contained in:
Clayton Coleman 2017-01-21 22:36:02 -05:00
parent 245b592fac
commit 469df12038
No known key found for this signature in database
GPG Key ID: 3D16906B4F1C5CB3
364 changed files with 1519 additions and 1554 deletions

View File

@ -53,7 +53,7 @@ func main() {
if err != nil { if err != nil {
glog.Fatalf("Failed to make client: %v", err) glog.Fatalf("Failed to make client: %v", err)
} }
namespace := api.NamespaceSystem namespace := metav1.NamespaceSystem
envNamespace := os.Getenv("NAMESPACE") envNamespace := os.Getenv("NAMESPACE")
if envNamespace != "" { if envNamespace != "" {
if _, err := client.Core().Namespaces().Get(envNamespace, meta_v1.GetOptions{}); err != nil { if _, err := client.Core().Namespaces().Get(envNamespace, meta_v1.GetOptions{}); err != nil {

View File

@ -19,9 +19,8 @@ go_library(
"//cmd/kube-aggregator/pkg/client/clientset_generated/internalclientset:go_default_library", "//cmd/kube-aggregator/pkg/client/clientset_generated/internalclientset:go_default_library",
"//cmd/kube-aggregator/pkg/client/informers/internalinterfaces:go_default_library", "//cmd/kube-aggregator/pkg/client/informers/internalinterfaces:go_default_library",
"//cmd/kube-aggregator/pkg/client/listers/apiregistration/internalversion:go_default_library", "//cmd/kube-aggregator/pkg/client/listers/apiregistration/internalversion:go_default_library",
"//pkg/api:go_default_library",
"//pkg/api/v1:go_default_library",
"//pkg/client/cache:go_default_library", "//pkg/client/cache:go_default_library",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/runtime", "//vendor:k8s.io/apimachinery/pkg/runtime",
"//vendor:k8s.io/apimachinery/pkg/watch", "//vendor:k8s.io/apimachinery/pkg/watch",
], ],

View File

@ -19,8 +19,8 @@ go_library(
"//cmd/kube-aggregator/pkg/client/clientset_generated/clientset:go_default_library", "//cmd/kube-aggregator/pkg/client/clientset_generated/clientset:go_default_library",
"//cmd/kube-aggregator/pkg/client/informers/internalinterfaces:go_default_library", "//cmd/kube-aggregator/pkg/client/informers/internalinterfaces:go_default_library",
"//cmd/kube-aggregator/pkg/client/listers/apiregistration/v1alpha1:go_default_library", "//cmd/kube-aggregator/pkg/client/listers/apiregistration/v1alpha1:go_default_library",
"//pkg/api/v1:go_default_library",
"//pkg/client/cache:go_default_library", "//pkg/client/cache:go_default_library",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/runtime", "//vendor:k8s.io/apimachinery/pkg/runtime",
"//vendor:k8s.io/apimachinery/pkg/watch", "//vendor:k8s.io/apimachinery/pkg/watch",
], ],

View File

@ -27,13 +27,13 @@ import (
"github.com/renstrom/dedent" "github.com/renstrom/dedent"
"github.com/spf13/cobra" "github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm" kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
kubemaster "k8s.io/kubernetes/cmd/kubeadm/app/master" kubemaster "k8s.io/kubernetes/cmd/kubeadm/app/master"
"k8s.io/kubernetes/cmd/kubeadm/app/phases/kubeconfig" "k8s.io/kubernetes/cmd/kubeadm/app/phases/kubeconfig"
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util" kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/kubectl" "k8s.io/kubernetes/pkg/kubectl"
) )
@ -167,11 +167,11 @@ func RunListTokens(out io.Writer, errW io.Writer, cmd *cobra.Command) error {
api.SecretTypeField: string(api.SecretTypeBootstrapToken), api.SecretTypeField: string(api.SecretTypeBootstrapToken),
}, },
) )
listOptions := v1.ListOptions{ listOptions := metav1.ListOptions{
FieldSelector: tokenSelector.String(), FieldSelector: tokenSelector.String(),
} }
results, err := client.Secrets(api.NamespaceSystem).List(listOptions) results, err := client.Secrets(metav1.NamespaceSystem).List(listOptions)
if err != nil { if err != nil {
return fmt.Errorf("failed to list bootstrap tokens [%v]", err) return fmt.Errorf("failed to list bootstrap tokens [%v]", err)
} }
@ -222,7 +222,7 @@ func RunDeleteToken(out io.Writer, cmd *cobra.Command, tokenId string) error {
} }
tokenSecretName := fmt.Sprintf("%s%s", kubeadmutil.BootstrapTokenSecretPrefix, tokenId) tokenSecretName := fmt.Sprintf("%s%s", kubeadmutil.BootstrapTokenSecretPrefix, tokenId)
if err := client.Secrets(api.NamespaceSystem).Delete(tokenSecretName, nil); err != nil { if err := client.Secrets(metav1.NamespaceSystem).Delete(tokenSecretName, nil); err != nil {
return fmt.Errorf("failed to delete bootstrap token [%v]", err) return fmt.Errorf("failed to delete bootstrap token [%v]", err)
} }
fmt.Fprintf(out, "[token] bootstrap token deleted: %s\n", tokenId) fmt.Fprintf(out, "[token] bootstrap token deleted: %s\n", tokenId)

View File

@ -21,10 +21,10 @@ import (
"net" "net"
"path" "path"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm" kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
"k8s.io/kubernetes/cmd/kubeadm/app/images" "k8s.io/kubernetes/cmd/kubeadm/app/images"
"k8s.io/kubernetes/cmd/kubeadm/app/phases/kubeconfig" "k8s.io/kubernetes/cmd/kubeadm/app/phases/kubeconfig"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/resource" "k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" "k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
@ -268,7 +268,7 @@ func CreateEssentialAddons(cfg *kubeadmapi.MasterConfiguration, client *clientse
SetMasterTaintTolerations(&kubeProxyDaemonSet.Spec.Template.ObjectMeta) SetMasterTaintTolerations(&kubeProxyDaemonSet.Spec.Template.ObjectMeta)
SetNodeAffinity(&kubeProxyDaemonSet.Spec.Template.ObjectMeta, NativeArchitectureNodeAffinity()) SetNodeAffinity(&kubeProxyDaemonSet.Spec.Template.ObjectMeta, NativeArchitectureNodeAffinity())
if _, err := client.Extensions().DaemonSets(api.NamespaceSystem).Create(kubeProxyDaemonSet); err != nil { if _, err := client.Extensions().DaemonSets(metav1.NamespaceSystem).Create(kubeProxyDaemonSet); err != nil {
return fmt.Errorf("failed creating essential kube-proxy addon [%v]", err) return fmt.Errorf("failed creating essential kube-proxy addon [%v]", err)
} }
@ -279,10 +279,10 @@ func CreateEssentialAddons(cfg *kubeadmapi.MasterConfiguration, client *clientse
SetNodeAffinity(&kubeDNSDeployment.Spec.Template.ObjectMeta, NativeArchitectureNodeAffinity()) SetNodeAffinity(&kubeDNSDeployment.Spec.Template.ObjectMeta, NativeArchitectureNodeAffinity())
kubeDNSServiceAccount := &v1.ServiceAccount{} kubeDNSServiceAccount := &v1.ServiceAccount{}
kubeDNSServiceAccount.ObjectMeta.Name = KubeDNS kubeDNSServiceAccount.ObjectMeta.Name = KubeDNS
if _, err := client.ServiceAccounts(api.NamespaceSystem).Create(kubeDNSServiceAccount); err != nil { if _, err := client.ServiceAccounts(metav1.NamespaceSystem).Create(kubeDNSServiceAccount); err != nil {
return fmt.Errorf("failed creating kube-dns service account [%v]", err) return fmt.Errorf("failed creating kube-dns service account [%v]", err)
} }
if _, err := client.Extensions().Deployments(api.NamespaceSystem).Create(kubeDNSDeployment); err != nil { if _, err := client.Extensions().Deployments(metav1.NamespaceSystem).Create(kubeDNSDeployment); err != nil {
return fmt.Errorf("failed creating essential kube-dns addon [%v]", err) return fmt.Errorf("failed creating essential kube-dns addon [%v]", err)
} }
@ -293,7 +293,7 @@ func CreateEssentialAddons(cfg *kubeadmapi.MasterConfiguration, client *clientse
kubeDNSService := NewService(KubeDNS, *kubeDNSServiceSpec) kubeDNSService := NewService(KubeDNS, *kubeDNSServiceSpec)
kubeDNSService.ObjectMeta.Labels["kubernetes.io/name"] = "KubeDNS" kubeDNSService.ObjectMeta.Labels["kubernetes.io/name"] = "KubeDNS"
if _, err := client.Services(api.NamespaceSystem).Create(kubeDNSService); err != nil { if _, err := client.Services(metav1.NamespaceSystem).Create(kubeDNSService); err != nil {
return fmt.Errorf("failed creating essential kube-dns addon [%v]", err) return fmt.Errorf("failed creating essential kube-dns addon [%v]", err)
} }

View File

@ -28,7 +28,6 @@ import (
"k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api" clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
"k8s.io/kubernetes/cmd/kubeadm/app/images" "k8s.io/kubernetes/cmd/kubeadm/app/images"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/api/v1"
extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1" extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" "k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
@ -73,7 +72,7 @@ func CreateClientAndWaitForAPI(file string) (*clientset.Clientset, error) {
fmt.Println("[apiclient] Waiting for at least one node to register and become ready") fmt.Println("[apiclient] Waiting for at least one node to register and become ready")
start := time.Now() start := time.Now()
wait.PollInfinite(apiCallRetryInterval, func() (bool, error) { wait.PollInfinite(apiCallRetryInterval, func() (bool, error) {
nodeList, err := client.Nodes().List(v1.ListOptions{}) nodeList, err := client.Nodes().List(metav1.ListOptions{})
if err != nil { if err != nil {
fmt.Println("[apiclient] Temporarily unable to list nodes (will retry)") fmt.Println("[apiclient] Temporarily unable to list nodes (will retry)")
return false, nil return false, nil
@ -107,7 +106,7 @@ func WaitForAPI(client *clientset.Clientset) {
start := time.Now() start := time.Now()
wait.PollInfinite(apiCallRetryInterval, func() (bool, error) { wait.PollInfinite(apiCallRetryInterval, func() (bool, error) {
// TODO: use /healthz API instead of this // TODO: use /healthz API instead of this
cs, err := client.ComponentStatuses().List(v1.ListOptions{}) cs, err := client.ComponentStatuses().List(metav1.ListOptions{})
if err != nil { if err != nil {
if apierrs.IsForbidden(err) { if apierrs.IsForbidden(err) {
fmt.Println("[apiclient] Waiting for API server authorization") fmt.Println("[apiclient] Waiting for API server authorization")
@ -176,7 +175,7 @@ func NewDeployment(deploymentName string, replicas int32, podSpec v1.PodSpec) *e
// It's safe to do this for alpha, as we don't have HA and there is no way we can get // It's safe to do this for alpha, as we don't have HA and there is no way we can get
// more then one node here (TODO(phase1+) use os.Hostname) // more then one node here (TODO(phase1+) use os.Hostname)
func findMyself(client *clientset.Clientset) (*v1.Node, error) { func findMyself(client *clientset.Clientset) (*v1.Node, error) {
nodeList, err := client.Nodes().List(v1.ListOptions{}) nodeList, err := client.Nodes().List(metav1.ListOptions{})
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to list nodes [%v]", err) return nil, fmt.Errorf("unable to list nodes [%v]", err)
} }
@ -274,7 +273,7 @@ func createDummyDeployment(client *clientset.Clientset) {
wait.PollInfinite(apiCallRetryInterval, func() (bool, error) { wait.PollInfinite(apiCallRetryInterval, func() (bool, error) {
// TODO: we should check the error, as some cases may be fatal // TODO: we should check the error, as some cases may be fatal
if _, err := client.Extensions().Deployments(api.NamespaceSystem).Create(dummyDeployment); err != nil { if _, err := client.Extensions().Deployments(metav1.NamespaceSystem).Create(dummyDeployment); err != nil {
fmt.Printf("[apiclient] Failed to create test deployment [%v] (will retry)\n", err) fmt.Printf("[apiclient] Failed to create test deployment [%v] (will retry)\n", err)
return false, nil return false, nil
} }
@ -282,7 +281,7 @@ func createDummyDeployment(client *clientset.Clientset) {
}) })
wait.PollInfinite(apiCallRetryInterval, func() (bool, error) { wait.PollInfinite(apiCallRetryInterval, func() (bool, error) {
d, err := client.Extensions().Deployments(api.NamespaceSystem).Get("dummy", metav1.GetOptions{}) d, err := client.Extensions().Deployments(metav1.NamespaceSystem).Get("dummy", metav1.GetOptions{})
if err != nil { if err != nil {
fmt.Printf("[apiclient] Failed to get test deployment [%v] (will retry)\n", err) fmt.Printf("[apiclient] Failed to get test deployment [%v] (will retry)\n", err)
return false, nil return false, nil
@ -296,7 +295,7 @@ func createDummyDeployment(client *clientset.Clientset) {
fmt.Println("[apiclient] Test deployment succeeded") fmt.Println("[apiclient] Test deployment succeeded")
// TODO: In the future, make sure the ReplicaSet and Pod are garbage collected // TODO: In the future, make sure the ReplicaSet and Pod are garbage collected
if err := client.Extensions().Deployments(api.NamespaceSystem).Delete("dummy", &v1.DeleteOptions{}); err != nil { if err := client.Extensions().Deployments(metav1.NamespaceSystem).Delete("dummy", &v1.DeleteOptions{}); err != nil {
fmt.Printf("[apiclient] Failed to delete test deployment [%v] (will ignore)\n", err) fmt.Printf("[apiclient] Failed to delete test deployment [%v] (will ignore)\n", err)
} }
} }

View File

@ -30,7 +30,6 @@ import (
kubeadmapiext "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1alpha1" kubeadmapiext "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1alpha1"
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants" kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util" kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/api/v1"
extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1" extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" "k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
@ -136,10 +135,10 @@ func CreateDiscoveryDeploymentAndSecret(cfg *kubeadmapi.MasterConfiguration, cli
kd := newKubeDiscovery(cfg, caCert) kd := newKubeDiscovery(cfg, caCert)
if _, err := client.Extensions().Deployments(api.NamespaceSystem).Create(kd.Deployment); err != nil { if _, err := client.Extensions().Deployments(metav1.NamespaceSystem).Create(kd.Deployment); err != nil {
return fmt.Errorf("failed to create %q deployment [%v]", kubeDiscoveryName, err) return fmt.Errorf("failed to create %q deployment [%v]", kubeDiscoveryName, err)
} }
if _, err := client.Secrets(api.NamespaceSystem).Create(kd.Secret); err != nil { if _, err := client.Secrets(metav1.NamespaceSystem).Create(kd.Secret); err != nil {
return fmt.Errorf("failed to create %q secret [%v]", kubeDiscoverySecretName, err) return fmt.Errorf("failed to create %q secret [%v]", kubeDiscoverySecretName, err)
} }
@ -147,7 +146,7 @@ func CreateDiscoveryDeploymentAndSecret(cfg *kubeadmapi.MasterConfiguration, cli
start := time.Now() start := time.Now()
wait.PollInfinite(apiCallRetryInterval, func() (bool, error) { wait.PollInfinite(apiCallRetryInterval, func() (bool, error) {
d, err := client.Extensions().Deployments(api.NamespaceSystem).Get(kubeDiscoveryName, metav1.GetOptions{}) d, err := client.Extensions().Deployments(metav1.NamespaceSystem).Get(kubeDiscoveryName, metav1.GetOptions{})
if err != nil { if err != nil {
return false, nil return false, nil
} }

View File

@ -27,7 +27,6 @@ import (
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm" kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
"k8s.io/kubernetes/cmd/kubeadm/app/images" "k8s.io/kubernetes/cmd/kubeadm/app/images"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/api/v1"
ext "k8s.io/kubernetes/pkg/apis/extensions/v1beta1" ext "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" "k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
@ -69,7 +68,7 @@ func launchSelfHostedAPIServer(cfg *kubeadmapi.MasterConfiguration, client *clie
start := time.Now() start := time.Now()
apiServer := getAPIServerDS(cfg, volumes, volumeMounts) apiServer := getAPIServerDS(cfg, volumes, volumeMounts)
if _, err := client.Extensions().DaemonSets(api.NamespaceSystem).Create(&apiServer); err != nil { if _, err := client.Extensions().DaemonSets(metav1.NamespaceSystem).Create(&apiServer); err != nil {
return fmt.Errorf("failed to create self-hosted %q daemon set [%v]", kubeAPIServer, err) return fmt.Errorf("failed to create self-hosted %q daemon set [%v]", kubeAPIServer, err)
} }
@ -77,7 +76,7 @@ func launchSelfHostedAPIServer(cfg *kubeadmapi.MasterConfiguration, client *clie
// TODO: This might be pointless, checking the pods is probably enough. // TODO: This might be pointless, checking the pods is probably enough.
// It does however get us a count of how many there should be which may be useful // It does however get us a count of how many there should be which may be useful
// with HA. // with HA.
apiDS, err := client.DaemonSets(api.NamespaceSystem).Get("self-hosted-"+kubeAPIServer, apiDS, err := client.DaemonSets(metav1.NamespaceSystem).Get("self-hosted-"+kubeAPIServer,
metav1.GetOptions{}) metav1.GetOptions{})
if err != nil { if err != nil {
fmt.Println("[self-hosted] error getting apiserver DaemonSet:", err) fmt.Println("[self-hosted] error getting apiserver DaemonSet:", err)
@ -114,7 +113,7 @@ func launchSelfHostedControllerManager(cfg *kubeadmapi.MasterConfiguration, clie
start := time.Now() start := time.Now()
ctrlMgr := getControllerManagerDeployment(cfg, volumes, volumeMounts) ctrlMgr := getControllerManagerDeployment(cfg, volumes, volumeMounts)
if _, err := client.Extensions().Deployments(api.NamespaceSystem).Create(&ctrlMgr); err != nil { if _, err := client.Extensions().Deployments(metav1.NamespaceSystem).Create(&ctrlMgr); err != nil {
return fmt.Errorf("failed to create self-hosted %q deployment [%v]", kubeControllerManager, err) return fmt.Errorf("failed to create self-hosted %q deployment [%v]", kubeControllerManager, err)
} }
@ -133,7 +132,7 @@ func launchSelfHostedControllerManager(cfg *kubeadmapi.MasterConfiguration, clie
func launchSelfHostedScheduler(cfg *kubeadmapi.MasterConfiguration, client *clientset.Clientset, volumes []v1.Volume, volumeMounts []v1.VolumeMount) error { func launchSelfHostedScheduler(cfg *kubeadmapi.MasterConfiguration, client *clientset.Clientset, volumes []v1.Volume, volumeMounts []v1.VolumeMount) error {
start := time.Now() start := time.Now()
scheduler := getSchedulerDeployment(cfg) scheduler := getSchedulerDeployment(cfg)
if _, err := client.Extensions().Deployments(api.NamespaceSystem).Create(&scheduler); err != nil { if _, err := client.Extensions().Deployments(metav1.NamespaceSystem).Create(&scheduler); err != nil {
return fmt.Errorf("failed to create self-hosted %q deployment [%v]", kubeScheduler, err) return fmt.Errorf("failed to create self-hosted %q deployment [%v]", kubeScheduler, err)
} }
@ -153,8 +152,8 @@ func launchSelfHostedScheduler(cfg *kubeadmapi.MasterConfiguration, client *clie
func waitForPodsWithLabel(client *clientset.Clientset, appLabel string, mustBeRunning bool) { func waitForPodsWithLabel(client *clientset.Clientset, appLabel string, mustBeRunning bool) {
wait.PollInfinite(apiCallRetryInterval, func() (bool, error) { wait.PollInfinite(apiCallRetryInterval, func() (bool, error) {
// TODO: Do we need a stronger label link than this? // TODO: Do we need a stronger label link than this?
listOpts := v1.ListOptions{LabelSelector: fmt.Sprintf("k8s-app=%s", appLabel)} listOpts := metav1.ListOptions{LabelSelector: fmt.Sprintf("k8s-app=%s", appLabel)}
apiPods, err := client.Pods(api.NamespaceSystem).List(listOpts) apiPods, err := client.Pods(metav1.NamespaceSystem).List(listOpts)
if err != nil { if err != nil {
fmt.Printf("[self-hosted] error getting %s pods [%v]\n", appLabel, err) fmt.Printf("[self-hosted] error getting %s pods [%v]\n", appLabel, err)
return false, nil return false, nil

View File

@ -21,7 +21,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/cmd/kubeadm/app/master" "k8s.io/kubernetes/cmd/kubeadm/app/master"
"k8s.io/kubernetes/pkg/api"
rbac "k8s.io/kubernetes/pkg/apis/rbac/v1beta1" rbac "k8s.io/kubernetes/pkg/apis/rbac/v1beta1"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" "k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
) )
@ -66,7 +65,7 @@ func CreateKubeDNSRBACClusterRole(clientset *clientset.Clientset) error {
subject := rbac.Subject{ subject := rbac.Subject{
Kind: "ServiceAccount", Kind: "ServiceAccount",
Name: master.KubeDNS, Name: master.KubeDNS,
Namespace: api.NamespaceSystem, Namespace: metav1.NamespaceSystem,
} }
clusterRoleBinding := rbac.ClusterRoleBinding{ clusterRoleBinding := rbac.ClusterRoleBinding{

View File

@ -136,11 +136,11 @@ func UpdateOrCreateToken(client *clientset.Clientset, d *kubeadmapi.TokenDiscove
secretName := fmt.Sprintf("%s%s", BootstrapTokenSecretPrefix, d.ID) secretName := fmt.Sprintf("%s%s", BootstrapTokenSecretPrefix, d.ID)
var lastErr error var lastErr error
for i := 0; i < tokenCreateRetries; i++ { for i := 0; i < tokenCreateRetries; i++ {
secret, err := client.Secrets(api.NamespaceSystem).Get(secretName, metav1.GetOptions{}) secret, err := client.Secrets(metav1.NamespaceSystem).Get(secretName, metav1.GetOptions{})
if err == nil { if err == nil {
// Secret with this ID already exists, update it: // Secret with this ID already exists, update it:
secret.Data = encodeTokenSecretData(d, tokenDuration) secret.Data = encodeTokenSecretData(d, tokenDuration)
if _, err := client.Secrets(api.NamespaceSystem).Update(secret); err == nil { if _, err := client.Secrets(metav1.NamespaceSystem).Update(secret); err == nil {
return nil return nil
} else { } else {
lastErr = err lastErr = err
@ -157,7 +157,7 @@ func UpdateOrCreateToken(client *clientset.Clientset, d *kubeadmapi.TokenDiscove
Type: api.SecretTypeBootstrapToken, Type: api.SecretTypeBootstrapToken,
Data: encodeTokenSecretData(d, tokenDuration), Data: encodeTokenSecretData(d, tokenDuration),
} }
if _, err := client.Secrets(api.NamespaceSystem).Create(secret); err == nil { if _, err := client.Secrets(metav1.NamespaceSystem).Create(secret); err == nil {
return nil return nil
} else { } else {
lastErr = err lastErr = err

View File

@ -16,7 +16,6 @@ go_library(
], ],
tags = ["automanaged"], tags = ["automanaged"],
deps = [ deps = [
"//pkg/api:go_default_library",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1", "//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/runtime", "//vendor:k8s.io/apimachinery/pkg/runtime",
"//vendor:k8s.io/apimachinery/pkg/runtime/schema", "//vendor:k8s.io/apimachinery/pkg/runtime/schema",

View File

@ -26,6 +26,8 @@ import (
"testing" "testing"
"github.com/golang/glog" "github.com/golang/glog"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
@ -48,7 +50,7 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
switch t := obj.(type) { switch t := obj.(type) {
case *api.ReplicationController: case *api.ReplicationController:
if t.Namespace == "" { if t.Namespace == "" {
t.Namespace = api.NamespaceDefault t.Namespace = metav1.NamespaceDefault
} }
errors = validation.ValidateReplicationController(t) errors = validation.ValidateReplicationController(t)
case *api.ReplicationControllerList: case *api.ReplicationControllerList:
@ -57,7 +59,7 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
} }
case *api.Service: case *api.Service:
if t.Namespace == "" { if t.Namespace == "" {
t.Namespace = api.NamespaceDefault t.Namespace = metav1.NamespaceDefault
} }
errors = validation.ValidateService(t) errors = validation.ValidateService(t)
case *api.ServiceList: case *api.ServiceList:
@ -66,7 +68,7 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
} }
case *api.Pod: case *api.Pod:
if t.Namespace == "" { if t.Namespace == "" {
t.Namespace = api.NamespaceDefault t.Namespace = metav1.NamespaceDefault
} }
errors = validation.ValidatePod(t) errors = validation.ValidatePod(t)
case *api.PodList: case *api.PodList:
@ -77,44 +79,44 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
errors = validation.ValidatePersistentVolume(t) errors = validation.ValidatePersistentVolume(t)
case *api.PersistentVolumeClaim: case *api.PersistentVolumeClaim:
if t.Namespace == "" { if t.Namespace == "" {
t.Namespace = api.NamespaceDefault t.Namespace = metav1.NamespaceDefault
} }
errors = validation.ValidatePersistentVolumeClaim(t) errors = validation.ValidatePersistentVolumeClaim(t)
case *api.PodTemplate: case *api.PodTemplate:
if t.Namespace == "" { if t.Namespace == "" {
t.Namespace = api.NamespaceDefault t.Namespace = metav1.NamespaceDefault
} }
errors = validation.ValidatePodTemplate(t) errors = validation.ValidatePodTemplate(t)
case *api.Endpoints: case *api.Endpoints:
if t.Namespace == "" { if t.Namespace == "" {
t.Namespace = api.NamespaceDefault t.Namespace = metav1.NamespaceDefault
} }
errors = validation.ValidateEndpoints(t) errors = validation.ValidateEndpoints(t)
case *api.Namespace: case *api.Namespace:
errors = validation.ValidateNamespace(t) errors = validation.ValidateNamespace(t)
case *api.Secret: case *api.Secret:
if t.Namespace == "" { if t.Namespace == "" {
t.Namespace = api.NamespaceDefault t.Namespace = metav1.NamespaceDefault
} }
errors = validation.ValidateSecret(t) errors = validation.ValidateSecret(t)
case *api.LimitRange: case *api.LimitRange:
if t.Namespace == "" { if t.Namespace == "" {
t.Namespace = api.NamespaceDefault t.Namespace = metav1.NamespaceDefault
} }
errors = validation.ValidateLimitRange(t) errors = validation.ValidateLimitRange(t)
case *api.ResourceQuota: case *api.ResourceQuota:
if t.Namespace == "" { if t.Namespace == "" {
t.Namespace = api.NamespaceDefault t.Namespace = metav1.NamespaceDefault
} }
errors = validation.ValidateResourceQuota(t) errors = validation.ValidateResourceQuota(t)
case *extensions.Deployment: case *extensions.Deployment:
if t.Namespace == "" { if t.Namespace == "" {
t.Namespace = api.NamespaceDefault t.Namespace = metav1.NamespaceDefault
} }
errors = expvalidation.ValidateDeployment(t) errors = expvalidation.ValidateDeployment(t)
case *batch.Job: case *batch.Job:
if t.Namespace == "" { if t.Namespace == "" {
t.Namespace = api.NamespaceDefault t.Namespace = metav1.NamespaceDefault
} }
// Job needs generateSelector called before validation, and job.Validate does this. // Job needs generateSelector called before validation, and job.Validate does this.
// See: https://github.com/kubernetes/kubernetes/issues/20951#issuecomment-187787040 // See: https://github.com/kubernetes/kubernetes/issues/20951#issuecomment-187787040
@ -122,17 +124,17 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
errors = job.Strategy.Validate(nil, t) errors = job.Strategy.Validate(nil, t)
case *extensions.Ingress: case *extensions.Ingress:
if t.Namespace == "" { if t.Namespace == "" {
t.Namespace = api.NamespaceDefault t.Namespace = metav1.NamespaceDefault
} }
errors = expvalidation.ValidateIngress(t) errors = expvalidation.ValidateIngress(t)
case *extensions.DaemonSet: case *extensions.DaemonSet:
if t.Namespace == "" { if t.Namespace == "" {
t.Namespace = api.NamespaceDefault t.Namespace = metav1.NamespaceDefault
} }
errors = expvalidation.ValidateDaemonSet(t) errors = expvalidation.ValidateDaemonSet(t)
case *apps.StatefulSet: case *apps.StatefulSet:
if t.Namespace == "" { if t.Namespace == "" {
t.Namespace = api.NamespaceDefault t.Namespace = metav1.NamespaceDefault
} }
errors = appsvalidation.ValidateStatefulSet(t) errors = appsvalidation.ValidateStatefulSet(t)
default: default:

View File

@ -11,15 +11,12 @@ go_library(
name = "go_default_library", name = "go_default_library",
srcs = [ srcs = [
"conversion.go", "conversion.go",
"defaults.go",
"register.go", "register.go",
], ],
tags = ["automanaged"], tags = ["automanaged"],
deps = [ deps = [
"//pkg/api:go_default_library", "//pkg/api:go_default_library",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1", "//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/fields",
"//vendor:k8s.io/apimachinery/pkg/labels",
"//vendor:k8s.io/apimachinery/pkg/runtime", "//vendor:k8s.io/apimachinery/pkg/runtime",
"//vendor:k8s.io/apimachinery/pkg/runtime/schema", "//vendor:k8s.io/apimachinery/pkg/runtime/schema",
"//vendor:k8s.io/apimachinery/pkg/runtime/serializer", "//vendor:k8s.io/apimachinery/pkg/runtime/serializer",

View File

@ -142,7 +142,7 @@ func getRegionNameForNode(node api.Node) (string, error) {
// Find the names of all zones and the region in which we have nodes in this cluster. // Find the names of all zones and the region in which we have nodes in this cluster.
func getZoneNames(client *clientset.Clientset) (zones []string, region string, err error) { func getZoneNames(client *clientset.Clientset) (zones []string, region string, err error) {
zoneNames := sets.NewString() zoneNames := sets.NewString()
nodes, err := client.Core().Nodes().List(api.ListOptions{}) nodes, err := client.Core().Nodes().List(metav1.ListOptions{})
if err != nil { if err != nil {
glog.Errorf("Failed to list nodes while getting zone names: %v", err) glog.Errorf("Failed to list nodes while getting zone names: %v", err)
return nil, "", err return nil, "", err

View File

@ -21,6 +21,7 @@ import (
"time" "time"
"github.com/golang/glog" "github.com/golang/glog"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
@ -29,7 +30,6 @@ import (
federationv1beta1 "k8s.io/kubernetes/federation/apis/federation/v1beta1" federationv1beta1 "k8s.io/kubernetes/federation/apis/federation/v1beta1"
clustercache "k8s.io/kubernetes/federation/client/cache" clustercache "k8s.io/kubernetes/federation/client/cache"
federationclientset "k8s.io/kubernetes/federation/client/clientset_generated/federation_clientset" federationclientset "k8s.io/kubernetes/federation/client/clientset_generated/federation_clientset"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/controller" "k8s.io/kubernetes/pkg/controller"
) )
@ -64,10 +64,10 @@ func NewclusterController(federationClient federationclientset.Interface, cluste
} }
cc.clusterStore.Store, cc.clusterController = cache.NewInformer( cc.clusterStore.Store, cc.clusterController = cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return cc.federationClient.Federation().Clusters().List(options) return cc.federationClient.Federation().Clusters().List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return cc.federationClient.Federation().Clusters().Watch(options) return cc.federationClient.Federation().Clusters().Watch(options)
}, },
}, },
@ -134,7 +134,7 @@ func (cc *ClusterController) GetClusterStatus(cluster *federationv1beta1.Cluster
// UpdateClusterStatus checks cluster status and get the metrics from cluster's restapi // UpdateClusterStatus checks cluster status and get the metrics from cluster's restapi
func (cc *ClusterController) UpdateClusterStatus() error { func (cc *ClusterController) UpdateClusterStatus() error {
clusters, err := cc.federationClient.Federation().Clusters().List(v1.ListOptions{}) clusters, err := cc.federationClient.Federation().Clusters().List(metav1.ListOptions{})
if err != nil { if err != nil {
return err return err
} }

View File

@ -24,6 +24,7 @@ go_library(
"//pkg/client/record:go_default_library", "//pkg/client/record:go_default_library",
"//pkg/controller:go_default_library", "//pkg/controller:go_default_library",
"//vendor:github.com/golang/glog", "//vendor:github.com/golang/glog",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/runtime", "//vendor:k8s.io/apimachinery/pkg/runtime",
"//vendor:k8s.io/apimachinery/pkg/types", "//vendor:k8s.io/apimachinery/pkg/types",
"//vendor:k8s.io/apimachinery/pkg/watch", "//vendor:k8s.io/apimachinery/pkg/watch",

View File

@ -19,6 +19,7 @@ package configmap
import ( import (
"time" "time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkgruntime "k8s.io/apimachinery/pkg/runtime" pkgruntime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
@ -98,11 +99,11 @@ func NewConfigMapController(client federationclientset.Interface) *ConfigMapCont
// Start informer on federated API servers on configmaps that should be federated. // Start informer on federated API servers on configmaps that should be federated.
configmapcontroller.configmapInformerStore, configmapcontroller.configmapInformerController = cache.NewInformer( configmapcontroller.configmapInformerStore, configmapcontroller.configmapInformerController = cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options apiv1.ListOptions) (pkgruntime.Object, error) { ListFunc: func(options metav1.ListOptions) (pkgruntime.Object, error) {
return client.Core().ConfigMaps(apiv1.NamespaceAll).List(options) return client.Core().ConfigMaps(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options apiv1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return client.Core().ConfigMaps(apiv1.NamespaceAll).Watch(options) return client.Core().ConfigMaps(metav1.NamespaceAll).Watch(options)
}, },
}, },
&apiv1.ConfigMap{}, &apiv1.ConfigMap{},
@ -115,11 +116,11 @@ func NewConfigMapController(client federationclientset.Interface) *ConfigMapCont
func(cluster *federationapi.Cluster, targetClient kubeclientset.Interface) (cache.Store, cache.Controller) { func(cluster *federationapi.Cluster, targetClient kubeclientset.Interface) (cache.Store, cache.Controller) {
return cache.NewInformer( return cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options apiv1.ListOptions) (pkgruntime.Object, error) { ListFunc: func(options metav1.ListOptions) (pkgruntime.Object, error) {
return targetClient.Core().ConfigMaps(apiv1.NamespaceAll).List(options) return targetClient.Core().ConfigMaps(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options apiv1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return targetClient.Core().ConfigMaps(apiv1.NamespaceAll).Watch(options) return targetClient.Core().ConfigMaps(metav1.NamespaceAll).Watch(options)
}, },
}, },
&apiv1.ConfigMap{}, &apiv1.ConfigMap{},

View File

@ -27,6 +27,7 @@ go_library(
"//pkg/controller:go_default_library", "//pkg/controller:go_default_library",
"//vendor:github.com/golang/glog", "//vendor:github.com/golang/glog",
"//vendor:k8s.io/apimachinery/pkg/api/errors", "//vendor:k8s.io/apimachinery/pkg/api/errors",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/runtime", "//vendor:k8s.io/apimachinery/pkg/runtime",
"//vendor:k8s.io/apimachinery/pkg/types", "//vendor:k8s.io/apimachinery/pkg/types",
"//vendor:k8s.io/apimachinery/pkg/watch", "//vendor:k8s.io/apimachinery/pkg/watch",

View File

@ -22,6 +22,7 @@ import (
"time" "time"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkgruntime "k8s.io/apimachinery/pkg/runtime" pkgruntime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
@ -105,11 +106,11 @@ func NewDaemonSetController(client federationclientset.Interface) *DaemonSetCont
// Start informer in federated API servers on daemonsets that should be federated. // Start informer in federated API servers on daemonsets that should be federated.
daemonsetcontroller.daemonsetInformerStore, daemonsetcontroller.daemonsetInformerController = cache.NewInformer( daemonsetcontroller.daemonsetInformerStore, daemonsetcontroller.daemonsetInformerController = cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options apiv1.ListOptions) (pkgruntime.Object, error) { ListFunc: func(options metav1.ListOptions) (pkgruntime.Object, error) {
return client.Extensions().DaemonSets(apiv1.NamespaceAll).List(options) return client.Extensions().DaemonSets(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options apiv1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return client.Extensions().DaemonSets(apiv1.NamespaceAll).Watch(options) return client.Extensions().DaemonSets(metav1.NamespaceAll).Watch(options)
}, },
}, },
&extensionsv1.DaemonSet{}, &extensionsv1.DaemonSet{},
@ -122,11 +123,11 @@ func NewDaemonSetController(client federationclientset.Interface) *DaemonSetCont
func(cluster *federationapi.Cluster, targetClient kubeclientset.Interface) (cache.Store, cache.Controller) { func(cluster *federationapi.Cluster, targetClient kubeclientset.Interface) (cache.Store, cache.Controller) {
return cache.NewInformer( return cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options apiv1.ListOptions) (pkgruntime.Object, error) { ListFunc: func(options metav1.ListOptions) (pkgruntime.Object, error) {
return targetClient.Extensions().DaemonSets(apiv1.NamespaceAll).List(options) return targetClient.Extensions().DaemonSets(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options apiv1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return targetClient.Extensions().DaemonSets(apiv1.NamespaceAll).Watch(options) return targetClient.Extensions().DaemonSets(metav1.NamespaceAll).Watch(options)
}, },
}, },
&extensionsv1.DaemonSet{}, &extensionsv1.DaemonSet{},

View File

@ -31,6 +31,7 @@ go_library(
"//pkg/util/workqueue:go_default_library", "//pkg/util/workqueue:go_default_library",
"//vendor:github.com/golang/glog", "//vendor:github.com/golang/glog",
"//vendor:k8s.io/apimachinery/pkg/api/errors", "//vendor:k8s.io/apimachinery/pkg/api/errors",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/runtime", "//vendor:k8s.io/apimachinery/pkg/runtime",
"//vendor:k8s.io/apimachinery/pkg/util/wait", "//vendor:k8s.io/apimachinery/pkg/util/wait",
"//vendor:k8s.io/apimachinery/pkg/watch", "//vendor:k8s.io/apimachinery/pkg/watch",

View File

@ -26,6 +26,7 @@ import (
"github.com/golang/glog" "github.com/golang/glog"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
@ -122,11 +123,11 @@ func NewDeploymentController(federationClient fedclientset.Interface) *Deploymen
deploymentFedInformerFactory := func(cluster *fedv1.Cluster, clientset kubeclientset.Interface) (cache.Store, cache.Controller) { deploymentFedInformerFactory := func(cluster *fedv1.Cluster, clientset kubeclientset.Interface) (cache.Store, cache.Controller) {
return cache.NewInformer( return cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options apiv1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return clientset.Extensions().Deployments(apiv1.NamespaceAll).List(options) return clientset.Extensions().Deployments(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options apiv1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return clientset.Extensions().Deployments(apiv1.NamespaceAll).Watch(options) return clientset.Extensions().Deployments(metav1.NamespaceAll).Watch(options)
}, },
}, },
&extensionsv1.Deployment{}, &extensionsv1.Deployment{},
@ -149,11 +150,11 @@ func NewDeploymentController(federationClient fedclientset.Interface) *Deploymen
podFedInformerFactory := func(cluster *fedv1.Cluster, clientset kubeclientset.Interface) (cache.Store, cache.Controller) { podFedInformerFactory := func(cluster *fedv1.Cluster, clientset kubeclientset.Interface) (cache.Store, cache.Controller) {
return cache.NewInformer( return cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options apiv1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return clientset.Core().Pods(apiv1.NamespaceAll).List(options) return clientset.Core().Pods(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options apiv1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return clientset.Core().Pods(apiv1.NamespaceAll).Watch(options) return clientset.Core().Pods(metav1.NamespaceAll).Watch(options)
}, },
}, },
&apiv1.Pod{}, &apiv1.Pod{},
@ -169,11 +170,11 @@ func NewDeploymentController(federationClient fedclientset.Interface) *Deploymen
fdc.deploymentStore, fdc.deploymentController = cache.NewInformer( fdc.deploymentStore, fdc.deploymentController = cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options apiv1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return fdc.fedClient.Extensions().Deployments(apiv1.NamespaceAll).List(options) return fdc.fedClient.Extensions().Deployments(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options apiv1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return fdc.fedClient.Extensions().Deployments(apiv1.NamespaceAll).Watch(options) return fdc.fedClient.Extensions().Deployments(metav1.NamespaceAll).Watch(options)
}, },
}, },
&extensionsv1.Deployment{}, &extensionsv1.Deployment{},

View File

@ -177,7 +177,7 @@ func newDeploymentWithReplicas(name string, replicas int32) *extensionsv1.Deploy
return &extensionsv1.Deployment{ return &extensionsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: name, Name: name,
Namespace: apiv1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
SelfLink: "/api/v1/namespaces/default/deployments/name", SelfLink: "/api/v1/namespaces/default/deployments/name",
}, },
Spec: extensionsv1.DeploymentSpec{ Spec: extensionsv1.DeploymentSpec{

View File

@ -140,11 +140,11 @@ func NewIngressController(client federationclientset.Interface) *IngressControll
// Start informer in federated API servers on ingresses that should be federated. // Start informer in federated API servers on ingresses that should be federated.
ic.ingressInformerStore, ic.ingressInformerController = cache.NewInformer( ic.ingressInformerStore, ic.ingressInformerController = cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (pkgruntime.Object, error) { ListFunc: func(options metav1.ListOptions) (pkgruntime.Object, error) {
return client.Extensions().Ingresses(api.NamespaceAll).List(options) return client.Extensions().Ingresses(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return client.Extensions().Ingresses(api.NamespaceAll).Watch(options) return client.Extensions().Ingresses(metav1.NamespaceAll).Watch(options)
}, },
}, },
&extensionsv1beta1.Ingress{}, &extensionsv1beta1.Ingress{},
@ -161,11 +161,11 @@ func NewIngressController(client federationclientset.Interface) *IngressControll
func(cluster *federationapi.Cluster, targetClient kubeclientset.Interface) (cache.Store, cache.Controller) { func(cluster *federationapi.Cluster, targetClient kubeclientset.Interface) (cache.Store, cache.Controller) {
return cache.NewInformer( return cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (pkgruntime.Object, error) { ListFunc: func(options metav1.ListOptions) (pkgruntime.Object, error) {
return targetClient.Extensions().Ingresses(api.NamespaceAll).List(options) return targetClient.Extensions().Ingresses(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return targetClient.Extensions().Ingresses(api.NamespaceAll).Watch(options) return targetClient.Extensions().Ingresses(metav1.NamespaceAll).Watch(options)
}, },
}, },
&extensionsv1beta1.Ingress{}, &extensionsv1beta1.Ingress{},
@ -194,13 +194,13 @@ func NewIngressController(client federationclientset.Interface) *IngressControll
glog.V(4).Infof("Returning new informer for cluster %q", cluster.Name) glog.V(4).Infof("Returning new informer for cluster %q", cluster.Name)
return cache.NewInformer( return cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (pkgruntime.Object, error) { ListFunc: func(options metav1.ListOptions) (pkgruntime.Object, error) {
if targetClient == nil { if targetClient == nil {
glog.Errorf("Internal error: targetClient is nil") glog.Errorf("Internal error: targetClient is nil")
} }
return targetClient.Core().ConfigMaps(uidConfigMapNamespace).List(options) // we only want to list one by name - unfortunately Kubernetes don't have a selector for that. return targetClient.Core().ConfigMaps(uidConfigMapNamespace).List(options) // we only want to list one by name - unfortunately Kubernetes don't have a selector for that.
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
if targetClient == nil { if targetClient == nil {
glog.Errorf("Internal error: targetClient is nil") glog.Errorf("Internal error: targetClient is nil")
} }

View File

@ -26,6 +26,7 @@ go_library(
"//pkg/controller:go_default_library", "//pkg/controller:go_default_library",
"//vendor:github.com/golang/glog", "//vendor:github.com/golang/glog",
"//vendor:k8s.io/apimachinery/pkg/api/errors", "//vendor:k8s.io/apimachinery/pkg/api/errors",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/runtime", "//vendor:k8s.io/apimachinery/pkg/runtime",
"//vendor:k8s.io/apimachinery/pkg/watch", "//vendor:k8s.io/apimachinery/pkg/watch",
"//vendor:k8s.io/client-go/pkg/util/flowcontrol", "//vendor:k8s.io/client-go/pkg/util/flowcontrol",

View File

@ -21,6 +21,7 @@ import (
"time" "time"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/pkg/util/flowcontrol" "k8s.io/client-go/pkg/util/flowcontrol"
@ -102,10 +103,10 @@ func NewNamespaceController(client federationclientset.Interface) *NamespaceCont
// Start informer in federated API servers on namespaces that should be federated. // Start informer in federated API servers on namespaces that should be federated.
nc.namespaceInformerStore, nc.namespaceInformerController = cache.NewInformer( nc.namespaceInformerStore, nc.namespaceInformerController = cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options apiv1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return client.Core().Namespaces().List(options) return client.Core().Namespaces().List(options)
}, },
WatchFunc: func(options apiv1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return client.Core().Namespaces().Watch(options) return client.Core().Namespaces().Watch(options)
}, },
}, },
@ -119,10 +120,10 @@ func NewNamespaceController(client federationclientset.Interface) *NamespaceCont
func(cluster *federationapi.Cluster, targetClient kubeclientset.Interface) (cache.Store, cache.Controller) { func(cluster *federationapi.Cluster, targetClient kubeclientset.Interface) (cache.Store, cache.Controller) {
return cache.NewInformer( return cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options apiv1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return targetClient.Core().Namespaces().List(options) return targetClient.Core().Namespaces().List(options)
}, },
WatchFunc: func(options apiv1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return targetClient.Core().Namespaces().Watch(options) return targetClient.Core().Namespaces().Watch(options)
}, },
}, },
@ -491,31 +492,31 @@ func (nc *NamespaceController) removeKubernetesFinalizer(namespace *apiv1.Namesp
// Right now there are just 7 types of objects: Deployments, DaemonSets, ReplicaSet, Secret, Ingress, Events and Service. // Right now there are just 7 types of objects: Deployments, DaemonSets, ReplicaSet, Secret, Ingress, Events and Service.
// Temporarily these items are simply deleted one by one to squeeze this code into 1.4. // Temporarily these items are simply deleted one by one to squeeze this code into 1.4.
// TODO: Make it generic (like in the regular namespace controller) and parallel. // TODO: Make it generic (like in the regular namespace controller) and parallel.
err := nc.federatedApiClient.Core().Services(namespace.Name).DeleteCollection(&apiv1.DeleteOptions{}, apiv1.ListOptions{}) err := nc.federatedApiClient.Core().Services(namespace.Name).DeleteCollection(&apiv1.DeleteOptions{}, metav1.ListOptions{})
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to delete service list: %v", err) return nil, fmt.Errorf("failed to delete service list: %v", err)
} }
err = nc.federatedApiClient.Extensions().ReplicaSets(namespace.Name).DeleteCollection(&apiv1.DeleteOptions{}, apiv1.ListOptions{}) err = nc.federatedApiClient.Extensions().ReplicaSets(namespace.Name).DeleteCollection(&apiv1.DeleteOptions{}, metav1.ListOptions{})
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to delete replicaset list from namespace: %v", err) return nil, fmt.Errorf("failed to delete replicaset list from namespace: %v", err)
} }
err = nc.federatedApiClient.Core().Secrets(namespace.Name).DeleteCollection(&apiv1.DeleteOptions{}, apiv1.ListOptions{}) err = nc.federatedApiClient.Core().Secrets(namespace.Name).DeleteCollection(&apiv1.DeleteOptions{}, metav1.ListOptions{})
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to delete secret list from namespace: %v", err) return nil, fmt.Errorf("failed to delete secret list from namespace: %v", err)
} }
err = nc.federatedApiClient.Extensions().Ingresses(namespace.Name).DeleteCollection(&apiv1.DeleteOptions{}, apiv1.ListOptions{}) err = nc.federatedApiClient.Extensions().Ingresses(namespace.Name).DeleteCollection(&apiv1.DeleteOptions{}, metav1.ListOptions{})
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to delete ingresses list from namespace: %v", err) return nil, fmt.Errorf("failed to delete ingresses list from namespace: %v", err)
} }
err = nc.federatedApiClient.Extensions().DaemonSets(namespace.Name).DeleteCollection(&apiv1.DeleteOptions{}, apiv1.ListOptions{}) err = nc.federatedApiClient.Extensions().DaemonSets(namespace.Name).DeleteCollection(&apiv1.DeleteOptions{}, metav1.ListOptions{})
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to delete daemonsets list from namespace: %v", err) return nil, fmt.Errorf("failed to delete daemonsets list from namespace: %v", err)
} }
err = nc.federatedApiClient.Extensions().Deployments(namespace.Name).DeleteCollection(&apiv1.DeleteOptions{}, apiv1.ListOptions{}) err = nc.federatedApiClient.Extensions().Deployments(namespace.Name).DeleteCollection(&apiv1.DeleteOptions{}, metav1.ListOptions{})
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to delete deployments list from namespace: %v", err) return nil, fmt.Errorf("failed to delete deployments list from namespace: %v", err)
} }
err = nc.federatedApiClient.Core().Events(namespace.Name).DeleteCollection(&apiv1.DeleteOptions{}, apiv1.ListOptions{}) err = nc.federatedApiClient.Core().Events(namespace.Name).DeleteCollection(&apiv1.DeleteOptions{}, metav1.ListOptions{})
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to delete events list from namespace: %v", err) return nil, fmt.Errorf("failed to delete events list from namespace: %v", err)
} }

View File

@ -32,6 +32,7 @@ go_library(
"//pkg/util/workqueue:go_default_library", "//pkg/util/workqueue:go_default_library",
"//vendor:github.com/golang/glog", "//vendor:github.com/golang/glog",
"//vendor:k8s.io/apimachinery/pkg/api/errors", "//vendor:k8s.io/apimachinery/pkg/api/errors",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/runtime", "//vendor:k8s.io/apimachinery/pkg/runtime",
"//vendor:k8s.io/apimachinery/pkg/util/wait", "//vendor:k8s.io/apimachinery/pkg/util/wait",
"//vendor:k8s.io/apimachinery/pkg/watch", "//vendor:k8s.io/apimachinery/pkg/watch",

View File

@ -26,6 +26,7 @@ import (
"github.com/golang/glog" "github.com/golang/glog"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
@ -125,11 +126,11 @@ func NewReplicaSetController(federationClient fedclientset.Interface) *ReplicaSe
replicaSetFedInformerFactory := func(cluster *fedv1.Cluster, clientset kubeclientset.Interface) (cache.Store, cache.Controller) { replicaSetFedInformerFactory := func(cluster *fedv1.Cluster, clientset kubeclientset.Interface) (cache.Store, cache.Controller) {
return cache.NewInformer( return cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options apiv1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return clientset.Extensions().ReplicaSets(apiv1.NamespaceAll).List(options) return clientset.Extensions().ReplicaSets(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options apiv1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return clientset.Extensions().ReplicaSets(apiv1.NamespaceAll).Watch(options) return clientset.Extensions().ReplicaSets(metav1.NamespaceAll).Watch(options)
}, },
}, },
&extensionsv1.ReplicaSet{}, &extensionsv1.ReplicaSet{},
@ -152,11 +153,11 @@ func NewReplicaSetController(federationClient fedclientset.Interface) *ReplicaSe
podFedInformerFactory := func(cluster *fedv1.Cluster, clientset kubeclientset.Interface) (cache.Store, cache.Controller) { podFedInformerFactory := func(cluster *fedv1.Cluster, clientset kubeclientset.Interface) (cache.Store, cache.Controller) {
return cache.NewInformer( return cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options apiv1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return clientset.Core().Pods(apiv1.NamespaceAll).List(options) return clientset.Core().Pods(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options apiv1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return clientset.Core().Pods(apiv1.NamespaceAll).Watch(options) return clientset.Core().Pods(metav1.NamespaceAll).Watch(options)
}, },
}, },
&apiv1.Pod{}, &apiv1.Pod{},
@ -172,11 +173,11 @@ func NewReplicaSetController(federationClient fedclientset.Interface) *ReplicaSe
frsc.replicaSetStore.Indexer, frsc.replicaSetController = cache.NewIndexerInformer( frsc.replicaSetStore.Indexer, frsc.replicaSetController = cache.NewIndexerInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options apiv1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return frsc.fedClient.Extensions().ReplicaSets(apiv1.NamespaceAll).List(options) return frsc.fedClient.Extensions().ReplicaSets(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options apiv1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return frsc.fedClient.Extensions().ReplicaSets(apiv1.NamespaceAll).Watch(options) return frsc.fedClient.Extensions().ReplicaSets(metav1.NamespaceAll).Watch(options)
}, },
}, },
&extensionsv1.ReplicaSet{}, &extensionsv1.ReplicaSet{},

View File

@ -119,30 +119,30 @@ func TestReplicaSetController(t *testing.T) {
go replicaSetController.Run(1, stopChan) go replicaSetController.Run(1, stopChan)
rs := newReplicaSetWithReplicas("rs", 9) rs := newReplicaSetWithReplicas("rs", 9)
rs, _ = fedclientset.Extensions().ReplicaSets(apiv1.NamespaceDefault).Create(rs) rs, _ = fedclientset.Extensions().ReplicaSets(metav1.NamespaceDefault).Create(rs)
fedrswatch.Add(rs) fedrswatch.Add(rs)
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
rs1, _ := kube1clientset.Extensions().ReplicaSets(apiv1.NamespaceDefault).Get(rs.Name, metav1.GetOptions{}) rs1, _ := kube1clientset.Extensions().ReplicaSets(metav1.NamespaceDefault).Get(rs.Name, metav1.GetOptions{})
kube1rswatch.Add(rs1) kube1rswatch.Add(rs1)
rs1.Status.Replicas = *rs1.Spec.Replicas rs1.Status.Replicas = *rs1.Spec.Replicas
rs1.Status.FullyLabeledReplicas = *rs1.Spec.Replicas rs1.Status.FullyLabeledReplicas = *rs1.Spec.Replicas
rs1.Status.ReadyReplicas = *rs1.Spec.Replicas rs1.Status.ReadyReplicas = *rs1.Spec.Replicas
rs1.Status.AvailableReplicas = *rs1.Spec.Replicas rs1.Status.AvailableReplicas = *rs1.Spec.Replicas
rs1, _ = kube1clientset.Extensions().ReplicaSets(apiv1.NamespaceDefault).UpdateStatus(rs1) rs1, _ = kube1clientset.Extensions().ReplicaSets(metav1.NamespaceDefault).UpdateStatus(rs1)
kube1rswatch.Modify(rs1) kube1rswatch.Modify(rs1)
rs2, _ := kube2clientset.Extensions().ReplicaSets(apiv1.NamespaceDefault).Get(rs.Name, metav1.GetOptions{}) rs2, _ := kube2clientset.Extensions().ReplicaSets(metav1.NamespaceDefault).Get(rs.Name, metav1.GetOptions{})
kube2rswatch.Add(rs2) kube2rswatch.Add(rs2)
rs2.Status.Replicas = *rs2.Spec.Replicas rs2.Status.Replicas = *rs2.Spec.Replicas
rs2.Status.FullyLabeledReplicas = *rs2.Spec.Replicas rs2.Status.FullyLabeledReplicas = *rs2.Spec.Replicas
rs2.Status.ReadyReplicas = *rs2.Spec.Replicas rs2.Status.ReadyReplicas = *rs2.Spec.Replicas
rs2.Status.AvailableReplicas = *rs2.Spec.Replicas rs2.Status.AvailableReplicas = *rs2.Spec.Replicas
rs2, _ = kube2clientset.Extensions().ReplicaSets(apiv1.NamespaceDefault).UpdateStatus(rs2) rs2, _ = kube2clientset.Extensions().ReplicaSets(metav1.NamespaceDefault).UpdateStatus(rs2)
kube2rswatch.Modify(rs2) kube2rswatch.Modify(rs2)
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
rs, _ = fedclientset.Extensions().ReplicaSets(apiv1.NamespaceDefault).Get(rs.Name, metav1.GetOptions{}) rs, _ = fedclientset.Extensions().ReplicaSets(metav1.NamespaceDefault).Get(rs.Name, metav1.GetOptions{})
assert.Equal(t, *rs.Spec.Replicas, *rs1.Spec.Replicas+*rs2.Spec.Replicas) assert.Equal(t, *rs.Spec.Replicas, *rs1.Spec.Replicas+*rs2.Spec.Replicas)
assert.Equal(t, rs.Status.Replicas, rs1.Status.Replicas+rs2.Status.Replicas) assert.Equal(t, rs.Status.Replicas, rs1.Status.Replicas+rs2.Status.Replicas)
assert.Equal(t, rs.Status.FullyLabeledReplicas, rs1.Status.FullyLabeledReplicas+rs2.Status.FullyLabeledReplicas) assert.Equal(t, rs.Status.FullyLabeledReplicas, rs1.Status.FullyLabeledReplicas+rs2.Status.FullyLabeledReplicas)
@ -151,28 +151,28 @@ func TestReplicaSetController(t *testing.T) {
var replicas int32 = 20 var replicas int32 = 20
rs.Spec.Replicas = &replicas rs.Spec.Replicas = &replicas
rs, _ = fedclientset.Extensions().ReplicaSets(apiv1.NamespaceDefault).Update(rs) rs, _ = fedclientset.Extensions().ReplicaSets(metav1.NamespaceDefault).Update(rs)
fedrswatch.Modify(rs) fedrswatch.Modify(rs)
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
rs1, _ = kube1clientset.Extensions().ReplicaSets(apiv1.NamespaceDefault).Get(rs.Name, metav1.GetOptions{}) rs1, _ = kube1clientset.Extensions().ReplicaSets(metav1.NamespaceDefault).Get(rs.Name, metav1.GetOptions{})
rs1.Status.Replicas = *rs1.Spec.Replicas rs1.Status.Replicas = *rs1.Spec.Replicas
rs1.Status.FullyLabeledReplicas = *rs1.Spec.Replicas rs1.Status.FullyLabeledReplicas = *rs1.Spec.Replicas
rs1.Status.ReadyReplicas = *rs1.Spec.Replicas rs1.Status.ReadyReplicas = *rs1.Spec.Replicas
rs1.Status.AvailableReplicas = *rs1.Spec.Replicas rs1.Status.AvailableReplicas = *rs1.Spec.Replicas
rs1, _ = kube1clientset.Extensions().ReplicaSets(apiv1.NamespaceDefault).UpdateStatus(rs1) rs1, _ = kube1clientset.Extensions().ReplicaSets(metav1.NamespaceDefault).UpdateStatus(rs1)
kube1rswatch.Modify(rs1) kube1rswatch.Modify(rs1)
rs2, _ = kube2clientset.Extensions().ReplicaSets(apiv1.NamespaceDefault).Get(rs.Name, metav1.GetOptions{}) rs2, _ = kube2clientset.Extensions().ReplicaSets(metav1.NamespaceDefault).Get(rs.Name, metav1.GetOptions{})
rs2.Status.Replicas = *rs2.Spec.Replicas rs2.Status.Replicas = *rs2.Spec.Replicas
rs2.Status.FullyLabeledReplicas = *rs2.Spec.Replicas rs2.Status.FullyLabeledReplicas = *rs2.Spec.Replicas
rs2.Status.ReadyReplicas = *rs2.Spec.Replicas rs2.Status.ReadyReplicas = *rs2.Spec.Replicas
rs2.Status.AvailableReplicas = *rs2.Spec.Replicas rs2.Status.AvailableReplicas = *rs2.Spec.Replicas
rs2, _ = kube2clientset.Extensions().ReplicaSets(apiv1.NamespaceDefault).UpdateStatus(rs2) rs2, _ = kube2clientset.Extensions().ReplicaSets(metav1.NamespaceDefault).UpdateStatus(rs2)
kube2rswatch.Modify(rs2) kube2rswatch.Modify(rs2)
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
rs, _ = fedclientset.Extensions().ReplicaSets(apiv1.NamespaceDefault).Get(rs.Name, metav1.GetOptions{}) rs, _ = fedclientset.Extensions().ReplicaSets(metav1.NamespaceDefault).Get(rs.Name, metav1.GetOptions{})
assert.Equal(t, *rs.Spec.Replicas, *rs1.Spec.Replicas+*rs2.Spec.Replicas) assert.Equal(t, *rs.Spec.Replicas, *rs1.Spec.Replicas+*rs2.Spec.Replicas)
assert.Equal(t, rs.Status.Replicas, rs1.Status.Replicas+rs2.Status.Replicas) assert.Equal(t, rs.Status.Replicas, rs1.Status.Replicas+rs2.Status.Replicas)
assert.Equal(t, rs.Status.FullyLabeledReplicas, rs1.Status.FullyLabeledReplicas+rs2.Status.FullyLabeledReplicas) assert.Equal(t, rs.Status.FullyLabeledReplicas, rs1.Status.FullyLabeledReplicas+rs2.Status.FullyLabeledReplicas)
@ -184,7 +184,7 @@ func newReplicaSetWithReplicas(name string, replicas int32) *extensionsv1.Replic
return &extensionsv1.ReplicaSet{ return &extensionsv1.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: name, Name: name,
Namespace: apiv1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
SelfLink: "/api/v1/namespaces/default/replicasets/name", SelfLink: "/api/v1/namespaces/default/replicasets/name",
}, },
Spec: extensionsv1.ReplicaSetSpec{ Spec: extensionsv1.ReplicaSetSpec{

View File

@ -26,6 +26,7 @@ go_library(
"//pkg/controller:go_default_library", "//pkg/controller:go_default_library",
"//vendor:github.com/golang/glog", "//vendor:github.com/golang/glog",
"//vendor:k8s.io/apimachinery/pkg/api/errors", "//vendor:k8s.io/apimachinery/pkg/api/errors",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/runtime", "//vendor:k8s.io/apimachinery/pkg/runtime",
"//vendor:k8s.io/apimachinery/pkg/types", "//vendor:k8s.io/apimachinery/pkg/types",
"//vendor:k8s.io/apimachinery/pkg/watch", "//vendor:k8s.io/apimachinery/pkg/watch",

View File

@ -21,6 +21,7 @@ import (
"time" "time"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkgruntime "k8s.io/apimachinery/pkg/runtime" pkgruntime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
@ -103,11 +104,11 @@ func NewSecretController(client federationclientset.Interface) *SecretController
// Start informer in federated API servers on secrets that should be federated. // Start informer in federated API servers on secrets that should be federated.
secretcontroller.secretInformerStore, secretcontroller.secretInformerController = cache.NewInformer( secretcontroller.secretInformerStore, secretcontroller.secretInformerController = cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options apiv1.ListOptions) (pkgruntime.Object, error) { ListFunc: func(options metav1.ListOptions) (pkgruntime.Object, error) {
return client.Core().Secrets(apiv1.NamespaceAll).List(options) return client.Core().Secrets(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options apiv1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return client.Core().Secrets(apiv1.NamespaceAll).Watch(options) return client.Core().Secrets(metav1.NamespaceAll).Watch(options)
}, },
}, },
&apiv1.Secret{}, &apiv1.Secret{},
@ -120,11 +121,11 @@ func NewSecretController(client federationclientset.Interface) *SecretController
func(cluster *federationapi.Cluster, targetClient kubeclientset.Interface) (cache.Store, cache.Controller) { func(cluster *federationapi.Cluster, targetClient kubeclientset.Interface) (cache.Store, cache.Controller) {
return cache.NewInformer( return cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options apiv1.ListOptions) (pkgruntime.Object, error) { ListFunc: func(options metav1.ListOptions) (pkgruntime.Object, error) {
return targetClient.Core().Secrets(apiv1.NamespaceAll).List(options) return targetClient.Core().Secrets(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options apiv1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return targetClient.Core().Secrets(apiv1.NamespaceAll).Watch(options) return targetClient.Core().Secrets(metav1.NamespaceAll).Watch(options)
}, },
}, },
&apiv1.Secret{}, &apiv1.Secret{},

View File

@ -19,6 +19,7 @@ package service
import ( import (
"sync" "sync"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkgruntime "k8s.io/apimachinery/pkg/runtime" pkgruntime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
@ -92,11 +93,11 @@ func (cc *clusterClientCache) startClusterLW(cluster *v1beta1.Cluster, clusterNa
} }
cachedClusterClient.endpointStore.Store, cachedClusterClient.endpointController = cache.NewInformer( cachedClusterClient.endpointStore.Store, cachedClusterClient.endpointController = cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (pkgruntime.Object, error) { ListFunc: func(options metav1.ListOptions) (pkgruntime.Object, error) {
return clientset.Core().Endpoints(v1.NamespaceAll).List(options) return clientset.Core().Endpoints(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return clientset.Core().Endpoints(v1.NamespaceAll).Watch(options) return clientset.Core().Endpoints(metav1.NamespaceAll).Watch(options)
}, },
}, },
&v1.Endpoints{}, &v1.Endpoints{},
@ -116,11 +117,11 @@ func (cc *clusterClientCache) startClusterLW(cluster *v1beta1.Cluster, clusterNa
cachedClusterClient.serviceStore.Indexer, cachedClusterClient.serviceController = cache.NewIndexerInformer( cachedClusterClient.serviceStore.Indexer, cachedClusterClient.serviceController = cache.NewIndexerInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (pkgruntime.Object, error) { ListFunc: func(options metav1.ListOptions) (pkgruntime.Object, error) {
return clientset.Core().Services(v1.NamespaceAll).List(options) return clientset.Core().Services(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return clientset.Core().Services(v1.NamespaceAll).Watch(options) return clientset.Core().Services(metav1.NamespaceAll).Watch(options)
}, },
}, },
&v1.Service{}, &v1.Service{},

View File

@ -181,11 +181,11 @@ func New(federationClient fedclientset.Interface, dns dnsprovider.Interface,
s.clusterDeliverer = util.NewDelayingDeliverer() s.clusterDeliverer = util.NewDelayingDeliverer()
s.serviceStore.Indexer, s.serviceController = cache.NewIndexerInformer( s.serviceStore.Indexer, s.serviceController = cache.NewIndexerInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (pkgruntime.Object, error) { ListFunc: func(options metav1.ListOptions) (pkgruntime.Object, error) {
return s.federationClient.Core().Services(v1.NamespaceAll).List(options) return s.federationClient.Core().Services(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return s.federationClient.Core().Services(v1.NamespaceAll).Watch(options) return s.federationClient.Core().Services(metav1.NamespaceAll).Watch(options)
}, },
}, },
&v1.Service{}, &v1.Service{},
@ -204,10 +204,10 @@ func New(federationClient fedclientset.Interface, dns dnsprovider.Interface,
) )
s.clusterStore.Store, s.clusterController = cache.NewInformer( s.clusterStore.Store, s.clusterController = cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (pkgruntime.Object, error) { ListFunc: func(options metav1.ListOptions) (pkgruntime.Object, error) {
return s.federationClient.Federation().Clusters().List(options) return s.federationClient.Federation().Clusters().List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return s.federationClient.Federation().Clusters().Watch(options) return s.federationClient.Federation().Clusters().Watch(options)
}, },
}, },
@ -249,11 +249,11 @@ func New(federationClient fedclientset.Interface, dns dnsprovider.Interface,
fedInformerFactory := func(cluster *v1beta1.Cluster, targetClient kubeclientset.Interface) (cache.Store, cache.Controller) { fedInformerFactory := func(cluster *v1beta1.Cluster, targetClient kubeclientset.Interface) (cache.Store, cache.Controller) {
return cache.NewInformer( return cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (pkgruntime.Object, error) { ListFunc: func(options metav1.ListOptions) (pkgruntime.Object, error) {
return targetClient.Core().Services(v1.NamespaceAll).List(options) return targetClient.Core().Services(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return targetClient.Core().Services(v1.NamespaceAll).Watch(options) return targetClient.Core().Services(metav1.NamespaceAll).Watch(options)
}, },
}, },
&v1.Service{}, &v1.Service{},

View File

@ -21,7 +21,6 @@ go_library(
"handlers.go", "handlers.go",
"meta.go", "meta.go",
"secret.go", "secret.go",
"versionize_listoptions.go",
], ],
tags = ["automanaged"], tags = ["automanaged"],
deps = [ deps = [

View File

@ -20,7 +20,6 @@ import (
"testing" "testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
apiv1 "k8s.io/kubernetes/pkg/api/v1"
extensionsv1 "k8s.io/kubernetes/pkg/apis/extensions/v1beta1" extensionsv1 "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
deputils "k8s.io/kubernetes/pkg/controller/deployment/util" deputils "k8s.io/kubernetes/pkg/controller/deployment/util"
@ -61,7 +60,7 @@ func newDeployment() *extensionsv1.Deployment {
return &extensionsv1.Deployment{ return &extensionsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "wrr", Name: "wrr",
Namespace: apiv1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
SelfLink: "/api/v1/namespaces/default/deployments/name123", SelfLink: "/api/v1/namespaces/default/deployments/name123",
}, },
Spec: extensionsv1.DeploymentSpec{ Spec: extensionsv1.DeploymentSpec{

View File

@ -22,6 +22,7 @@ import (
"sync" "sync"
"time" "time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkgruntime "k8s.io/apimachinery/pkg/runtime" pkgruntime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
restclient "k8s.io/client-go/rest" restclient "k8s.io/client-go/rest"
@ -160,10 +161,10 @@ func NewFederatedInformer(
federatedInformer.clusterInformer.store, federatedInformer.clusterInformer.controller = cache.NewInformer( federatedInformer.clusterInformer.store, federatedInformer.clusterInformer.controller = cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options apiv1.ListOptions) (pkgruntime.Object, error) { ListFunc: func(options metav1.ListOptions) (pkgruntime.Object, error) {
return federationClient.Federation().Clusters().List(options) return federationClient.Federation().Clusters().List(options)
}, },
WatchFunc: func(options apiv1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return federationClient.Federation().Clusters().Watch(options) return federationClient.Federation().Clusters().Watch(options)
}, },
}, },

View File

@ -81,11 +81,11 @@ func TestFederatedInformer(t *testing.T) {
targetInformerFactory := func(cluster *federationapi.Cluster, clientset kubeclientset.Interface) (cache.Store, cache.Controller) { targetInformerFactory := func(cluster *federationapi.Cluster, clientset kubeclientset.Interface) (cache.Store, cache.Controller) {
return cache.NewInformer( return cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options apiv1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return clientset.Core().Services(apiv1.NamespaceAll).List(options) return clientset.Core().Services(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options apiv1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return clientset.Core().Services(apiv1.NamespaceAll).Watch(options) return clientset.Core().Services(metav1.NamespaceAll).Watch(options)
}, },
}, },
&apiv1.Service{}, &apiv1.Service{},

View File

@ -1,40 +0,0 @@
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package util
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1"
)
// TODO: remove this when Reflector takes an interface rather than a particular ListOptions as input parameter.
func VersionizeV1ListOptions(in api.ListOptions) (out v1.ListOptions) {
if in.LabelSelector != nil {
out.LabelSelector = in.LabelSelector.String()
} else {
out.LabelSelector = ""
}
if in.FieldSelector != nil {
out.FieldSelector = in.FieldSelector.String()
} else {
out.FieldSelector = ""
}
out.Watch = in.Watch
out.ResourceVersion = in.ResourceVersion
out.TimeoutSeconds = in.TimeoutSeconds
return out
}

View File

@ -592,7 +592,7 @@ func createControllerManager(clientset *client.Clientset, namespace, name, svcNa
func waitForPods(clientset *client.Clientset, fedPods []string, namespace string) error { func waitForPods(clientset *client.Clientset, fedPods []string, namespace string) error {
err := wait.PollInfinite(podWaitInterval, func() (bool, error) { err := wait.PollInfinite(podWaitInterval, func() (bool, error) {
podCheck := len(fedPods) podCheck := len(fedPods)
podList, err := clientset.Core().Pods(namespace).List(api.ListOptions{}) podList, err := clientset.Core().Pods(namespace).List(metav1.ListOptions{})
if err != nil { if err != nil {
return false, nil return false, nil
} }

View File

@ -22,6 +22,7 @@ go_library(
"//pkg/genericapiserver/registry/generic:go_default_library", "//pkg/genericapiserver/registry/generic:go_default_library",
"//pkg/genericapiserver/registry/rest:go_default_library", "//pkg/genericapiserver/registry/rest:go_default_library",
"//pkg/storage:go_default_library", "//pkg/storage:go_default_library",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/internalversion",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1", "//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/fields", "//vendor:k8s.io/apimachinery/pkg/fields",
"//vendor:k8s.io/apimachinery/pkg/labels", "//vendor:k8s.io/apimachinery/pkg/labels",

View File

@ -42,7 +42,6 @@ go_library(
"//vendor:k8s.io/apimachinery/pkg/api/meta", "//vendor:k8s.io/apimachinery/pkg/api/meta",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1", "//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/conversion", "//vendor:k8s.io/apimachinery/pkg/conversion",
"//vendor:k8s.io/apimachinery/pkg/fields",
"//vendor:k8s.io/apimachinery/pkg/labels", "//vendor:k8s.io/apimachinery/pkg/labels",
"//vendor:k8s.io/apimachinery/pkg/runtime", "//vendor:k8s.io/apimachinery/pkg/runtime",
"//vendor:k8s.io/apimachinery/pkg/runtime/schema", "//vendor:k8s.io/apimachinery/pkg/runtime/schema",

View File

@ -20,6 +20,7 @@ import (
"fmt" "fmt"
"k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/validation" "k8s.io/apimachinery/pkg/util/validation"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
@ -34,7 +35,7 @@ func ValidateEvent(event *api.Event) field.ErrorList {
// Make sure event.Namespace and the involvedObject.Namespace agree // Make sure event.Namespace and the involvedObject.Namespace agree
if len(event.InvolvedObject.Namespace) == 0 { if len(event.InvolvedObject.Namespace) == 0 {
// event.Namespace must also be empty (or "default", for compatibility with old clients) // event.Namespace must also be empty (or "default", for compatibility with old clients)
if event.Namespace != api.NamespaceNone && event.Namespace != api.NamespaceDefault { if event.Namespace != metav1.NamespaceNone && event.Namespace != metav1.NamespaceDefault {
allErrs = append(allErrs, field.Invalid(field.NewPath("involvedObject", "namespace"), event.InvolvedObject.Namespace, "does not match event.namespace")) allErrs = append(allErrs, field.Invalid(field.NewPath("involvedObject", "namespace"), event.InvolvedObject.Namespace, "does not match event.namespace"))
} }
} else { } else {

View File

@ -56,7 +56,7 @@ func TestValidateEvent(t *testing.T) {
&api.Event{ &api.Event{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "test3", Name: "test3",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
InvolvedObject: api.ObjectReference{ InvolvedObject: api.ObjectReference{
APIVersion: "v1", APIVersion: "v1",
@ -68,7 +68,7 @@ func TestValidateEvent(t *testing.T) {
&api.Event{ &api.Event{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "test4", Name: "test4",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
InvolvedObject: api.ObjectReference{ InvolvedObject: api.ObjectReference{
APIVersion: "v1", APIVersion: "v1",
@ -80,12 +80,12 @@ func TestValidateEvent(t *testing.T) {
&api.Event{ &api.Event{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "test5", Name: "test5",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
InvolvedObject: api.ObjectReference{ InvolvedObject: api.ObjectReference{
APIVersion: "extensions/v1beta1", APIVersion: "extensions/v1beta1",
Kind: "NoKind", Kind: "NoKind",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
}, },
true, true,
@ -93,7 +93,7 @@ func TestValidateEvent(t *testing.T) {
&api.Event{ &api.Event{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "test6", Name: "test6",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
InvolvedObject: api.ObjectReference{ InvolvedObject: api.ObjectReference{
APIVersion: "extensions/v1beta1", APIVersion: "extensions/v1beta1",
@ -106,12 +106,12 @@ func TestValidateEvent(t *testing.T) {
&api.Event{ &api.Event{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "test7", Name: "test7",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
InvolvedObject: api.ObjectReference{ InvolvedObject: api.ObjectReference{
APIVersion: "extensions/v1beta1", APIVersion: "extensions/v1beta1",
Kind: "Job", Kind: "Job",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
}, },
true, true,
@ -119,7 +119,7 @@ func TestValidateEvent(t *testing.T) {
&api.Event{ &api.Event{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "test8", Name: "test8",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
InvolvedObject: api.ObjectReference{ InvolvedObject: api.ObjectReference{
APIVersion: "other/v1beta1", APIVersion: "other/v1beta1",
@ -145,7 +145,7 @@ func TestValidateEvent(t *testing.T) {
&api.Event{ &api.Event{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "test10", Name: "test10",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
InvolvedObject: api.ObjectReference{ InvolvedObject: api.ObjectReference{
APIVersion: "extensions", APIVersion: "extensions",

View File

@ -5243,7 +5243,7 @@ func TestValidateReplicationControllerStatusUpdate(t *testing.T) {
successCases := []rcUpdateTest{ successCases := []rcUpdateTest{
{ {
old: api.ReplicationController{ old: api.ReplicationController{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Selector: validSelector, Selector: validSelector,
Template: &validPodTemplate.Template, Template: &validPodTemplate.Template,
@ -5253,7 +5253,7 @@ func TestValidateReplicationControllerStatusUpdate(t *testing.T) {
}, },
}, },
update: api.ReplicationController{ update: api.ReplicationController{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Replicas: 3, Replicas: 3,
Selector: validSelector, Selector: validSelector,
@ -5275,7 +5275,7 @@ func TestValidateReplicationControllerStatusUpdate(t *testing.T) {
errorCases := map[string]rcUpdateTest{ errorCases := map[string]rcUpdateTest{
"negative replicas": { "negative replicas": {
old: api.ReplicationController{ old: api.ReplicationController{
ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Selector: validSelector, Selector: validSelector,
Template: &validPodTemplate.Template, Template: &validPodTemplate.Template,
@ -5285,7 +5285,7 @@ func TestValidateReplicationControllerStatusUpdate(t *testing.T) {
}, },
}, },
update: api.ReplicationController{ update: api.ReplicationController{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Replicas: 2, Replicas: 2,
Selector: validSelector, Selector: validSelector,
@ -5351,14 +5351,14 @@ func TestValidateReplicationControllerUpdate(t *testing.T) {
successCases := []rcUpdateTest{ successCases := []rcUpdateTest{
{ {
old: api.ReplicationController{ old: api.ReplicationController{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Selector: validSelector, Selector: validSelector,
Template: &validPodTemplate.Template, Template: &validPodTemplate.Template,
}, },
}, },
update: api.ReplicationController{ update: api.ReplicationController{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Replicas: 3, Replicas: 3,
Selector: validSelector, Selector: validSelector,
@ -5368,14 +5368,14 @@ func TestValidateReplicationControllerUpdate(t *testing.T) {
}, },
{ {
old: api.ReplicationController{ old: api.ReplicationController{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Selector: validSelector, Selector: validSelector,
Template: &validPodTemplate.Template, Template: &validPodTemplate.Template,
}, },
}, },
update: api.ReplicationController{ update: api.ReplicationController{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Replicas: 1, Replicas: 1,
Selector: validSelector, Selector: validSelector,
@ -5394,14 +5394,14 @@ func TestValidateReplicationControllerUpdate(t *testing.T) {
errorCases := map[string]rcUpdateTest{ errorCases := map[string]rcUpdateTest{
"more than one read/write": { "more than one read/write": {
old: api.ReplicationController{ old: api.ReplicationController{
ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Selector: validSelector, Selector: validSelector,
Template: &validPodTemplate.Template, Template: &validPodTemplate.Template,
}, },
}, },
update: api.ReplicationController{ update: api.ReplicationController{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Replicas: 2, Replicas: 2,
Selector: validSelector, Selector: validSelector,
@ -5411,14 +5411,14 @@ func TestValidateReplicationControllerUpdate(t *testing.T) {
}, },
"invalid selector": { "invalid selector": {
old: api.ReplicationController{ old: api.ReplicationController{
ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Selector: validSelector, Selector: validSelector,
Template: &validPodTemplate.Template, Template: &validPodTemplate.Template,
}, },
}, },
update: api.ReplicationController{ update: api.ReplicationController{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Replicas: 2, Replicas: 2,
Selector: invalidSelector, Selector: invalidSelector,
@ -5428,14 +5428,14 @@ func TestValidateReplicationControllerUpdate(t *testing.T) {
}, },
"invalid pod": { "invalid pod": {
old: api.ReplicationController{ old: api.ReplicationController{
ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Selector: validSelector, Selector: validSelector,
Template: &validPodTemplate.Template, Template: &validPodTemplate.Template,
}, },
}, },
update: api.ReplicationController{ update: api.ReplicationController{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Replicas: 2, Replicas: 2,
Selector: validSelector, Selector: validSelector,
@ -5445,14 +5445,14 @@ func TestValidateReplicationControllerUpdate(t *testing.T) {
}, },
"negative replicas": { "negative replicas": {
old: api.ReplicationController{ old: api.ReplicationController{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Selector: validSelector, Selector: validSelector,
Template: &validPodTemplate.Template, Template: &validPodTemplate.Template,
}, },
}, },
update: api.ReplicationController{ update: api.ReplicationController{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Replicas: -1, Replicas: -1,
Selector: validSelector, Selector: validSelector,
@ -5509,21 +5509,21 @@ func TestValidateReplicationController(t *testing.T) {
} }
successCases := []api.ReplicationController{ successCases := []api.ReplicationController{
{ {
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Selector: validSelector, Selector: validSelector,
Template: &validPodTemplate.Template, Template: &validPodTemplate.Template,
}, },
}, },
{ {
ObjectMeta: metav1.ObjectMeta{Name: "abc-123", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc-123", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Selector: validSelector, Selector: validSelector,
Template: &validPodTemplate.Template, Template: &validPodTemplate.Template,
}, },
}, },
{ {
ObjectMeta: metav1.ObjectMeta{Name: "abc-123", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc-123", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Replicas: 1, Replicas: 1,
Selector: validSelector, Selector: validSelector,
@ -5539,7 +5539,7 @@ func TestValidateReplicationController(t *testing.T) {
errorCases := map[string]api.ReplicationController{ errorCases := map[string]api.ReplicationController{
"zero-length ID": { "zero-length ID": {
ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Selector: validSelector, Selector: validSelector,
Template: &validPodTemplate.Template, Template: &validPodTemplate.Template,
@ -5553,20 +5553,20 @@ func TestValidateReplicationController(t *testing.T) {
}, },
}, },
"empty selector": { "empty selector": {
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Template: &validPodTemplate.Template, Template: &validPodTemplate.Template,
}, },
}, },
"selector_doesnt_match": { "selector_doesnt_match": {
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Selector: map[string]string{"foo": "bar"}, Selector: map[string]string{"foo": "bar"},
Template: &validPodTemplate.Template, Template: &validPodTemplate.Template,
}, },
}, },
"invalid manifest": { "invalid manifest": {
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Selector: validSelector, Selector: validSelector,
}, },
@ -5580,7 +5580,7 @@ func TestValidateReplicationController(t *testing.T) {
}, },
}, },
"negative_replicas": { "negative_replicas": {
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Replicas: -1, Replicas: -1,
Selector: validSelector, Selector: validSelector,
@ -5589,7 +5589,7 @@ func TestValidateReplicationController(t *testing.T) {
"invalid_label": { "invalid_label": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc-123", Name: "abc-123",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
Labels: map[string]string{ Labels: map[string]string{
"NoUppercaseOrSpecialCharsLike=Equals": "bar", "NoUppercaseOrSpecialCharsLike=Equals": "bar",
}, },
@ -5602,7 +5602,7 @@ func TestValidateReplicationController(t *testing.T) {
"invalid_label 2": { "invalid_label 2": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc-123", Name: "abc-123",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
Labels: map[string]string{ Labels: map[string]string{
"NoUppercaseOrSpecialCharsLike=Equals": "bar", "NoUppercaseOrSpecialCharsLike=Equals": "bar",
}, },
@ -5614,7 +5614,7 @@ func TestValidateReplicationController(t *testing.T) {
"invalid_annotation": { "invalid_annotation": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc-123", Name: "abc-123",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
Annotations: map[string]string{ Annotations: map[string]string{
"NoUppercaseOrSpecialCharsLike=Equals": "bar", "NoUppercaseOrSpecialCharsLike=Equals": "bar",
}, },
@ -5627,7 +5627,7 @@ func TestValidateReplicationController(t *testing.T) {
"invalid restart policy 1": { "invalid restart policy 1": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc-123", Name: "abc-123",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Selector: validSelector, Selector: validSelector,
@ -5646,7 +5646,7 @@ func TestValidateReplicationController(t *testing.T) {
"invalid restart policy 2": { "invalid restart policy 2": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc-123", Name: "abc-123",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: api.ReplicationControllerSpec{ Spec: api.ReplicationControllerSpec{
Selector: validSelector, Selector: validSelector,
@ -8522,7 +8522,7 @@ func newNodeNameEndpoint(nodeName string) *api.Endpoints {
ep := &api.Endpoints{ ep := &api.Endpoints{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "foo", Name: "foo",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "1", ResourceVersion: "1",
}, },
Subsets: []api.EndpointSubset{ Subsets: []api.EndpointSubset{

View File

@ -53,14 +53,14 @@ func TestValidateStatefulSet(t *testing.T) {
} }
successCases := []apps.StatefulSet{ successCases := []apps.StatefulSet{
{ {
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{ Spec: apps.StatefulSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
{ {
ObjectMeta: metav1.ObjectMeta{Name: "abc-123", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc-123", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{ Spec: apps.StatefulSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
@ -75,7 +75,7 @@ func TestValidateStatefulSet(t *testing.T) {
errorCases := map[string]apps.StatefulSet{ errorCases := map[string]apps.StatefulSet{
"zero-length ID": { "zero-length ID": {
ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{ Spec: apps.StatefulSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
@ -89,26 +89,26 @@ func TestValidateStatefulSet(t *testing.T) {
}, },
}, },
"empty selector": { "empty selector": {
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{ Spec: apps.StatefulSetSpec{
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
"selector_doesnt_match": { "selector_doesnt_match": {
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{ Spec: apps.StatefulSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}}, Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
"invalid manifest": { "invalid manifest": {
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{ Spec: apps.StatefulSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
}, },
}, },
"negative_replicas": { "negative_replicas": {
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{ Spec: apps.StatefulSetSpec{
Replicas: -1, Replicas: -1,
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
@ -117,7 +117,7 @@ func TestValidateStatefulSet(t *testing.T) {
"invalid_label": { "invalid_label": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc-123", Name: "abc-123",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
Labels: map[string]string{ Labels: map[string]string{
"NoUppercaseOrSpecialCharsLike=Equals": "bar", "NoUppercaseOrSpecialCharsLike=Equals": "bar",
}, },
@ -130,7 +130,7 @@ func TestValidateStatefulSet(t *testing.T) {
"invalid_label 2": { "invalid_label 2": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc-123", Name: "abc-123",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
Labels: map[string]string{ Labels: map[string]string{
"NoUppercaseOrSpecialCharsLike=Equals": "bar", "NoUppercaseOrSpecialCharsLike=Equals": "bar",
}, },
@ -142,7 +142,7 @@ func TestValidateStatefulSet(t *testing.T) {
"invalid_annotation": { "invalid_annotation": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc-123", Name: "abc-123",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
Annotations: map[string]string{ Annotations: map[string]string{
"NoUppercaseOrSpecialCharsLike=Equals": "bar", "NoUppercaseOrSpecialCharsLike=Equals": "bar",
}, },
@ -155,7 +155,7 @@ func TestValidateStatefulSet(t *testing.T) {
"invalid restart policy 1": { "invalid restart policy 1": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc-123", Name: "abc-123",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: apps.StatefulSetSpec{ Spec: apps.StatefulSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
@ -174,7 +174,7 @@ func TestValidateStatefulSet(t *testing.T) {
"invalid restart policy 2": { "invalid restart policy 2": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc-123", Name: "abc-123",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: apps.StatefulSetSpec{ Spec: apps.StatefulSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
@ -261,14 +261,14 @@ func TestValidateStatefulSetUpdate(t *testing.T) {
successCases := []psUpdateTest{ successCases := []psUpdateTest{
{ {
old: apps.StatefulSet{ old: apps.StatefulSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{ Spec: apps.StatefulSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
update: apps.StatefulSet{ update: apps.StatefulSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{ Spec: apps.StatefulSetSpec{
Replicas: 3, Replicas: 3,
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
@ -287,14 +287,14 @@ func TestValidateStatefulSetUpdate(t *testing.T) {
errorCases := map[string]psUpdateTest{ errorCases := map[string]psUpdateTest{
"more than one read/write": { "more than one read/write": {
old: apps.StatefulSet{ old: apps.StatefulSet{
ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{ Spec: apps.StatefulSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
update: apps.StatefulSet{ update: apps.StatefulSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{ Spec: apps.StatefulSetSpec{
Replicas: 2, Replicas: 2,
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
@ -304,14 +304,14 @@ func TestValidateStatefulSetUpdate(t *testing.T) {
}, },
"updates to a field other than spec.Replicas": { "updates to a field other than spec.Replicas": {
old: apps.StatefulSet{ old: apps.StatefulSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{ Spec: apps.StatefulSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
update: apps.StatefulSet{ update: apps.StatefulSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{ Spec: apps.StatefulSetSpec{
Replicas: 1, Replicas: 1,
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
@ -321,14 +321,14 @@ func TestValidateStatefulSetUpdate(t *testing.T) {
}, },
"invalid selector": { "invalid selector": {
old: apps.StatefulSet{ old: apps.StatefulSet{
ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{ Spec: apps.StatefulSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
update: apps.StatefulSet{ update: apps.StatefulSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{ Spec: apps.StatefulSetSpec{
Replicas: 2, Replicas: 2,
Selector: &metav1.LabelSelector{MatchLabels: invalidLabels}, Selector: &metav1.LabelSelector{MatchLabels: invalidLabels},
@ -338,14 +338,14 @@ func TestValidateStatefulSetUpdate(t *testing.T) {
}, },
"invalid pod": { "invalid pod": {
old: apps.StatefulSet{ old: apps.StatefulSet{
ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{ Spec: apps.StatefulSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
update: apps.StatefulSet{ update: apps.StatefulSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{ Spec: apps.StatefulSetSpec{
Replicas: 2, Replicas: 2,
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
@ -355,14 +355,14 @@ func TestValidateStatefulSetUpdate(t *testing.T) {
}, },
"negative replicas": { "negative replicas": {
old: apps.StatefulSet{ old: apps.StatefulSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{ Spec: apps.StatefulSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
update: apps.StatefulSet{ update: apps.StatefulSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{ Spec: apps.StatefulSetSpec{
Replicas: -1, Replicas: -1,
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},

View File

@ -21,7 +21,6 @@ import (
"testing" "testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/autoscaling" "k8s.io/kubernetes/pkg/apis/autoscaling"
"k8s.io/kubernetes/pkg/controller/podautoscaler" "k8s.io/kubernetes/pkg/controller/podautoscaler"
) )
@ -31,7 +30,7 @@ func TestValidateScale(t *testing.T) {
{ {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "frontend", Name: "frontend",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: autoscaling.ScaleSpec{ Spec: autoscaling.ScaleSpec{
Replicas: 1, Replicas: 1,
@ -40,7 +39,7 @@ func TestValidateScale(t *testing.T) {
{ {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "frontend", Name: "frontend",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: autoscaling.ScaleSpec{ Spec: autoscaling.ScaleSpec{
Replicas: 10, Replicas: 10,
@ -49,7 +48,7 @@ func TestValidateScale(t *testing.T) {
{ {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "frontend", Name: "frontend",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: autoscaling.ScaleSpec{ Spec: autoscaling.ScaleSpec{
Replicas: 0, Replicas: 0,
@ -71,7 +70,7 @@ func TestValidateScale(t *testing.T) {
scale: autoscaling.Scale{ scale: autoscaling.Scale{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "frontend", Name: "frontend",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: autoscaling.ScaleSpec{ Spec: autoscaling.ScaleSpec{
Replicas: -1, Replicas: -1,
@ -95,7 +94,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
{ {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "myautoscaler", Name: "myautoscaler",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{ ScaleTargetRef: autoscaling.CrossVersionObjectReference{
@ -110,7 +109,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
{ {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "myautoscaler", Name: "myautoscaler",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{ ScaleTargetRef: autoscaling.CrossVersionObjectReference{
@ -124,7 +123,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
{ {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "myautoscaler", Name: "myautoscaler",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
Annotations: map[string]string{ Annotations: map[string]string{
podautoscaler.HpaCustomMetricsTargetAnnotationName: "{\"items\":[{\"name\":\"qps\",\"value\":\"20\"}]}", podautoscaler.HpaCustomMetricsTargetAnnotationName: "{\"items\":[{\"name\":\"qps\",\"value\":\"20\"}]}",
}, },
@ -151,7 +150,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
}{ }{
{ {
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{ horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc"},
MinReplicas: newInt32(1), MinReplicas: newInt32(1),
@ -163,7 +162,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
}, },
{ {
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{ horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Kind: "..", Name: "myrc"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Kind: "..", Name: "myrc"},
MinReplicas: newInt32(1), MinReplicas: newInt32(1),
@ -175,7 +174,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
}, },
{ {
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{ horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Kind: "ReplicationController"},
MinReplicas: newInt32(1), MinReplicas: newInt32(1),
@ -187,7 +186,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
}, },
{ {
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{ horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Kind: "ReplicationController", Name: ".."}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Kind: "ReplicationController", Name: ".."},
MinReplicas: newInt32(1), MinReplicas: newInt32(1),
@ -201,7 +200,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{ horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "myautoscaler", Name: "myautoscaler",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{},
@ -215,7 +214,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{ horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "myautoscaler", Name: "myautoscaler",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{},
@ -229,7 +228,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{ horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "myautoscaler", Name: "myautoscaler",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{},
@ -244,7 +243,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{ horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "myautoscaler", Name: "myautoscaler",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
Annotations: map[string]string{ Annotations: map[string]string{
podautoscaler.HpaCustomMetricsTargetAnnotationName: "broken", podautoscaler.HpaCustomMetricsTargetAnnotationName: "broken",
}, },
@ -264,7 +263,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{ horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "myautoscaler", Name: "myautoscaler",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
Annotations: map[string]string{ Annotations: map[string]string{
podautoscaler.HpaCustomMetricsTargetAnnotationName: "{}", podautoscaler.HpaCustomMetricsTargetAnnotationName: "{}",
}, },
@ -284,7 +283,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{ horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "myautoscaler", Name: "myautoscaler",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
Annotations: map[string]string{ Annotations: map[string]string{
podautoscaler.HpaCustomMetricsTargetAnnotationName: "{\"items\":[{\"value\":\"20\"}]}", podautoscaler.HpaCustomMetricsTargetAnnotationName: "{\"items\":[{\"value\":\"20\"}]}",
}, },
@ -304,7 +303,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{ horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "myautoscaler", Name: "myautoscaler",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
Annotations: map[string]string{ Annotations: map[string]string{
podautoscaler.HpaCustomMetricsTargetAnnotationName: "{\"items\":[{\"name\":\"qps\",\"value\":\"0\"}]}", podautoscaler.HpaCustomMetricsTargetAnnotationName: "{\"items\":[{\"name\":\"qps\",\"value\":\"0\"}]}",
}, },

View File

@ -74,7 +74,7 @@ func TestValidateJob(t *testing.T) {
"manual selector": { "manual selector": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "myjob", Name: "myjob",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.JobSpec{ Spec: batch.JobSpec{
@ -86,7 +86,7 @@ func TestValidateJob(t *testing.T) {
"generated selector": { "generated selector": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "myjob", Name: "myjob",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.JobSpec{ Spec: batch.JobSpec{
@ -106,7 +106,7 @@ func TestValidateJob(t *testing.T) {
"spec.parallelism:must be greater than or equal to 0": { "spec.parallelism:must be greater than or equal to 0": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "myjob", Name: "myjob",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.JobSpec{ Spec: batch.JobSpec{
@ -118,7 +118,7 @@ func TestValidateJob(t *testing.T) {
"spec.completions:must be greater than or equal to 0": { "spec.completions:must be greater than or equal to 0": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "myjob", Name: "myjob",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.JobSpec{ Spec: batch.JobSpec{
@ -130,7 +130,7 @@ func TestValidateJob(t *testing.T) {
"spec.activeDeadlineSeconds:must be greater than or equal to 0": { "spec.activeDeadlineSeconds:must be greater than or equal to 0": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "myjob", Name: "myjob",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.JobSpec{ Spec: batch.JobSpec{
@ -142,7 +142,7 @@ func TestValidateJob(t *testing.T) {
"spec.selector:Required value": { "spec.selector:Required value": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "myjob", Name: "myjob",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.JobSpec{ Spec: batch.JobSpec{
@ -152,7 +152,7 @@ func TestValidateJob(t *testing.T) {
"spec.template.metadata.labels: Invalid value: {\"y\":\"z\"}: `selector` does not match template `labels`": { "spec.template.metadata.labels: Invalid value: {\"y\":\"z\"}: `selector` does not match template `labels`": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "myjob", Name: "myjob",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.JobSpec{ Spec: batch.JobSpec{
@ -173,7 +173,7 @@ func TestValidateJob(t *testing.T) {
"spec.template.metadata.labels: Invalid value: {\"controller-uid\":\"4d5e6f\"}: `selector` does not match template `labels`": { "spec.template.metadata.labels: Invalid value: {\"controller-uid\":\"4d5e6f\"}: `selector` does not match template `labels`": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "myjob", Name: "myjob",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.JobSpec{ Spec: batch.JobSpec{
@ -194,7 +194,7 @@ func TestValidateJob(t *testing.T) {
"spec.template.spec.restartPolicy: Unsupported value": { "spec.template.spec.restartPolicy: Unsupported value": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "myjob", Name: "myjob",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.JobSpec{ Spec: batch.JobSpec{
@ -237,7 +237,7 @@ func TestValidateJobUpdateStatus(t *testing.T) {
successCases := []testcase{ successCases := []testcase{
{ {
old: batch.Job{ old: batch.Job{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Status: batch.JobStatus{ Status: batch.JobStatus{
Active: 1, Active: 1,
Succeeded: 2, Succeeded: 2,
@ -245,7 +245,7 @@ func TestValidateJobUpdateStatus(t *testing.T) {
}, },
}, },
update: batch.Job{ update: batch.Job{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Status: batch.JobStatus{ Status: batch.JobStatus{
Active: 1, Active: 1,
Succeeded: 1, Succeeded: 1,
@ -268,7 +268,7 @@ func TestValidateJobUpdateStatus(t *testing.T) {
old: batch.Job{ old: batch.Job{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc", Name: "abc",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "10", ResourceVersion: "10",
}, },
Status: batch.JobStatus{ Status: batch.JobStatus{
@ -280,7 +280,7 @@ func TestValidateJobUpdateStatus(t *testing.T) {
update: batch.Job{ update: batch.Job{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc", Name: "abc",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "10", ResourceVersion: "10",
}, },
Status: batch.JobStatus{ Status: batch.JobStatus{
@ -313,7 +313,7 @@ func TestValidateCronJob(t *testing.T) {
"basic scheduled job": { "basic scheduled job": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "mycronjob", Name: "mycronjob",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.CronJobSpec{ Spec: batch.CronJobSpec{
@ -329,7 +329,7 @@ func TestValidateCronJob(t *testing.T) {
"non-standard scheduled": { "non-standard scheduled": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "mycronjob", Name: "mycronjob",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.CronJobSpec{ Spec: batch.CronJobSpec{
@ -356,7 +356,7 @@ func TestValidateCronJob(t *testing.T) {
"spec.schedule: Invalid value": { "spec.schedule: Invalid value": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "mycronjob", Name: "mycronjob",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.CronJobSpec{ Spec: batch.CronJobSpec{
@ -372,7 +372,7 @@ func TestValidateCronJob(t *testing.T) {
"spec.schedule: Required value": { "spec.schedule: Required value": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "mycronjob", Name: "mycronjob",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.CronJobSpec{ Spec: batch.CronJobSpec{
@ -388,7 +388,7 @@ func TestValidateCronJob(t *testing.T) {
"spec.startingDeadlineSeconds:must be greater than or equal to 0": { "spec.startingDeadlineSeconds:must be greater than or equal to 0": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "mycronjob", Name: "mycronjob",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.CronJobSpec{ Spec: batch.CronJobSpec{
@ -405,7 +405,7 @@ func TestValidateCronJob(t *testing.T) {
"spec.concurrencyPolicy: Required value": { "spec.concurrencyPolicy: Required value": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "mycronjob", Name: "mycronjob",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.CronJobSpec{ Spec: batch.CronJobSpec{
@ -420,7 +420,7 @@ func TestValidateCronJob(t *testing.T) {
"spec.jobTemplate.spec.parallelism:must be greater than or equal to 0": { "spec.jobTemplate.spec.parallelism:must be greater than or equal to 0": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "mycronjob", Name: "mycronjob",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.CronJobSpec{ Spec: batch.CronJobSpec{
@ -437,7 +437,7 @@ func TestValidateCronJob(t *testing.T) {
"spec.jobTemplate.spec.completions:must be greater than or equal to 0": { "spec.jobTemplate.spec.completions:must be greater than or equal to 0": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "mycronjob", Name: "mycronjob",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.CronJobSpec{ Spec: batch.CronJobSpec{
@ -455,7 +455,7 @@ func TestValidateCronJob(t *testing.T) {
"spec.jobTemplate.spec.activeDeadlineSeconds:must be greater than or equal to 0": { "spec.jobTemplate.spec.activeDeadlineSeconds:must be greater than or equal to 0": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "mycronjob", Name: "mycronjob",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.CronJobSpec{ Spec: batch.CronJobSpec{
@ -472,7 +472,7 @@ func TestValidateCronJob(t *testing.T) {
"spec.jobTemplate.spec.selector: Invalid value: {\"matchLabels\":{\"a\":\"b\"}}: `selector` will be auto-generated": { "spec.jobTemplate.spec.selector: Invalid value: {\"matchLabels\":{\"a\":\"b\"}}: `selector` will be auto-generated": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "mycronjob", Name: "mycronjob",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.CronJobSpec{ Spec: batch.CronJobSpec{
@ -489,7 +489,7 @@ func TestValidateCronJob(t *testing.T) {
"spec.jobTemplate.spec.manualSelector: Unsupported value": { "spec.jobTemplate.spec.manualSelector: Unsupported value": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "mycronjob", Name: "mycronjob",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.CronJobSpec{ Spec: batch.CronJobSpec{
@ -506,7 +506,7 @@ func TestValidateCronJob(t *testing.T) {
"spec.jobTemplate.spec.template.spec.restartPolicy: Unsupported value": { "spec.jobTemplate.spec.template.spec.restartPolicy: Unsupported value": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "mycronjob", Name: "mycronjob",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.CronJobSpec{ Spec: batch.CronJobSpec{

View File

@ -277,7 +277,7 @@ func SetDefaults_KubeletConfiguration(obj *KubeletConfiguration) {
obj.LowDiskSpaceThresholdMB = 256 obj.LowDiskSpaceThresholdMB = 256
} }
if obj.MasterServiceNamespace == "" { if obj.MasterServiceNamespace == "" {
obj.MasterServiceNamespace = api.NamespaceDefault obj.MasterServiceNamespace = metav1.NamespaceDefault
} }
if obj.MaxContainerCount == nil { if obj.MaxContainerCount == nil {
temp := int32(-1) temp := int32(-1)

View File

@ -40,7 +40,7 @@ func TestValidateDaemonSetStatusUpdate(t *testing.T) {
successCases := []dsUpdateTest{ successCases := []dsUpdateTest{
{ {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Status: extensions.DaemonSetStatus{ Status: extensions.DaemonSetStatus{
CurrentNumberScheduled: 1, CurrentNumberScheduled: 1,
NumberMisscheduled: 2, NumberMisscheduled: 2,
@ -49,7 +49,7 @@ func TestValidateDaemonSetStatusUpdate(t *testing.T) {
}, },
}, },
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Status: extensions.DaemonSetStatus{ Status: extensions.DaemonSetStatus{
CurrentNumberScheduled: 1, CurrentNumberScheduled: 1,
NumberMisscheduled: 1, NumberMisscheduled: 1,
@ -72,7 +72,7 @@ func TestValidateDaemonSetStatusUpdate(t *testing.T) {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc", Name: "abc",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "10", ResourceVersion: "10",
}, },
Status: extensions.DaemonSetStatus{ Status: extensions.DaemonSetStatus{
@ -86,7 +86,7 @@ func TestValidateDaemonSetStatusUpdate(t *testing.T) {
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc", Name: "abc",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "10", ResourceVersion: "10",
}, },
Status: extensions.DaemonSetStatus{ Status: extensions.DaemonSetStatus{
@ -102,7 +102,7 @@ func TestValidateDaemonSetStatusUpdate(t *testing.T) {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc", Name: "abc",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "10", ResourceVersion: "10",
}, },
Status: extensions.DaemonSetStatus{ Status: extensions.DaemonSetStatus{
@ -116,7 +116,7 @@ func TestValidateDaemonSetStatusUpdate(t *testing.T) {
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc", Name: "abc",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "10", ResourceVersion: "10",
}, },
Status: extensions.DaemonSetStatus{ Status: extensions.DaemonSetStatus{
@ -132,7 +132,7 @@ func TestValidateDaemonSetStatusUpdate(t *testing.T) {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc", Name: "abc",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "10", ResourceVersion: "10",
}, },
Status: extensions.DaemonSetStatus{ Status: extensions.DaemonSetStatus{
@ -146,7 +146,7 @@ func TestValidateDaemonSetStatusUpdate(t *testing.T) {
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc", Name: "abc",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "10", ResourceVersion: "10",
}, },
Status: extensions.DaemonSetStatus{ Status: extensions.DaemonSetStatus{
@ -162,7 +162,7 @@ func TestValidateDaemonSetStatusUpdate(t *testing.T) {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc", Name: "abc",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "10", ResourceVersion: "10",
}, },
Status: extensions.DaemonSetStatus{ Status: extensions.DaemonSetStatus{
@ -176,7 +176,7 @@ func TestValidateDaemonSetStatusUpdate(t *testing.T) {
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc", Name: "abc",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "10", ResourceVersion: "10",
}, },
Status: extensions.DaemonSetStatus{ Status: extensions.DaemonSetStatus{
@ -192,7 +192,7 @@ func TestValidateDaemonSetStatusUpdate(t *testing.T) {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc", Name: "abc",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "10", ResourceVersion: "10",
}, },
Status: extensions.DaemonSetStatus{ Status: extensions.DaemonSetStatus{
@ -206,7 +206,7 @@ func TestValidateDaemonSetStatusUpdate(t *testing.T) {
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc", Name: "abc",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "10", ResourceVersion: "10",
}, },
Status: extensions.DaemonSetStatus{ Status: extensions.DaemonSetStatus{
@ -222,7 +222,7 @@ func TestValidateDaemonSetStatusUpdate(t *testing.T) {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc", Name: "abc",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "10", ResourceVersion: "10",
}, },
Status: extensions.DaemonSetStatus{ Status: extensions.DaemonSetStatus{
@ -236,7 +236,7 @@ func TestValidateDaemonSetStatusUpdate(t *testing.T) {
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc", Name: "abc",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "10", ResourceVersion: "10",
}, },
Status: extensions.DaemonSetStatus{ Status: extensions.DaemonSetStatus{
@ -345,14 +345,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
successCases := []dsUpdateTest{ successCases := []dsUpdateTest{
{ {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validSelector}, Selector: &metav1.LabelSelector{MatchLabels: validSelector},
Template: validPodTemplateAbc.Template, Template: validPodTemplateAbc.Template,
}, },
}, },
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validSelector}, Selector: &metav1.LabelSelector{MatchLabels: validSelector},
Template: validPodTemplateAbc.Template, Template: validPodTemplateAbc.Template,
@ -361,14 +361,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
}, },
{ {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validSelector}, Selector: &metav1.LabelSelector{MatchLabels: validSelector},
Template: validPodTemplateAbc.Template, Template: validPodTemplateAbc.Template,
}, },
}, },
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validSelector2}, Selector: &metav1.LabelSelector{MatchLabels: validSelector2},
Template: validPodTemplateAbc2.Template, Template: validPodTemplateAbc2.Template,
@ -377,14 +377,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
}, },
{ {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validSelector}, Selector: &metav1.LabelSelector{MatchLabels: validSelector},
Template: validPodTemplateAbc.Template, Template: validPodTemplateAbc.Template,
}, },
}, },
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validSelector}, Selector: &metav1.LabelSelector{MatchLabels: validSelector},
Template: validPodTemplateNodeSelector.Template, Template: validPodTemplateNodeSelector.Template,
@ -402,14 +402,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
errorCases := map[string]dsUpdateTest{ errorCases := map[string]dsUpdateTest{
"change daemon name": { "change daemon name": {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validSelector}, Selector: &metav1.LabelSelector{MatchLabels: validSelector},
Template: validPodTemplateAbc.Template, Template: validPodTemplateAbc.Template,
}, },
}, },
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validSelector}, Selector: &metav1.LabelSelector{MatchLabels: validSelector},
Template: validPodTemplateAbc.Template, Template: validPodTemplateAbc.Template,
@ -418,14 +418,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
}, },
"invalid selector": { "invalid selector": {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validSelector}, Selector: &metav1.LabelSelector{MatchLabels: validSelector},
Template: validPodTemplateAbc.Template, Template: validPodTemplateAbc.Template,
}, },
}, },
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: invalidSelector}, Selector: &metav1.LabelSelector{MatchLabels: invalidSelector},
Template: validPodTemplateAbc.Template, Template: validPodTemplateAbc.Template,
@ -434,14 +434,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
}, },
"invalid pod": { "invalid pod": {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validSelector}, Selector: &metav1.LabelSelector{MatchLabels: validSelector},
Template: validPodTemplateAbc.Template, Template: validPodTemplateAbc.Template,
}, },
}, },
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validSelector}, Selector: &metav1.LabelSelector{MatchLabels: validSelector},
Template: invalidPodTemplate.Template, Template: invalidPodTemplate.Template,
@ -450,14 +450,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
}, },
"change container image": { "change container image": {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validSelector}, Selector: &metav1.LabelSelector{MatchLabels: validSelector},
Template: validPodTemplateAbc.Template, Template: validPodTemplateAbc.Template,
}, },
}, },
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validSelector}, Selector: &metav1.LabelSelector{MatchLabels: validSelector},
Template: validPodTemplateDef.Template, Template: validPodTemplateDef.Template,
@ -466,14 +466,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
}, },
"read-write volume": { "read-write volume": {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validSelector}, Selector: &metav1.LabelSelector{MatchLabels: validSelector},
Template: validPodTemplateAbc.Template, Template: validPodTemplateAbc.Template,
}, },
}, },
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validSelector}, Selector: &metav1.LabelSelector{MatchLabels: validSelector},
Template: readWriteVolumePodTemplate.Template, Template: readWriteVolumePodTemplate.Template,
@ -482,14 +482,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
}, },
"invalid update strategy": { "invalid update strategy": {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validSelector}, Selector: &metav1.LabelSelector{MatchLabels: validSelector},
Template: validPodTemplateAbc.Template, Template: validPodTemplateAbc.Template,
}, },
}, },
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: invalidSelector}, Selector: &metav1.LabelSelector{MatchLabels: invalidSelector},
Template: validPodTemplateAbc.Template, Template: validPodTemplateAbc.Template,
@ -532,14 +532,14 @@ func TestValidateDaemonSet(t *testing.T) {
} }
successCases := []extensions.DaemonSet{ successCases := []extensions.DaemonSet{
{ {
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validSelector}, Selector: &metav1.LabelSelector{MatchLabels: validSelector},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
{ {
ObjectMeta: metav1.ObjectMeta{Name: "abc-123", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc-123", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validSelector}, Selector: &metav1.LabelSelector{MatchLabels: validSelector},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
@ -554,7 +554,7 @@ func TestValidateDaemonSet(t *testing.T) {
errorCases := map[string]extensions.DaemonSet{ errorCases := map[string]extensions.DaemonSet{
"zero-length ID": { "zero-length ID": {
ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validSelector}, Selector: &metav1.LabelSelector{MatchLabels: validSelector},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
@ -568,27 +568,27 @@ func TestValidateDaemonSet(t *testing.T) {
}, },
}, },
"nil selector": { "nil selector": {
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
"empty selector": { "empty selector": {
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{}, Selector: &metav1.LabelSelector{},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
"selector_doesnt_match": { "selector_doesnt_match": {
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}}, Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
"invalid template": { "invalid template": {
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validSelector}, Selector: &metav1.LabelSelector{MatchLabels: validSelector},
}, },
@ -596,7 +596,7 @@ func TestValidateDaemonSet(t *testing.T) {
"invalid_label": { "invalid_label": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc-123", Name: "abc-123",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
Labels: map[string]string{ Labels: map[string]string{
"NoUppercaseOrSpecialCharsLike=Equals": "bar", "NoUppercaseOrSpecialCharsLike=Equals": "bar",
}, },
@ -609,7 +609,7 @@ func TestValidateDaemonSet(t *testing.T) {
"invalid_label 2": { "invalid_label 2": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc-123", Name: "abc-123",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
Labels: map[string]string{ Labels: map[string]string{
"NoUppercaseOrSpecialCharsLike=Equals": "bar", "NoUppercaseOrSpecialCharsLike=Equals": "bar",
}, },
@ -621,7 +621,7 @@ func TestValidateDaemonSet(t *testing.T) {
"invalid_annotation": { "invalid_annotation": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc-123", Name: "abc-123",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
Annotations: map[string]string{ Annotations: map[string]string{
"NoUppercaseOrSpecialCharsLike=Equals": "bar", "NoUppercaseOrSpecialCharsLike=Equals": "bar",
}, },
@ -634,7 +634,7 @@ func TestValidateDaemonSet(t *testing.T) {
"invalid restart policy 1": { "invalid restart policy 1": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc-123", Name: "abc-123",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validSelector}, Selector: &metav1.LabelSelector{MatchLabels: validSelector},
@ -653,7 +653,7 @@ func TestValidateDaemonSet(t *testing.T) {
"invalid restart policy 2": { "invalid restart policy 2": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc-123", Name: "abc-123",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validSelector}, Selector: &metav1.LabelSelector{MatchLabels: validSelector},
@ -697,7 +697,7 @@ func validDeployment() *extensions.Deployment {
return &extensions.Deployment{ return &extensions.Deployment{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc", Name: "abc",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: extensions.DeploymentSpec{ Spec: extensions.DeploymentSpec{
Selector: &metav1.LabelSelector{ Selector: &metav1.LabelSelector{
@ -715,7 +715,7 @@ func validDeployment() *extensions.Deployment {
Template: api.PodTemplateSpec{ Template: api.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc", Name: "abc",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
Labels: map[string]string{ Labels: map[string]string{
"name": "abc", "name": "abc",
}, },
@ -753,7 +753,7 @@ func TestValidateDeployment(t *testing.T) {
errorCases := map[string]*extensions.Deployment{} errorCases := map[string]*extensions.Deployment{}
errorCases["metadata.name: Required value"] = &extensions.Deployment{ errorCases["metadata.name: Required value"] = &extensions.Deployment{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
} }
// selector should match the labels in pod template. // selector should match the labels in pod template.
@ -888,7 +888,7 @@ func TestValidateIngress(t *testing.T) {
return extensions.Ingress{ return extensions.Ingress{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "foo", Name: "foo",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: extensions.IngressSpec{ Spec: extensions.IngressSpec{
Backend: &extensions.IngressBackend{ Backend: &extensions.IngressBackend{
@ -992,7 +992,7 @@ func TestValidateIngressTLS(t *testing.T) {
return extensions.Ingress{ return extensions.Ingress{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "foo", Name: "foo",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: extensions.IngressSpec{ Spec: extensions.IngressSpec{
Backend: &extensions.IngressBackend{ Backend: &extensions.IngressBackend{
@ -1062,7 +1062,7 @@ func TestValidateIngressStatusUpdate(t *testing.T) {
return extensions.Ingress{ return extensions.Ingress{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "foo", Name: "foo",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "9", ResourceVersion: "9",
}, },
Spec: extensions.IngressSpec{ Spec: extensions.IngressSpec{
@ -1149,7 +1149,7 @@ func TestValidateScale(t *testing.T) {
{ {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "frontend", Name: "frontend",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: extensions.ScaleSpec{ Spec: extensions.ScaleSpec{
Replicas: 1, Replicas: 1,
@ -1158,7 +1158,7 @@ func TestValidateScale(t *testing.T) {
{ {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "frontend", Name: "frontend",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: extensions.ScaleSpec{ Spec: extensions.ScaleSpec{
Replicas: 10, Replicas: 10,
@ -1167,7 +1167,7 @@ func TestValidateScale(t *testing.T) {
{ {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "frontend", Name: "frontend",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: extensions.ScaleSpec{ Spec: extensions.ScaleSpec{
Replicas: 0, Replicas: 0,
@ -1189,7 +1189,7 @@ func TestValidateScale(t *testing.T) {
scale: extensions.Scale{ scale: extensions.Scale{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "frontend", Name: "frontend",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: extensions.ScaleSpec{ Spec: extensions.ScaleSpec{
Replicas: -1, Replicas: -1,
@ -1229,7 +1229,7 @@ func TestValidateReplicaSetStatusUpdate(t *testing.T) {
successCases := []rcUpdateTest{ successCases := []rcUpdateTest{
{ {
old: extensions.ReplicaSet{ old: extensions.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
@ -1239,7 +1239,7 @@ func TestValidateReplicaSetStatusUpdate(t *testing.T) {
}, },
}, },
update: extensions.ReplicaSet{ update: extensions.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Replicas: 3, Replicas: 3,
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
@ -1261,7 +1261,7 @@ func TestValidateReplicaSetStatusUpdate(t *testing.T) {
errorCases := map[string]rcUpdateTest{ errorCases := map[string]rcUpdateTest{
"negative replicas": { "negative replicas": {
old: extensions.ReplicaSet{ old: extensions.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
@ -1271,7 +1271,7 @@ func TestValidateReplicaSetStatusUpdate(t *testing.T) {
}, },
}, },
update: extensions.ReplicaSet{ update: extensions.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Replicas: 2, Replicas: 2,
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
@ -1337,14 +1337,14 @@ func TestValidateReplicaSetUpdate(t *testing.T) {
successCases := []rcUpdateTest{ successCases := []rcUpdateTest{
{ {
old: extensions.ReplicaSet{ old: extensions.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
update: extensions.ReplicaSet{ update: extensions.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Replicas: 3, Replicas: 3,
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
@ -1354,14 +1354,14 @@ func TestValidateReplicaSetUpdate(t *testing.T) {
}, },
{ {
old: extensions.ReplicaSet{ old: extensions.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
update: extensions.ReplicaSet{ update: extensions.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Replicas: 1, Replicas: 1,
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
@ -1380,14 +1380,14 @@ func TestValidateReplicaSetUpdate(t *testing.T) {
errorCases := map[string]rcUpdateTest{ errorCases := map[string]rcUpdateTest{
"more than one read/write": { "more than one read/write": {
old: extensions.ReplicaSet{ old: extensions.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
update: extensions.ReplicaSet{ update: extensions.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Replicas: 2, Replicas: 2,
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
@ -1397,14 +1397,14 @@ func TestValidateReplicaSetUpdate(t *testing.T) {
}, },
"invalid selector": { "invalid selector": {
old: extensions.ReplicaSet{ old: extensions.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
update: extensions.ReplicaSet{ update: extensions.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Replicas: 2, Replicas: 2,
Selector: &metav1.LabelSelector{MatchLabels: invalidLabels}, Selector: &metav1.LabelSelector{MatchLabels: invalidLabels},
@ -1414,14 +1414,14 @@ func TestValidateReplicaSetUpdate(t *testing.T) {
}, },
"invalid pod": { "invalid pod": {
old: extensions.ReplicaSet{ old: extensions.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
update: extensions.ReplicaSet{ update: extensions.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Replicas: 2, Replicas: 2,
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
@ -1431,14 +1431,14 @@ func TestValidateReplicaSetUpdate(t *testing.T) {
}, },
"negative replicas": { "negative replicas": {
old: extensions.ReplicaSet{ old: extensions.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
update: extensions.ReplicaSet{ update: extensions.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Replicas: -1, Replicas: -1,
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
@ -1495,21 +1495,21 @@ func TestValidateReplicaSet(t *testing.T) {
} }
successCases := []extensions.ReplicaSet{ successCases := []extensions.ReplicaSet{
{ {
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
{ {
ObjectMeta: metav1.ObjectMeta{Name: "abc-123", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc-123", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
{ {
ObjectMeta: metav1.ObjectMeta{Name: "abc-123", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc-123", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Replicas: 1, Replicas: 1,
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
@ -1525,7 +1525,7 @@ func TestValidateReplicaSet(t *testing.T) {
errorCases := map[string]extensions.ReplicaSet{ errorCases := map[string]extensions.ReplicaSet{
"zero-length ID": { "zero-length ID": {
ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
@ -1539,20 +1539,20 @@ func TestValidateReplicaSet(t *testing.T) {
}, },
}, },
"empty selector": { "empty selector": {
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
"selector_doesnt_match": { "selector_doesnt_match": {
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}}, Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}},
Template: validPodTemplate.Template, Template: validPodTemplate.Template,
}, },
}, },
"invalid manifest": { "invalid manifest": {
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
}, },
@ -1566,7 +1566,7 @@ func TestValidateReplicaSet(t *testing.T) {
}, },
}, },
"negative_replicas": { "negative_replicas": {
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Replicas: -1, Replicas: -1,
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
@ -1575,7 +1575,7 @@ func TestValidateReplicaSet(t *testing.T) {
"invalid_label": { "invalid_label": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc-123", Name: "abc-123",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
Labels: map[string]string{ Labels: map[string]string{
"NoUppercaseOrSpecialCharsLike=Equals": "bar", "NoUppercaseOrSpecialCharsLike=Equals": "bar",
}, },
@ -1588,7 +1588,7 @@ func TestValidateReplicaSet(t *testing.T) {
"invalid_label 2": { "invalid_label 2": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc-123", Name: "abc-123",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
Labels: map[string]string{ Labels: map[string]string{
"NoUppercaseOrSpecialCharsLike=Equals": "bar", "NoUppercaseOrSpecialCharsLike=Equals": "bar",
}, },
@ -1600,7 +1600,7 @@ func TestValidateReplicaSet(t *testing.T) {
"invalid_annotation": { "invalid_annotation": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc-123", Name: "abc-123",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
Annotations: map[string]string{ Annotations: map[string]string{
"NoUppercaseOrSpecialCharsLike=Equals": "bar", "NoUppercaseOrSpecialCharsLike=Equals": "bar",
}, },
@ -1613,7 +1613,7 @@ func TestValidateReplicaSet(t *testing.T) {
"invalid restart policy 1": { "invalid restart policy 1": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc-123", Name: "abc-123",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},
@ -1632,7 +1632,7 @@ func TestValidateReplicaSet(t *testing.T) {
"invalid restart policy 2": { "invalid restart policy 2": {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "abc-123", Name: "abc-123",
Namespace: api.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: validLabels}, Selector: &metav1.LabelSelector{MatchLabels: validLabels},

View File

@ -21,7 +21,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/rbac" "k8s.io/kubernetes/pkg/apis/rbac"
) )
@ -143,7 +142,7 @@ func TestValidateClusterRoleBinding(t *testing.T) {
func TestValidateRoleBinding(t *testing.T) { func TestValidateRoleBinding(t *testing.T) {
errs := ValidateRoleBinding( errs := ValidateRoleBinding(
&rbac.RoleBinding{ &rbac.RoleBinding{
ObjectMeta: metav1.ObjectMeta{Namespace: api.NamespaceDefault, Name: "master"}, ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceDefault, Name: "master"},
RoleRef: rbac.RoleRef{APIGroup: rbac.GroupName, Kind: "Role", Name: "valid"}, RoleRef: rbac.RoleRef{APIGroup: rbac.GroupName, Kind: "Role", Name: "valid"},
Subjects: []rbac.Subject{ Subjects: []rbac.Subject{
{Name: "validsaname", Kind: rbac.ServiceAccountKind}, {Name: "validsaname", Kind: rbac.ServiceAccountKind},
@ -163,7 +162,7 @@ func TestValidateRoleBinding(t *testing.T) {
}{ }{
"bad group": { "bad group": {
A: rbac.RoleBinding{ A: rbac.RoleBinding{
ObjectMeta: metav1.ObjectMeta{Namespace: api.NamespaceDefault, Name: "default"}, ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceDefault, Name: "default"},
RoleRef: rbac.RoleRef{APIGroup: "rbac.GroupName", Kind: "ClusterRole", Name: "valid"}, RoleRef: rbac.RoleRef{APIGroup: "rbac.GroupName", Kind: "ClusterRole", Name: "valid"},
}, },
T: field.ErrorTypeNotSupported, T: field.ErrorTypeNotSupported,
@ -171,7 +170,7 @@ func TestValidateRoleBinding(t *testing.T) {
}, },
"bad kind": { "bad kind": {
A: rbac.RoleBinding{ A: rbac.RoleBinding{
ObjectMeta: metav1.ObjectMeta{Namespace: api.NamespaceDefault, Name: "default"}, ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceDefault, Name: "default"},
RoleRef: rbac.RoleRef{APIGroup: rbac.GroupName, Kind: "Type", Name: "valid"}, RoleRef: rbac.RoleRef{APIGroup: rbac.GroupName, Kind: "Type", Name: "valid"},
}, },
T: field.ErrorTypeNotSupported, T: field.ErrorTypeNotSupported,
@ -187,7 +186,7 @@ func TestValidateRoleBinding(t *testing.T) {
}, },
"zero-length name": { "zero-length name": {
A: rbac.RoleBinding{ A: rbac.RoleBinding{
ObjectMeta: metav1.ObjectMeta{Namespace: api.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceDefault},
RoleRef: rbac.RoleRef{APIGroup: rbac.GroupName, Kind: "Role", Name: "valid"}, RoleRef: rbac.RoleRef{APIGroup: rbac.GroupName, Kind: "Role", Name: "valid"},
}, },
T: field.ErrorTypeRequired, T: field.ErrorTypeRequired,
@ -195,7 +194,7 @@ func TestValidateRoleBinding(t *testing.T) {
}, },
"bad role": { "bad role": {
A: rbac.RoleBinding{ A: rbac.RoleBinding{
ObjectMeta: metav1.ObjectMeta{Namespace: api.NamespaceDefault, Name: "default"}, ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceDefault, Name: "default"},
RoleRef: rbac.RoleRef{APIGroup: rbac.GroupName, Kind: "Role"}, RoleRef: rbac.RoleRef{APIGroup: rbac.GroupName, Kind: "Role"},
}, },
T: field.ErrorTypeRequired, T: field.ErrorTypeRequired,
@ -203,7 +202,7 @@ func TestValidateRoleBinding(t *testing.T) {
}, },
"bad subject kind": { "bad subject kind": {
A: rbac.RoleBinding{ A: rbac.RoleBinding{
ObjectMeta: metav1.ObjectMeta{Namespace: api.NamespaceDefault, Name: "master"}, ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceDefault, Name: "master"},
RoleRef: rbac.RoleRef{APIGroup: rbac.GroupName, Kind: "Role", Name: "valid"}, RoleRef: rbac.RoleRef{APIGroup: rbac.GroupName, Kind: "Role", Name: "valid"},
Subjects: []rbac.Subject{{Name: "subject"}}, Subjects: []rbac.Subject{{Name: "subject"}},
}, },
@ -212,7 +211,7 @@ func TestValidateRoleBinding(t *testing.T) {
}, },
"bad subject name": { "bad subject name": {
A: rbac.RoleBinding{ A: rbac.RoleBinding{
ObjectMeta: metav1.ObjectMeta{Namespace: api.NamespaceDefault, Name: "master"}, ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceDefault, Name: "master"},
RoleRef: rbac.RoleRef{APIGroup: rbac.GroupName, Kind: "Role", Name: "valid"}, RoleRef: rbac.RoleRef{APIGroup: rbac.GroupName, Kind: "Role", Name: "valid"},
Subjects: []rbac.Subject{{Name: "subject:bad", Kind: rbac.ServiceAccountKind}}, Subjects: []rbac.Subject{{Name: "subject:bad", Kind: rbac.ServiceAccountKind}},
}, },
@ -221,7 +220,7 @@ func TestValidateRoleBinding(t *testing.T) {
}, },
"missing subject name": { "missing subject name": {
A: rbac.RoleBinding{ A: rbac.RoleBinding{
ObjectMeta: metav1.ObjectMeta{Namespace: api.NamespaceDefault, Name: "master"}, ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceDefault, Name: "master"},
RoleRef: rbac.RoleRef{APIGroup: rbac.GroupName, Kind: "Role", Name: "valid"}, RoleRef: rbac.RoleRef{APIGroup: rbac.GroupName, Kind: "Role", Name: "valid"},
Subjects: []rbac.Subject{{Kind: rbac.ServiceAccountKind}}, Subjects: []rbac.Subject{{Kind: rbac.ServiceAccountKind}},
}, },
@ -248,13 +247,13 @@ func TestValidateRoleBinding(t *testing.T) {
func TestValidateRoleBindingUpdate(t *testing.T) { func TestValidateRoleBindingUpdate(t *testing.T) {
old := &rbac.RoleBinding{ old := &rbac.RoleBinding{
ObjectMeta: metav1.ObjectMeta{Namespace: api.NamespaceDefault, Name: "master", ResourceVersion: "1"}, ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceDefault, Name: "master", ResourceVersion: "1"},
RoleRef: rbac.RoleRef{APIGroup: rbac.GroupName, Kind: "Role", Name: "valid"}, RoleRef: rbac.RoleRef{APIGroup: rbac.GroupName, Kind: "Role", Name: "valid"},
} }
errs := ValidateRoleBindingUpdate( errs := ValidateRoleBindingUpdate(
&rbac.RoleBinding{ &rbac.RoleBinding{
ObjectMeta: metav1.ObjectMeta{Namespace: api.NamespaceDefault, Name: "master", ResourceVersion: "1"}, ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceDefault, Name: "master", ResourceVersion: "1"},
RoleRef: rbac.RoleRef{APIGroup: rbac.GroupName, Kind: "Role", Name: "valid"}, RoleRef: rbac.RoleRef{APIGroup: rbac.GroupName, Kind: "Role", Name: "valid"},
}, },
old, old,
@ -270,7 +269,7 @@ func TestValidateRoleBindingUpdate(t *testing.T) {
}{ }{
"changedRef": { "changedRef": {
A: rbac.RoleBinding{ A: rbac.RoleBinding{
ObjectMeta: metav1.ObjectMeta{Namespace: api.NamespaceDefault, Name: "master", ResourceVersion: "1"}, ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceDefault, Name: "master", ResourceVersion: "1"},
RoleRef: rbac.RoleRef{APIGroup: rbac.GroupName, Kind: "Role", Name: "changed"}, RoleRef: rbac.RoleRef{APIGroup: rbac.GroupName, Kind: "Role", Name: "changed"},
}, },
T: field.ErrorTypeInvalid, T: field.ErrorTypeInvalid,

View File

@ -35,6 +35,7 @@ go_library(
"//vendor:github.com/golang/glog", "//vendor:github.com/golang/glog",
"//vendor:k8s.io/apimachinery/pkg/api/errors", "//vendor:k8s.io/apimachinery/pkg/api/errors",
"//vendor:k8s.io/apimachinery/pkg/api/meta", "//vendor:k8s.io/apimachinery/pkg/api/meta",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/internalversion",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1", "//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/fields", "//vendor:k8s.io/apimachinery/pkg/fields",
"//vendor:k8s.io/apimachinery/pkg/labels", "//vendor:k8s.io/apimachinery/pkg/labels",

View File

@ -351,12 +351,12 @@ func TestUpdate(t *testing.T) {
watchCh := make(chan struct{}) watchCh := make(chan struct{})
_, controller := NewInformer( _, controller := NewInformer(
&testLW{ &testLW{
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
watch, err := source.Watch(options) watch, err := source.Watch(options)
close(watchCh) close(watchCh)
return watch, err return watch, err
}, },
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return source.List(options) return source.List(options)
}, },
}, },

View File

@ -25,7 +25,6 @@ import (
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/kubernetes/pkg/api/v1"
) )
// AppendFunc is used to add a matching item to whatever list the caller is using // AppendFunc is used to add a matching item to whatever list the caller is using
@ -45,7 +44,7 @@ func ListAll(store Store, selector labels.Selector, appendFn AppendFunc) error {
} }
func ListAllByNamespace(indexer Indexer, namespace string, selector labels.Selector, appendFn AppendFunc) error { func ListAllByNamespace(indexer Indexer, namespace string, selector labels.Selector, appendFn AppendFunc) error {
if namespace == v1.NamespaceAll { if namespace == metav1.NamespaceAll {
for _, m := range indexer.List() { for _, m := range indexer.List() {
metadata, err := meta.Accessor(m) metadata, err := meta.Accessor(m)
if err != nil { if err != nil {

View File

@ -25,8 +25,6 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
restclient "k8s.io/client-go/rest" restclient "k8s.io/client-go/rest"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1"
) )
// ListerWatcher is any object that knows how to perform an initial list and start a watch on a resource. // ListerWatcher is any object that knows how to perform an initial list and start a watch on a resource.

View File

@ -70,18 +70,18 @@ func TestListWatchesCanList(t *testing.T) {
}{ }{
// Node // Node
{ {
location: testapi.Default.ResourcePath("nodes", v1.NamespaceAll, ""), location: testapi.Default.ResourcePath("nodes", metav1.NamespaceAll, ""),
resource: "nodes", resource: "nodes",
namespace: v1.NamespaceAll, namespace: metav1.NamespaceAll,
fieldSelector: parseSelectorOrDie(""), fieldSelector: parseSelectorOrDie(""),
}, },
// pod with "assigned" field selector. // pod with "assigned" field selector.
{ {
location: buildLocation( location: buildLocation(
testapi.Default.ResourcePath("pods", v1.NamespaceAll, ""), testapi.Default.ResourcePath("pods", metav1.NamespaceAll, ""),
buildQueryValues(url.Values{fieldSelectorQueryParamName: []string{"spec.host="}})), buildQueryValues(url.Values{fieldSelectorQueryParamName: []string{"spec.host="}})),
resource: "pods", resource: "pods",
namespace: v1.NamespaceAll, namespace: metav1.NamespaceAll,
fieldSelector: fields.Set{"spec.host": ""}.AsSelector(), fieldSelector: fields.Set{"spec.host": ""}.AsSelector(),
}, },
// pod in namespace "foo" // pod in namespace "foo"
@ -105,7 +105,7 @@ func TestListWatchesCanList(t *testing.T) {
client := clientset.NewForConfigOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &api.Registry.GroupOrDie(v1.GroupName).GroupVersion}}) client := clientset.NewForConfigOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &api.Registry.GroupOrDie(v1.GroupName).GroupVersion}})
lw := NewListWatchFromClient(client.Core().RESTClient(), item.resource, item.namespace, item.fieldSelector) lw := NewListWatchFromClient(client.Core().RESTClient(), item.resource, item.namespace, item.fieldSelector)
// This test merely tests that the correct request is made. // This test merely tests that the correct request is made.
lw.List(v1.ListOptions{}) lw.List(metav1.ListOptions{})
handler.ValidateRequest(t, item.location, "GET", nil) handler.ValidateRequest(t, item.location, "GET", nil)
} }
} }
@ -122,30 +122,30 @@ func TestListWatchesCanWatch(t *testing.T) {
// Node // Node
{ {
location: buildLocation( location: buildLocation(
testapi.Default.ResourcePathWithPrefix("watch", "nodes", v1.NamespaceAll, ""), testapi.Default.ResourcePathWithPrefix("watch", "nodes", metav1.NamespaceAll, ""),
buildQueryValues(url.Values{})), buildQueryValues(url.Values{})),
rv: "", rv: "",
resource: "nodes", resource: "nodes",
namespace: v1.NamespaceAll, namespace: metav1.NamespaceAll,
fieldSelector: parseSelectorOrDie(""), fieldSelector: parseSelectorOrDie(""),
}, },
{ {
location: buildLocation( location: buildLocation(
testapi.Default.ResourcePathWithPrefix("watch", "nodes", v1.NamespaceAll, ""), testapi.Default.ResourcePathWithPrefix("watch", "nodes", metav1.NamespaceAll, ""),
buildQueryValues(url.Values{"resourceVersion": []string{"42"}})), buildQueryValues(url.Values{"resourceVersion": []string{"42"}})),
rv: "42", rv: "42",
resource: "nodes", resource: "nodes",
namespace: v1.NamespaceAll, namespace: metav1.NamespaceAll,
fieldSelector: parseSelectorOrDie(""), fieldSelector: parseSelectorOrDie(""),
}, },
// pod with "assigned" field selector. // pod with "assigned" field selector.
{ {
location: buildLocation( location: buildLocation(
testapi.Default.ResourcePathWithPrefix("watch", "pods", v1.NamespaceAll, ""), testapi.Default.ResourcePathWithPrefix("watch", "pods", metav1.NamespaceAll, ""),
buildQueryValues(url.Values{fieldSelectorQueryParamName: []string{"spec.host="}, "resourceVersion": []string{"0"}})), buildQueryValues(url.Values{fieldSelectorQueryParamName: []string{"spec.host="}, "resourceVersion": []string{"0"}})),
rv: "0", rv: "0",
resource: "pods", resource: "pods",
namespace: v1.NamespaceAll, namespace: metav1.NamespaceAll,
fieldSelector: fields.Set{"spec.host": ""}.AsSelector(), fieldSelector: fields.Set{"spec.host": ""}.AsSelector(),
}, },
// pod with namespace foo and assigned field selector // pod with namespace foo and assigned field selector
@ -171,7 +171,7 @@ func TestListWatchesCanWatch(t *testing.T) {
client := clientset.NewForConfigOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &api.Registry.GroupOrDie(v1.GroupName).GroupVersion}}) client := clientset.NewForConfigOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &api.Registry.GroupOrDie(v1.GroupName).GroupVersion}})
lw := NewListWatchFromClient(client.Core().RESTClient(), item.resource, item.namespace, item.fieldSelector) lw := NewListWatchFromClient(client.Core().RESTClient(), item.resource, item.namespace, item.fieldSelector)
// This test merely tests that the correct request is made. // This test merely tests that the correct request is made.
lw.Watch(v1.ListOptions{ResourceVersion: item.rv}) lw.Watch(metav1.ListOptions{ResourceVersion: item.rv})
handler.ValidateRequest(t, item.location, "GET", nil) handler.ValidateRequest(t, item.location, "GET", nil)
} }
} }
@ -181,11 +181,11 @@ type lw struct {
watch watch.Interface watch watch.Interface
} }
func (w lw) List(options v1.ListOptions) (runtime.Object, error) { func (w lw) List(options metav1.ListOptions) (runtime.Object, error) {
return w.list, nil return w.list, nil
} }
func (w lw) Watch(options v1.ListOptions) (watch.Interface, error) { func (w lw) Watch(options metav1.ListOptions) (watch.Interface, error) {
return w.watch, nil return w.watch, nil
} }

View File

@ -31,10 +31,10 @@ import (
func TestMutationDetector(t *testing.T) { func TestMutationDetector(t *testing.T) {
fakeWatch := watch.NewFake() fakeWatch := watch.NewFake()
lw := &testLW{ lw := &testLW{
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return fakeWatch, nil return fakeWatch, nil
}, },
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return &v1.PodList{}, nil return &v1.PodList{}, nil
}, },
} }

View File

@ -34,14 +34,14 @@ import (
var nevererrc chan error var nevererrc chan error
type testLW struct { type testLW struct {
ListFunc func(options v1.ListOptions) (runtime.Object, error) ListFunc func(options metav1.ListOptions) (runtime.Object, error)
WatchFunc func(options v1.ListOptions) (watch.Interface, error) WatchFunc func(options metav1.ListOptions) (watch.Interface, error)
} }
func (t *testLW) List(options v1.ListOptions) (runtime.Object, error) { func (t *testLW) List(options metav1.ListOptions) (runtime.Object, error) {
return t.ListFunc(options) return t.ListFunc(options)
} }
func (t *testLW) Watch(options v1.ListOptions) (watch.Interface, error) { func (t *testLW) Watch(options metav1.ListOptions) (watch.Interface, error) {
return t.WatchFunc(options) return t.WatchFunc(options)
} }
@ -50,10 +50,10 @@ func TestCloseWatchChannelOnError(t *testing.T) {
pod := &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "bar"}} pod := &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "bar"}}
fw := watch.NewFake() fw := watch.NewFake()
r.listerWatcher = &testLW{ r.listerWatcher = &testLW{
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return fw, nil return fw, nil
}, },
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return &v1.PodList{ListMeta: metav1.ListMeta{ResourceVersion: "1"}}, nil return &v1.PodList{ListMeta: metav1.ListMeta{ResourceVersion: "1"}}, nil
}, },
} }
@ -76,10 +76,10 @@ func TestRunUntil(t *testing.T) {
r := NewReflector(&testLW{}, &v1.Pod{}, store, 0) r := NewReflector(&testLW{}, &v1.Pod{}, store, 0)
fw := watch.NewFake() fw := watch.NewFake()
r.listerWatcher = &testLW{ r.listerWatcher = &testLW{
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return fw, nil return fw, nil
}, },
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return &v1.PodList{ListMeta: metav1.ListMeta{ResourceVersion: "1"}}, nil return &v1.PodList{ListMeta: metav1.ListMeta{ResourceVersion: "1"}}, nil
}, },
} }
@ -215,7 +215,7 @@ func TestReflectorListAndWatch(t *testing.T) {
// inject an error. // inject an error.
expectedRVs := []string{"1", "3"} expectedRVs := []string{"1", "3"}
lw := &testLW{ lw := &testLW{
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
rv := options.ResourceVersion rv := options.ResourceVersion
fw := watch.NewFake() fw := watch.NewFake()
if e, a := expectedRVs[0], rv; e != a { if e, a := expectedRVs[0], rv; e != a {
@ -227,7 +227,7 @@ func TestReflectorListAndWatch(t *testing.T) {
go func() { createdFakes <- fw }() go func() { createdFakes <- fw }()
return fw, nil return fw, nil
}, },
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return &v1.PodList{ListMeta: metav1.ListMeta{ResourceVersion: "1"}}, nil return &v1.PodList{ListMeta: metav1.ListMeta{ResourceVersion: "1"}}, nil
}, },
} }
@ -331,7 +331,7 @@ func TestReflectorListAndWatchWithErrors(t *testing.T) {
} }
watchRet, watchErr := item.events, item.watchErr watchRet, watchErr := item.events, item.watchErr
lw := &testLW{ lw := &testLW{
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
if watchErr != nil { if watchErr != nil {
return nil, watchErr return nil, watchErr
} }
@ -345,7 +345,7 @@ func TestReflectorListAndWatchWithErrors(t *testing.T) {
}() }()
return fw, nil return fw, nil
}, },
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return item.list, item.listErr return item.list, item.listErr
}, },
} }
@ -369,11 +369,11 @@ func TestReflectorResync(t *testing.T) {
} }
lw := &testLW{ lw := &testLW{
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
fw := watch.NewFake() fw := watch.NewFake()
return fw, nil return fw, nil
}, },
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return &v1.PodList{ListMeta: metav1.ListMeta{ResourceVersion: "0"}}, nil return &v1.PodList{ListMeta: metav1.ListMeta{ResourceVersion: "0"}}, nil
}, },
} }

View File

@ -19,6 +19,7 @@ package v1
import ( import (
"fmt" "fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
@ -117,7 +118,7 @@ func (e *events) Search(objOrRef runtime.Object) (*v1.EventList, error) {
refUID = &stringRefUID refUID = &stringRefUID
} }
fieldSelector := e.GetFieldSelector(&ref.Name, &ref.Namespace, refKind, refUID) fieldSelector := e.GetFieldSelector(&ref.Name, &ref.Namespace, refKind, refUID)
return e.List(v1.ListOptions{FieldSelector: fieldSelector.String()}) return e.List(metav1.ListOptions{FieldSelector: fieldSelector.String()})
} }
// Returns the appropriate field selector based on the API version being used to communicate with the server. // Returns the appropriate field selector based on the API version being used to communicate with the server.

View File

@ -19,6 +19,7 @@ package internalversion
import ( import (
"fmt" "fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
@ -117,7 +118,7 @@ func (e *events) Search(objOrRef runtime.Object) (*api.EventList, error) {
refUID = &stringRefUID refUID = &stringRefUID
} }
fieldSelector := e.GetFieldSelector(&ref.Name, &ref.Namespace, refKind, refUID) fieldSelector := e.GetFieldSelector(&ref.Name, &ref.Namespace, refKind, refUID)
return e.List(api.ListOptions{FieldSelector: fieldSelector}) return e.List(metav1.ListOptions{FieldSelector: fieldSelector.String()})
} }
// Returns the appropriate field selector based on the API version being used to communicate with the server. // Returns the appropriate field selector based on the API version being used to communicate with the server.

View File

@ -17,6 +17,7 @@ limitations under the License.
package fake package fake
import ( import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
@ -66,9 +67,9 @@ func (c *FakeEvents) PatchWithEventNamespace(event *api.Event, data []byte) (*ap
// Search returns a list of events matching the specified object. // Search returns a list of events matching the specified object.
func (c *FakeEvents) Search(objOrRef runtime.Object) (*api.EventList, error) { func (c *FakeEvents) Search(objOrRef runtime.Object) (*api.EventList, error) {
action := core.NewRootListAction(eventsResource, api.ListOptions{}) action := core.NewRootListAction(eventsResource, metav1.ListOptions{})
if c.ns != "" { if c.ns != "" {
action = core.NewListAction(eventsResource, c.ns, api.ListOptions{}) action = core.NewListAction(eventsResource, c.ns, metav1.ListOptions{})
} }
obj, err := c.Fake.Invokes(action, &api.EventList{}) obj, err := c.Fake.Invokes(action, &api.EventList{})
if obj == nil { if obj == nil {

View File

@ -144,7 +144,7 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
}, },
}, },
list: func(lister StoreToReplicationControllerLister) ([]*v1.ReplicationController, error) { list: func(lister StoreToReplicationControllerLister) ([]*v1.ReplicationController, error) {
return lister.ReplicationControllers(v1.NamespaceAll).List(labels.Set{}.AsSelectorPreValidated()) return lister.ReplicationControllers(metav1.NamespaceAll).List(labels.Set{}.AsSelectorPreValidated())
}, },
outRCNames: sets.NewString("hmm", "foo"), outRCNames: sets.NewString("hmm", "foo"),
}, },
@ -539,14 +539,14 @@ func TestStoreToPodLister(t *testing.T) {
store.Add(&v1.Pod{ store.Add(&v1.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "quux", Name: "quux",
Namespace: v1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
Labels: map[string]string{"name": "quux"}, Labels: map[string]string{"name": "quux"},
}, },
}) })
spl := StoreToPodLister{store} spl := StoreToPodLister{store}
// Verify that we can always look up by Namespace. // Verify that we can always look up by Namespace.
defaultPods, err := spl.Pods(v1.NamespaceDefault).List(labels.Set{}.AsSelectorPreValidated()) defaultPods, err := spl.Pods(metav1.NamespaceDefault).List(labels.Set{}.AsSelectorPreValidated())
if err != nil { if err != nil {
t.Errorf("Unexpected error: %v", err) t.Errorf("Unexpected error: %v", err)
} else if e, a := 1, len(defaultPods); e != a { } else if e, a := 1, len(defaultPods); e != a {

View File

@ -298,7 +298,7 @@ func (recorder *recorderImpl) makeEvent(ref *v1.ObjectReference, eventtype, reas
t := metav1.Time{Time: recorder.clock.Now()} t := metav1.Time{Time: recorder.clock.Now()}
namespace := ref.Namespace namespace := ref.Namespace
if namespace == "" { if namespace == "" {
namespace = v1.NamespaceDefault namespace = metav1.NamespaceDefault
} }
return &v1.Event{ return &v1.Event{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{

View File

@ -163,7 +163,7 @@ func (f *FakeControllerSource) getListItemsLocked() ([]runtime.Object, error) {
} }
// List returns a list object, with its resource version set. // List returns a list object, with its resource version set.
func (f *FakeControllerSource) List(options v1.ListOptions) (runtime.Object, error) { func (f *FakeControllerSource) List(options metav1.ListOptions) (runtime.Object, error) {
f.lock.RLock() f.lock.RLock()
defer f.lock.RUnlock() defer f.lock.RUnlock()
list, err := f.getListItemsLocked() list, err := f.getListItemsLocked()
@ -184,7 +184,7 @@ func (f *FakeControllerSource) List(options v1.ListOptions) (runtime.Object, err
} }
// List returns a list object, with its resource version set. // List returns a list object, with its resource version set.
func (f *FakePVControllerSource) List(options v1.ListOptions) (runtime.Object, error) { func (f *FakePVControllerSource) List(options metav1.ListOptions) (runtime.Object, error) {
f.lock.RLock() f.lock.RLock()
defer f.lock.RUnlock() defer f.lock.RUnlock()
list, err := f.FakeControllerSource.getListItemsLocked() list, err := f.FakeControllerSource.getListItemsLocked()
@ -205,7 +205,7 @@ func (f *FakePVControllerSource) List(options v1.ListOptions) (runtime.Object, e
} }
// List returns a list object, with its resource version set. // List returns a list object, with its resource version set.
func (f *FakePVCControllerSource) List(options v1.ListOptions) (runtime.Object, error) { func (f *FakePVCControllerSource) List(options metav1.ListOptions) (runtime.Object, error) {
f.lock.RLock() f.lock.RLock()
defer f.lock.RUnlock() defer f.lock.RUnlock()
list, err := f.FakeControllerSource.getListItemsLocked() list, err := f.FakeControllerSource.getListItemsLocked()
@ -227,7 +227,7 @@ func (f *FakePVCControllerSource) List(options v1.ListOptions) (runtime.Object,
// Watch returns a watch, which will be pre-populated with all changes // Watch returns a watch, which will be pre-populated with all changes
// after resourceVersion. // after resourceVersion.
func (f *FakeControllerSource) Watch(options v1.ListOptions) (watch.Interface, error) { func (f *FakeControllerSource) Watch(options metav1.ListOptions) (watch.Interface, error) {
f.lock.RLock() f.lock.RLock()
defer f.lock.RUnlock() defer f.lock.RUnlock()
rc, err := strconv.Atoi(options.ResourceVersion) rc, err := strconv.Atoi(options.ResourceVersion)

View File

@ -66,13 +66,13 @@ func TestRCNumber(t *testing.T) {
source.Modify(pod("foo")) source.Modify(pod("foo"))
source.Modify(pod("foo")) source.Modify(pod("foo"))
w, err := source.Watch(v1.ListOptions{ResourceVersion: "1"}) w, err := source.Watch(metav1.ListOptions{ResourceVersion: "1"})
if err != nil { if err != nil {
t.Fatalf("Unexpected error: %v", err) t.Fatalf("Unexpected error: %v", err)
} }
go consume(t, w, []string{"2", "3"}, wg) go consume(t, w, []string{"2", "3"}, wg)
list, err := source.List(v1.ListOptions{}) list, err := source.List(metav1.ListOptions{})
if err != nil { if err != nil {
t.Fatalf("Unexpected error: %v", err) t.Fatalf("Unexpected error: %v", err)
} }
@ -80,13 +80,13 @@ func TestRCNumber(t *testing.T) {
t.Errorf("wanted %v, got %v", e, a) t.Errorf("wanted %v, got %v", e, a)
} }
w2, err := source.Watch(v1.ListOptions{ResourceVersion: "2"}) w2, err := source.Watch(metav1.ListOptions{ResourceVersion: "2"})
if err != nil { if err != nil {
t.Fatalf("Unexpected error: %v", err) t.Fatalf("Unexpected error: %v", err)
} }
go consume(t, w2, []string{"3"}, wg) go consume(t, w2, []string{"3"}, wg)
w3, err := source.Watch(v1.ListOptions{ResourceVersion: "3"}) w3, err := source.Watch(metav1.ListOptions{ResourceVersion: "3"})
if err != nil { if err != nil {
t.Fatalf("Unexpected error: %v", err) t.Fatalf("Unexpected error: %v", err)
} }

View File

@ -21,12 +21,11 @@ import (
"path" "path"
"strings" "strings"
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/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1"
) )
func NewRootGetAction(resource schema.GroupVersionResource, name string) GetActionImpl { func NewRootGetAction(resource schema.GroupVersionResource, name string) GetActionImpl {
@ -224,22 +223,18 @@ func NewRootWatchAction(resource schema.GroupVersionResource, opts interface{})
func ExtractFromListOptions(opts interface{}) (labelSelector labels.Selector, fieldSelector fields.Selector, resourceVersion string) { func ExtractFromListOptions(opts interface{}) (labelSelector labels.Selector, fieldSelector fields.Selector, resourceVersion string) {
var err error var err error
switch t := opts.(type) { switch t := opts.(type) {
case api.ListOptions: case metav1.ListOptions:
labelSelector = t.LabelSelector
fieldSelector = t.FieldSelector
resourceVersion = t.ResourceVersion
case v1.ListOptions:
labelSelector, err = labels.Parse(t.LabelSelector) labelSelector, err = labels.Parse(t.LabelSelector)
if err != nil { if err != nil {
panic(err) panic(fmt.Errorf("invalid selector %q: %v", t.LabelSelector, err))
} }
fieldSelector, err = fields.ParseSelector(t.FieldSelector) fieldSelector, err = fields.ParseSelector(t.FieldSelector)
if err != nil { if err != nil {
panic(err) panic(fmt.Errorf("invalid selector %q: %v", t.FieldSelector, err))
} }
resourceVersion = t.ResourceVersion resourceVersion = t.ResourceVersion
default: default:
panic(fmt.Errorf("expect a ListOptions")) panic(fmt.Errorf("expect a ListOptions %T", opts))
} }
if labelSelector == nil { if labelSelector == nil {
labelSelector = labels.Everything() labelSelector = labels.Everything()

View File

@ -35,7 +35,7 @@ func TestFakeClientSetFiltering(t *testing.T) {
testSA("nsB", "sa-3"), testSA("nsB", "sa-3"),
) )
saList1, err := tc.Core().ServiceAccounts("nsA").List(api.ListOptions{}) saList1, err := tc.Core().ServiceAccounts("nsA").List(metav1.ListOptions{})
if err != nil { if err != nil {
t.Fatalf("ServiceAccounts.List: %s", err) t.Fatalf("ServiceAccounts.List: %s", err)
} }
@ -48,7 +48,7 @@ func TestFakeClientSetFiltering(t *testing.T) {
} }
} }
saList2, err := tc.Core().ServiceAccounts("nsB").List(api.ListOptions{}) saList2, err := tc.Core().ServiceAccounts("nsB").List(metav1.ListOptions{})
if err != nil { if err != nil {
t.Fatalf("ServiceAccounts.List: %s", err) t.Fatalf("ServiceAccounts.List: %s", err)
} }
@ -77,7 +77,7 @@ func TestFakeClientSetFiltering(t *testing.T) {
t.Fatalf("Pods.Get: expected nsB/pod-1 not to match, but it matched %s/%s", wrongPod.Namespace, wrongPod.Name) t.Fatalf("Pods.Get: expected nsB/pod-1 not to match, but it matched %s/%s", wrongPod.Namespace, wrongPod.Name)
} }
allPods, err := tc.Core().Pods(api.NamespaceAll).List(api.ListOptions{}) allPods, err := tc.Core().Pods(metav1.NamespaceAll).List(metav1.ListOptions{})
if err != nil { if err != nil {
t.Fatalf("Pods.List: %s", err) t.Fatalf("Pods.List: %s", err)
} }
@ -85,7 +85,7 @@ func TestFakeClientSetFiltering(t *testing.T) {
t.Fatalf("Expected %d pods to match, got %d", expected, actual) t.Fatalf("Expected %d pods to match, got %d", expected, actual)
} }
allSAs, err := tc.Core().ServiceAccounts(api.NamespaceAll).List(api.ListOptions{}) allSAs, err := tc.Core().ServiceAccounts(metav1.NamespaceAll).List(metav1.ListOptions{})
if err != nil { if err != nil {
t.Fatalf("ServiceAccounts.List: %s", err) t.Fatalf("ServiceAccounts.List: %s", err)
} }
@ -105,7 +105,7 @@ func TestFakeClientsetInheritsNamespace(t *testing.T) {
t.Fatalf("Namespaces.Create: %s", err) t.Fatalf("Namespaces.Create: %s", err)
} }
allNS, err := tc.Core().Namespaces().List(api.ListOptions{}) allNS, err := tc.Core().Namespaces().List(metav1.ListOptions{})
if err != nil { if err != nil {
t.Fatalf("Namespaces.List: %s", err) t.Fatalf("Namespaces.List: %s", err)
} }

View File

@ -34,7 +34,6 @@ import (
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
restclient "k8s.io/client-go/rest" restclient "k8s.io/client-go/rest"
restclientwatch "k8s.io/client-go/rest/watch" restclientwatch "k8s.io/client-go/rest/watch"
"k8s.io/kubernetes/pkg/api/v1"
) )
func getJSON(version, kind, name string) []byte { func getJSON(version, kind, name string) []byte {
@ -137,7 +136,7 @@ func TestList(t *testing.T) {
} }
defer srv.Close() defer srv.Close()
got, err := cl.Resource(resource, tc.namespace).List(&v1.ListOptions{}) got, err := cl.Resource(resource, tc.namespace).List(&metav1.ListOptions{})
if err != nil { if err != nil {
t.Errorf("unexpected error when listing %q: %v", tc.name, err) t.Errorf("unexpected error when listing %q: %v", tc.name, err)
continue continue
@ -294,7 +293,7 @@ func TestDeleteCollection(t *testing.T) {
} }
defer srv.Close() defer srv.Close()
err = cl.Resource(resource, tc.namespace).DeleteCollection(nil, &v1.ListOptions{}) err = cl.Resource(resource, tc.namespace).DeleteCollection(nil, &metav1.ListOptions{})
if err != nil { if err != nil {
t.Errorf("unexpected error when deleting collection %q: %v", tc.name, err) t.Errorf("unexpected error when deleting collection %q: %v", tc.name, err)
continue continue
@ -470,7 +469,7 @@ func TestWatch(t *testing.T) {
} }
defer srv.Close() defer srv.Close()
watcher, err := cl.Resource(resource, tc.namespace).Watch(&v1.ListOptions{}) watcher, err := cl.Resource(resource, tc.namespace).Watch(&metav1.ListOptions{})
if err != nil { if err != nil {
t.Errorf("unexpected error when watching %q: %v", tc.name, err) t.Errorf("unexpected error when watching %q: %v", tc.name, err)
continue continue

View File

@ -20,11 +20,11 @@ import (
"fmt" "fmt"
"time" "time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
"k8s.io/kubernetes/pkg/api/v1"
certificates "k8s.io/kubernetes/pkg/apis/certificates/v1beta1" certificates "k8s.io/kubernetes/pkg/apis/certificates/v1beta1"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" "k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
@ -81,10 +81,10 @@ func NewCertificateController(kubeClient clientset.Interface, syncPeriod time.Du
// Manage the addition/update of certificate requests // Manage the addition/update of certificate requests
cc.csrStore.Store, cc.csrController = cache.NewInformer( cc.csrStore.Store, cc.csrController = cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return cc.kubeClient.Certificates().CertificateSigningRequests().List(options) return cc.kubeClient.Certificates().CertificateSigningRequests().List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return cc.kubeClient.Certificates().CertificateSigningRequests().Watch(options) return cc.kubeClient.Certificates().CertificateSigningRequests().Watch(options)
}, },
}, },

View File

@ -89,7 +89,7 @@ func (cnc *CloudNodeController) Run() {
defer utilruntime.HandleCrash() defer utilruntime.HandleCrash()
go wait.Until(func() { go wait.Until(func() {
nodes, err := cnc.kubeClient.Core().Nodes().List(v1.ListOptions{ResourceVersion: "0"}) nodes, err := cnc.kubeClient.Core().Nodes().List(metav1.ListOptions{ResourceVersion: "0"})
if err != nil { if err != nil {
glog.Errorf("Error monitoring node status: %v", err) glog.Errorf("Error monitoring node status: %v", err)
} }

View File

@ -59,7 +59,7 @@ func newReplicationController(replicas int) *v1.ReplicationController {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
UID: uuid.NewUUID(), UID: uuid.NewUUID(),
Name: "foobar", Name: "foobar",
Namespace: v1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "18", ResourceVersion: "18",
}, },
Spec: v1.ReplicationControllerSpec{ Spec: v1.ReplicationControllerSpec{
@ -238,7 +238,7 @@ func TestUIDExpectations(t *testing.T) {
} }
func TestCreatePods(t *testing.T) { func TestCreatePods(t *testing.T) {
ns := v1.NamespaceDefault ns := metav1.NamespaceDefault
body := runtime.EncodeOrDie(testapi.Default.Codec(), &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "empty_pod"}}) body := runtime.EncodeOrDie(testapi.Default.Codec(), &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "empty_pod"}})
fakeHandler := utiltesting.FakeHandler{ fakeHandler := utiltesting.FakeHandler{
StatusCode: 200, StatusCode: 200,
@ -267,7 +267,7 @@ func TestCreatePods(t *testing.T) {
}, },
Spec: controllerSpec.Spec.Template.Spec, Spec: controllerSpec.Spec.Template.Spec,
} }
fakeHandler.ValidateRequest(t, testapi.Default.ResourcePath("pods", v1.NamespaceDefault, ""), "POST", nil) fakeHandler.ValidateRequest(t, testapi.Default.ResourcePath("pods", metav1.NamespaceDefault, ""), "POST", nil)
var actualPod = &v1.Pod{} var actualPod = &v1.Pod{}
err := json.Unmarshal([]byte(fakeHandler.RequestBody), actualPod) err := json.Unmarshal([]byte(fakeHandler.RequestBody), actualPod)
if err != nil { if err != nil {

View File

@ -130,7 +130,7 @@ func newJob(UID string) batch.Job {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
UID: types.UID(UID), UID: types.UID(UID),
Name: "foobar", Name: "foobar",
Namespace: v1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
SelfLink: "/apis/batch/v1/namespaces/snazzycats/jobs/myjob", SelfLink: "/apis/batch/v1/namespaces/snazzycats/jobs/myjob",
}, },
Spec: jobSpec(), Spec: jobSpec(),

View File

@ -101,7 +101,7 @@ func TestGetParentUIDFromJob(t *testing.T) {
j := &batch.Job{ j := &batch.Job{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "foobar", Name: "foobar",
Namespace: v1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: batch.JobSpec{ Spec: batch.JobSpec{
Selector: &metav1.LabelSelector{ Selector: &metav1.LabelSelector{
@ -269,7 +269,7 @@ func TestGetRecentUnmetScheduleTimes(t *testing.T) {
sj := batch.CronJob{ sj := batch.CronJob{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "mycronjob", Name: "mycronjob",
Namespace: v1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
UID: types.UID("1a2b3c"), UID: types.UID("1a2b3c"),
}, },
Spec: batch.CronJobSpec{ Spec: batch.CronJobSpec{

View File

@ -58,7 +58,7 @@ func newDaemonSet(name string) *extensions.DaemonSet {
TypeMeta: metav1.TypeMeta{APIVersion: testapi.Extensions.GroupVersion().String()}, TypeMeta: metav1.TypeMeta{APIVersion: testapi.Extensions.GroupVersion().String()},
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: name, Name: name,
Namespace: v1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: simpleDaemonSetLabel}, Selector: &metav1.LabelSelector{MatchLabels: simpleDaemonSetLabel},
@ -88,7 +88,7 @@ func newNode(name string, label map[string]string) *v1.Node {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: name, Name: name,
Labels: label, Labels: label,
Namespace: v1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Status: v1.NodeStatus{ Status: v1.NodeStatus{
Conditions: []v1.NodeCondition{ Conditions: []v1.NodeCondition{
@ -113,7 +113,7 @@ func newPod(podName string, nodeName string, label map[string]string) *v1.Pod {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
GenerateName: podName, GenerateName: podName,
Labels: label, Labels: label,
Namespace: v1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: v1.PodSpec{ Spec: v1.PodSpec{
NodeName: nodeName, NodeName: nodeName,
@ -377,7 +377,7 @@ func TestPortConflictWithSameDaemonPodDoesNotDeletePod(t *testing.T) {
manager.podStore.Indexer.Add(&v1.Pod{ manager.podStore.Indexer.Add(&v1.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: simpleDaemonSetLabel, Labels: simpleDaemonSetLabel,
Namespace: v1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: podSpec, Spec: podSpec,
}) })
@ -427,7 +427,7 @@ func TestPodIsNotDeletedByDaemonsetWithEmptyLabelSelector(t *testing.T) {
manager.podStore.Indexer.Add(&v1.Pod{ manager.podStore.Indexer.Add(&v1.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{"bang": "boom"}, Labels: map[string]string{"bang": "boom"},
Namespace: v1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: v1.PodSpec{ Spec: v1.PodSpec{
NodeName: "node1", NodeName: "node1",

View File

@ -47,7 +47,7 @@ func rs(name string, replicas int, selector map[string]string, timestamp metav1.
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: name, Name: name,
CreationTimestamp: timestamp, CreationTimestamp: timestamp,
Namespace: v1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
Replicas: func() *int32 { i := int32(replicas); return &i }(), Replicas: func() *int32 { i := int32(replicas); return &i }(),
@ -71,7 +71,7 @@ func newDeployment(name string, replicas int, revisionHistoryLimit *int32, maxSu
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
UID: uuid.NewUUID(), UID: uuid.NewUUID(),
Name: name, Name: name,
Namespace: v1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
Annotations: make(map[string]string), Annotations: make(map[string]string),
}, },
Spec: extensions.DeploymentSpec{ Spec: extensions.DeploymentSpec{
@ -112,7 +112,7 @@ func newReplicaSet(d *extensions.Deployment, name string, replicas int) *extensi
return &extensions.ReplicaSet{ return &extensions.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: name, Name: name,
Namespace: v1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
Labels: d.Spec.Selector.MatchLabels, Labels: d.Spec.Selector.MatchLabels,
}, },
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{

View File

@ -127,7 +127,7 @@ func (dc *DeploymentController) getAllReplicaSetsAndSyncRevision(deployment *ext
// rsAndPodsWithHashKeySynced returns the RSes and pods the given deployment targets, with pod-template-hash information synced. // rsAndPodsWithHashKeySynced returns the RSes and pods the given deployment targets, with pod-template-hash information synced.
func (dc *DeploymentController) rsAndPodsWithHashKeySynced(deployment *extensions.Deployment) ([]*extensions.ReplicaSet, *v1.PodList, error) { func (dc *DeploymentController) rsAndPodsWithHashKeySynced(deployment *extensions.Deployment) ([]*extensions.ReplicaSet, *v1.PodList, error) {
rsList, err := deploymentutil.ListReplicaSets(deployment, rsList, err := deploymentutil.ListReplicaSets(deployment,
func(namespace string, options v1.ListOptions) ([]*extensions.ReplicaSet, error) { func(namespace string, options metav1.ListOptions) ([]*extensions.ReplicaSet, error) {
parsed, err := labels.Parse(options.LabelSelector) parsed, err := labels.Parse(options.LabelSelector)
if err != nil { if err != nil {
return nil, err return nil, err
@ -191,7 +191,7 @@ func (dc *DeploymentController) addHashKeyToRSAndPods(rs *extensions.ReplicaSet)
if err != nil { if err != nil {
return nil, fmt.Errorf("error in converting selector to label selector for replica set %s: %s", updatedRS.Name, err) return nil, fmt.Errorf("error in converting selector to label selector for replica set %s: %s", updatedRS.Name, err)
} }
options := v1.ListOptions{LabelSelector: selector.String()} options := metav1.ListOptions{LabelSelector: selector.String()}
parsed, err := labels.Parse(options.LabelSelector) parsed, err := labels.Parse(options.LabelSelector)
if err != nil { if err != nil {
return nil, err return nil, err
@ -240,7 +240,7 @@ func (dc *DeploymentController) addHashKeyToRSAndPods(rs *extensions.ReplicaSet)
func (dc *DeploymentController) listPods(deployment *extensions.Deployment) (*v1.PodList, error) { func (dc *DeploymentController) listPods(deployment *extensions.Deployment) (*v1.PodList, error) {
return deploymentutil.ListPods(deployment, return deploymentutil.ListPods(deployment,
func(namespace string, options v1.ListOptions) (*v1.PodList, error) { func(namespace string, options metav1.ListOptions) (*v1.PodList, error) {
parsed, err := labels.Parse(options.LabelSelector) parsed, err := labels.Parse(options.LabelSelector)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -537,7 +537,7 @@ func GetNewReplicaSet(deployment *extensions.Deployment, c clientset.Interface)
// listReplicaSets lists all RSes the given deployment targets with the given client interface. // listReplicaSets lists all RSes the given deployment targets with the given client interface.
func listReplicaSets(deployment *extensions.Deployment, c clientset.Interface) ([]*extensions.ReplicaSet, error) { func listReplicaSets(deployment *extensions.Deployment, c clientset.Interface) ([]*extensions.ReplicaSet, error) {
return ListReplicaSets(deployment, return ListReplicaSets(deployment,
func(namespace string, options v1.ListOptions) ([]*extensions.ReplicaSet, error) { func(namespace string, options metav1.ListOptions) ([]*extensions.ReplicaSet, error) {
rsList, err := c.Extensions().ReplicaSets(namespace).List(options) rsList, err := c.Extensions().ReplicaSets(namespace).List(options)
if err != nil { if err != nil {
return nil, err return nil, err
@ -553,14 +553,14 @@ func listReplicaSets(deployment *extensions.Deployment, c clientset.Interface) (
// listReplicaSets lists all Pods the given deployment targets with the given client interface. // listReplicaSets lists all Pods the given deployment targets with the given client interface.
func listPods(deployment *extensions.Deployment, c clientset.Interface) (*v1.PodList, error) { func listPods(deployment *extensions.Deployment, c clientset.Interface) (*v1.PodList, error) {
return ListPods(deployment, return ListPods(deployment,
func(namespace string, options v1.ListOptions) (*v1.PodList, error) { func(namespace string, options metav1.ListOptions) (*v1.PodList, error) {
return c.Core().Pods(namespace).List(options) return c.Core().Pods(namespace).List(options)
}) })
} }
// TODO: switch this to full namespacers // TODO: switch this to full namespacers
type rsListFunc func(string, v1.ListOptions) ([]*extensions.ReplicaSet, error) type rsListFunc func(string, metav1.ListOptions) ([]*extensions.ReplicaSet, error)
type podListFunc func(string, v1.ListOptions) (*v1.PodList, error) type podListFunc func(string, metav1.ListOptions) (*v1.PodList, error)
// ListReplicaSets returns a slice of RSes the given deployment targets. // ListReplicaSets returns a slice of RSes the given deployment targets.
func ListReplicaSets(deployment *extensions.Deployment, getRSList rsListFunc) ([]*extensions.ReplicaSet, error) { func ListReplicaSets(deployment *extensions.Deployment, getRSList rsListFunc) ([]*extensions.ReplicaSet, error) {
@ -572,7 +572,7 @@ func ListReplicaSets(deployment *extensions.Deployment, getRSList rsListFunc) ([
if err != nil { if err != nil {
return nil, err return nil, err
} }
options := v1.ListOptions{LabelSelector: selector.String()} options := metav1.ListOptions{LabelSelector: selector.String()}
return getRSList(namespace, options) return getRSList(namespace, options)
} }
@ -583,7 +583,7 @@ func ListPods(deployment *extensions.Deployment, getPodList podListFunc) (*v1.Po
if err != nil { if err != nil {
return nil, err return nil, err
} }
options := v1.ListOptions{LabelSelector: selector.String()} options := metav1.ListOptions{LabelSelector: selector.String()}
return getPodList(namespace, options) return getPodList(namespace, options)
} }

View File

@ -129,11 +129,11 @@ func NewDisruptionController(podInformer cache.SharedIndexInformer, kubeClient c
dc.pdbStore, dc.pdbController = cache.NewInformer( dc.pdbStore, dc.pdbController = cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return dc.kubeClient.Policy().PodDisruptionBudgets(v1.NamespaceAll).List(options) return dc.kubeClient.Policy().PodDisruptionBudgets(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return dc.kubeClient.Policy().PodDisruptionBudgets(v1.NamespaceAll).Watch(options) return dc.kubeClient.Policy().PodDisruptionBudgets(metav1.NamespaceAll).Watch(options)
}, },
}, },
&policy.PodDisruptionBudget{}, &policy.PodDisruptionBudget{},
@ -148,11 +148,11 @@ func NewDisruptionController(podInformer cache.SharedIndexInformer, kubeClient c
dc.rcIndexer, dc.rcController = cache.NewIndexerInformer( dc.rcIndexer, dc.rcController = cache.NewIndexerInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return dc.kubeClient.Core().ReplicationControllers(v1.NamespaceAll).List(options) return dc.kubeClient.Core().ReplicationControllers(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return dc.kubeClient.Core().ReplicationControllers(v1.NamespaceAll).Watch(options) return dc.kubeClient.Core().ReplicationControllers(metav1.NamespaceAll).Watch(options)
}, },
}, },
&v1.ReplicationController{}, &v1.ReplicationController{},
@ -165,11 +165,11 @@ func NewDisruptionController(podInformer cache.SharedIndexInformer, kubeClient c
dc.rsLister.Indexer, dc.rsController = cache.NewIndexerInformer( dc.rsLister.Indexer, dc.rsController = cache.NewIndexerInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return dc.kubeClient.Extensions().ReplicaSets(v1.NamespaceAll).List(options) return dc.kubeClient.Extensions().ReplicaSets(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return dc.kubeClient.Extensions().ReplicaSets(v1.NamespaceAll).Watch(options) return dc.kubeClient.Extensions().ReplicaSets(metav1.NamespaceAll).Watch(options)
}, },
}, },
&extensions.ReplicaSet{}, &extensions.ReplicaSet{},
@ -181,11 +181,11 @@ func NewDisruptionController(podInformer cache.SharedIndexInformer, kubeClient c
dc.dIndexer, dc.dController = cache.NewIndexerInformer( dc.dIndexer, dc.dController = cache.NewIndexerInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return dc.kubeClient.Extensions().Deployments(v1.NamespaceAll).List(options) return dc.kubeClient.Extensions().Deployments(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return dc.kubeClient.Extensions().Deployments(v1.NamespaceAll).Watch(options) return dc.kubeClient.Extensions().Deployments(metav1.NamespaceAll).Watch(options)
}, },
}, },
&extensions.Deployment{}, &extensions.Deployment{},
@ -197,11 +197,11 @@ func NewDisruptionController(podInformer cache.SharedIndexInformer, kubeClient c
dc.ssStore, dc.ssController = cache.NewInformer( dc.ssStore, dc.ssController = cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return dc.kubeClient.Apps().StatefulSets(v1.NamespaceAll).List(options) return dc.kubeClient.Apps().StatefulSets(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return dc.kubeClient.Apps().StatefulSets(v1.NamespaceAll).Watch(options) return dc.kubeClient.Apps().StatefulSets(metav1.NamespaceAll).Watch(options)
}, },
}, },
&apps.StatefulSet{}, &apps.StatefulSet{},

View File

@ -122,7 +122,7 @@ func newPodDisruptionBudget(t *testing.T, minAvailable intstr.IntOrString) (*pol
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
UID: uuid.NewUUID(), UID: uuid.NewUUID(),
Name: "foobar", Name: "foobar",
Namespace: v1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "18", ResourceVersion: "18",
}, },
Spec: policy.PodDisruptionBudgetSpec{ Spec: policy.PodDisruptionBudgetSpec{
@ -146,7 +146,7 @@ func newPod(t *testing.T, name string) (*v1.Pod, string) {
UID: uuid.NewUUID(), UID: uuid.NewUUID(),
Annotations: make(map[string]string), Annotations: make(map[string]string),
Name: name, Name: name,
Namespace: v1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "18", ResourceVersion: "18",
Labels: fooBar(), Labels: fooBar(),
}, },
@ -172,7 +172,7 @@ func newReplicationController(t *testing.T, size int32) (*v1.ReplicationControll
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
UID: uuid.NewUUID(), UID: uuid.NewUUID(),
Name: "foobar", Name: "foobar",
Namespace: v1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "18", ResourceVersion: "18",
Labels: fooBar(), Labels: fooBar(),
}, },
@ -196,7 +196,7 @@ func newDeployment(t *testing.T, size int32) (*extensions.Deployment, string) {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
UID: uuid.NewUUID(), UID: uuid.NewUUID(),
Name: "foobar", Name: "foobar",
Namespace: v1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "18", ResourceVersion: "18",
Labels: fooBar(), Labels: fooBar(),
}, },
@ -220,7 +220,7 @@ func newReplicaSet(t *testing.T, size int32) (*extensions.ReplicaSet, string) {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
UID: uuid.NewUUID(), UID: uuid.NewUUID(),
Name: "foobar", Name: "foobar",
Namespace: v1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "18", ResourceVersion: "18",
Labels: fooBar(), Labels: fooBar(),
}, },
@ -244,7 +244,7 @@ func newStatefulSet(t *testing.T, size int32) (*apps.StatefulSet, string) {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
UID: uuid.NewUUID(), UID: uuid.NewUUID(),
Name: "foobar", Name: "foobar",
Namespace: v1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "18", ResourceVersion: "18",
Labels: fooBar(), Labels: fooBar(),
}, },

View File

@ -84,11 +84,11 @@ func NewEndpointController(podInformer cache.SharedIndexInformer, client clients
e.serviceStore.Indexer, e.serviceController = cache.NewIndexerInformer( e.serviceStore.Indexer, e.serviceController = cache.NewIndexerInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return e.client.Core().Services(v1.NamespaceAll).List(options) return e.client.Core().Services(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return e.client.Core().Services(v1.NamespaceAll).Watch(options) return e.client.Core().Services(metav1.NamespaceAll).Watch(options)
}, },
}, },
&v1.Service{}, &v1.Service{},
@ -503,7 +503,7 @@ func (e *EndpointController) syncService(key string) error {
// some stragglers could have been left behind if the endpoint controller // some stragglers could have been left behind if the endpoint controller
// reboots). // reboots).
func (e *EndpointController) checkLeftoverEndpoints() { func (e *EndpointController) checkLeftoverEndpoints() {
list, err := e.client.Core().Endpoints(v1.NamespaceAll).List(v1.ListOptions{}) list, err := e.client.Core().Endpoints(metav1.NamespaceAll).List(metav1.ListOptions{})
if err != nil { if err != nil {
utilruntime.HandleError(fmt.Errorf("Unable to list endpoints (%v); orphaned endpoints will not be cleaned up. (They're pretty harmless, but you can restart this component if you want another attempt made.)", err)) utilruntime.HandleError(fmt.Errorf("Unable to list endpoints (%v); orphaned endpoints will not be cleaned up. (They're pretty harmless, but you can restart this component if you want another attempt made.)", err))
return return

View File

@ -93,7 +93,7 @@ func makeTestServer(t *testing.T, namespace string, endpointsResponse serverResp
} }
func TestSyncEndpointsItemsPreserveNoSelector(t *testing.T) { func TestSyncEndpointsItemsPreserveNoSelector(t *testing.T) {
ns := v1.NamespaceDefault ns := metav1.NamespaceDefault
testServer, endpointsHandler := makeTestServer(t, ns, testServer, endpointsHandler := makeTestServer(t, ns,
serverResponse{http.StatusOK, &v1.Endpoints{ serverResponse{http.StatusOK, &v1.Endpoints{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
@ -119,10 +119,10 @@ func TestSyncEndpointsItemsPreserveNoSelector(t *testing.T) {
} }
func TestCheckLeftoverEndpoints(t *testing.T) { func TestCheckLeftoverEndpoints(t *testing.T) {
ns := v1.NamespaceDefault ns := metav1.NamespaceDefault
// Note that this requests *all* endpoints, therefore the NamespaceAll // Note that this requests *all* endpoints, therefore metav1.NamespaceAll
// below. // below.
testServer, _ := makeTestServer(t, v1.NamespaceAll, testServer, _ := makeTestServer(t, metav1.NamespaceAll,
serverResponse{http.StatusOK, &v1.EndpointsList{ serverResponse{http.StatusOK, &v1.EndpointsList{
ListMeta: metav1.ListMeta{ ListMeta: metav1.ListMeta{
ResourceVersion: "1", ResourceVersion: "1",
@ -396,8 +396,8 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
} }
func TestSyncEndpointsItemsPreexistingIdentical(t *testing.T) { func TestSyncEndpointsItemsPreexistingIdentical(t *testing.T) {
ns := v1.NamespaceDefault ns := metav1.NamespaceDefault
testServer, endpointsHandler := makeTestServer(t, v1.NamespaceDefault, testServer, endpointsHandler := makeTestServer(t, metav1.NamespaceDefault,
serverResponse{http.StatusOK, &v1.Endpoints{ serverResponse{http.StatusOK, &v1.Endpoints{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
ResourceVersion: "1", ResourceVersion: "1",
@ -413,16 +413,16 @@ func TestSyncEndpointsItemsPreexistingIdentical(t *testing.T) {
client := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &api.Registry.GroupOrDie(v1.GroupName).GroupVersion}}) client := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &api.Registry.GroupOrDie(v1.GroupName).GroupVersion}})
endpoints := NewEndpointControllerFromClient(client, controller.NoResyncPeriodFunc) endpoints := NewEndpointControllerFromClient(client, controller.NoResyncPeriodFunc)
endpoints.podStoreSynced = alwaysReady endpoints.podStoreSynced = alwaysReady
addPods(endpoints.podStore.Indexer, v1.NamespaceDefault, 1, 1, 0) addPods(endpoints.podStore.Indexer, metav1.NamespaceDefault, 1, 1, 0)
endpoints.serviceStore.Indexer.Add(&v1.Service{ endpoints.serviceStore.Indexer.Add(&v1.Service{
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: v1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: metav1.NamespaceDefault},
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Selector: map[string]string{"foo": "bar"}, Selector: map[string]string{"foo": "bar"},
Ports: []v1.ServicePort{{Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt(8080)}}, Ports: []v1.ServicePort{{Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt(8080)}},
}, },
}) })
endpoints.syncService(ns + "/foo") endpoints.syncService(ns + "/foo")
endpointsHandler.ValidateRequest(t, testapi.Default.ResourcePath("endpoints", v1.NamespaceDefault, "foo"), "GET", nil) endpointsHandler.ValidateRequest(t, testapi.Default.ResourcePath("endpoints", metav1.NamespaceDefault, "foo"), "GET", nil)
} }
func TestSyncEndpointsItems(t *testing.T) { func TestSyncEndpointsItems(t *testing.T) {

View File

@ -450,24 +450,24 @@ type GarbageCollector struct {
func gcListWatcher(client *dynamic.Client, resource schema.GroupVersionResource) *cache.ListWatch { func gcListWatcher(client *dynamic.Client, resource schema.GroupVersionResource) *cache.ListWatch {
return &cache.ListWatch{ return &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
// APIResource.Kind is not used by the dynamic client, so // APIResource.Kind is not used by the dynamic client, so
// leave it empty. We want to list this resource in all // leave it empty. We want to list this resource in all
// namespaces if it's namespace scoped, so leave // namespaces if it's namespace scoped, so leave
// APIResource.Namespaced as false is all right. // APIResource.Namespaced as false is all right.
apiResource := metav1.APIResource{Name: resource.Resource} apiResource := metav1.APIResource{Name: resource.Resource}
return client.ParameterCodec(dynamic.VersionedParameterEncoderWithV1Fallback). return client.ParameterCodec(dynamic.VersionedParameterEncoderWithV1Fallback).
Resource(&apiResource, v1.NamespaceAll). Resource(&apiResource, metav1.NamespaceAll).
List(&options) List(&options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
// APIResource.Kind is not used by the dynamic client, so // APIResource.Kind is not used by the dynamic client, so
// leave it empty. We want to list this resource in all // leave it empty. We want to list this resource in all
// namespaces if it's namespace scoped, so leave // namespaces if it's namespace scoped, so leave
// APIResource.Namespaced as false is all right. // APIResource.Namespaced as false is all right.
apiResource := metav1.APIResource{Name: resource.Resource} apiResource := metav1.APIResource{Name: resource.Resource}
return client.ParameterCodec(dynamic.VersionedParameterEncoderWithV1Fallback). return client.ParameterCodec(dynamic.VersionedParameterEncoderWithV1Fallback).
Resource(&apiResource, v1.NamespaceAll). Resource(&apiResource, metav1.NamespaceAll).
Watch(&options) Watch(&options)
}, },
} }

View File

@ -349,8 +349,8 @@ func TestGCListWatcher(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
lw := gcListWatcher(client, podResource) lw := gcListWatcher(client, podResource)
lw.Watch(v1.ListOptions{ResourceVersion: "1"}) lw.Watch(metav1.ListOptions{ResourceVersion: "1"})
lw.List(v1.ListOptions{ResourceVersion: "1"}) lw.List(metav1.ListOptions{ResourceVersion: "1"})
if e, a := 2, len(testHandler.actions); e != a { if e, a := 2, len(testHandler.actions); e != a {
t.Errorf("expect %d requests, got %d", e, a) t.Errorf("expect %d requests, got %d", e, a)
} }

View File

@ -35,6 +35,7 @@ go_library(
"//pkg/client/listers/batch/v1:go_default_library", "//pkg/client/listers/batch/v1:go_default_library",
"//pkg/client/listers/core/internalversion:go_default_library", "//pkg/client/listers/core/internalversion:go_default_library",
"//vendor:github.com/golang/glog", "//vendor:github.com/golang/glog",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/runtime", "//vendor:k8s.io/apimachinery/pkg/runtime",
"//vendor:k8s.io/apimachinery/pkg/runtime/schema", "//vendor:k8s.io/apimachinery/pkg/runtime/schema",
"//vendor:k8s.io/apimachinery/pkg/watch", "//vendor:k8s.io/apimachinery/pkg/watch",

View File

@ -20,9 +20,9 @@ import (
"reflect" "reflect"
"time" "time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
"k8s.io/kubernetes/pkg/api/v1"
batch "k8s.io/kubernetes/pkg/apis/batch/v1" batch "k8s.io/kubernetes/pkg/apis/batch/v1"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" "k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
@ -61,11 +61,11 @@ func (f *jobInformer) Informer() cache.SharedIndexInformer {
func NewJobInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { func NewJobInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer( sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return client.Batch().Jobs(v1.NamespaceAll).List(options) return client.Batch().Jobs(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return client.Batch().Jobs(v1.NamespaceAll).Watch(options) return client.Batch().Jobs(metav1.NamespaceAll).Watch(options)
}, },
}, },
&batch.Job{}, &batch.Job{},

View File

@ -20,6 +20,7 @@ import (
"reflect" "reflect"
"time" "time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
@ -359,11 +360,11 @@ func (f *replicationControllerInformer) Lister() *listers.StoreToReplicationCont
func NewPodInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { func NewPodInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer( sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return client.Core().Pods(v1.NamespaceAll).List(options) return client.Core().Pods(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return client.Core().Pods(v1.NamespaceAll).Watch(options) return client.Core().Pods(metav1.NamespaceAll).Watch(options)
}, },
}, },
&v1.Pod{}, &v1.Pod{},
@ -378,10 +379,10 @@ func NewPodInformer(client clientset.Interface, resyncPeriod time.Duration) cach
func NewNodeInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { func NewNodeInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer( sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return client.Core().Nodes().List(options) return client.Core().Nodes().List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return client.Core().Nodes().Watch(options) return client.Core().Nodes().Watch(options)
}, },
}, },
@ -396,11 +397,11 @@ func NewNodeInformer(client clientset.Interface, resyncPeriod time.Duration) cac
func NewPVCInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { func NewPVCInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer( sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return client.Core().PersistentVolumeClaims(v1.NamespaceAll).List(options) return client.Core().PersistentVolumeClaims(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return client.Core().PersistentVolumeClaims(v1.NamespaceAll).Watch(options) return client.Core().PersistentVolumeClaims(metav1.NamespaceAll).Watch(options)
}, },
}, },
&v1.PersistentVolumeClaim{}, &v1.PersistentVolumeClaim{},
@ -415,10 +416,10 @@ func NewPVCInformer(client clientset.Interface, resyncPeriod time.Duration) cach
func NewPVInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { func NewPVInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer( sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return client.Core().PersistentVolumes().List(options) return client.Core().PersistentVolumes().List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return client.Core().PersistentVolumes().Watch(options) return client.Core().PersistentVolumes().Watch(options)
}, },
}, },
@ -433,10 +434,10 @@ func NewPVInformer(client clientset.Interface, resyncPeriod time.Duration) cache
func NewNamespaceInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { func NewNamespaceInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer( sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return client.Core().Namespaces().List(options) return client.Core().Namespaces().List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return client.Core().Namespaces().Watch(options) return client.Core().Namespaces().Watch(options)
}, },
}, },
@ -451,15 +452,11 @@ func NewNamespaceInformer(client clientset.Interface, resyncPeriod time.Duration
func NewInternalNamespaceInformer(client internalclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { func NewInternalNamespaceInformer(client internalclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer( sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
internalOptions := api.ListOptions{} return client.Core().Namespaces().List(options)
v1.Convert_v1_ListOptions_To_api_ListOptions(&options, &internalOptions, nil)
return client.Core().Namespaces().List(internalOptions)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
internalOptions := api.ListOptions{} return client.Core().Namespaces().Watch(options)
v1.Convert_v1_ListOptions_To_api_ListOptions(&options, &internalOptions, nil)
return client.Core().Namespaces().Watch(internalOptions)
}, },
}, },
&api.Namespace{}, &api.Namespace{},
@ -473,11 +470,11 @@ func NewInternalNamespaceInformer(client internalclientset.Interface, resyncPeri
func NewLimitRangeInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { func NewLimitRangeInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer( sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return client.Core().LimitRanges(v1.NamespaceAll).List(options) return client.Core().LimitRanges(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return client.Core().LimitRanges(v1.NamespaceAll).Watch(options) return client.Core().LimitRanges(metav1.NamespaceAll).Watch(options)
}, },
}, },
&v1.LimitRange{}, &v1.LimitRange{},
@ -491,15 +488,11 @@ func NewLimitRangeInformer(client clientset.Interface, resyncPeriod time.Duratio
func NewInternalLimitRangeInformer(internalclient internalclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { func NewInternalLimitRangeInformer(internalclient internalclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer( sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
internalOptions := api.ListOptions{} return internalclient.Core().LimitRanges(metav1.NamespaceAll).List(options)
v1.Convert_v1_ListOptions_To_api_ListOptions(&options, &internalOptions, nil)
return internalclient.Core().LimitRanges(v1.NamespaceAll).List(internalOptions)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
internalOptions := api.ListOptions{} return internalclient.Core().LimitRanges(metav1.NamespaceAll).Watch(options)
v1.Convert_v1_ListOptions_To_api_ListOptions(&options, &internalOptions, nil)
return internalclient.Core().LimitRanges(v1.NamespaceAll).Watch(internalOptions)
}, },
}, },
&api.LimitRange{}, &api.LimitRange{},
@ -513,11 +506,11 @@ func NewInternalLimitRangeInformer(internalclient internalclientset.Interface, r
func NewReplicationControllerInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { func NewReplicationControllerInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer( sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return client.Core().ReplicationControllers(v1.NamespaceAll).List(options) return client.Core().ReplicationControllers(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return client.Core().ReplicationControllers(v1.NamespaceAll).Watch(options) return client.Core().ReplicationControllers(metav1.NamespaceAll).Watch(options)
}, },
}, },
&v1.ReplicationController{}, &v1.ReplicationController{},
@ -568,11 +561,11 @@ func (f *serviceAccountInformer) Lister() *listers.StoreToServiceAccountLister {
func NewServiceAccountInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { func NewServiceAccountInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer( sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return client.Core().ServiceAccounts(v1.NamespaceAll).List(options) return client.Core().ServiceAccounts(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return client.Core().ServiceAccounts(v1.NamespaceAll).Watch(options) return client.Core().ServiceAccounts(metav1.NamespaceAll).Watch(options)
}, },
}, },
&v1.ServiceAccount{}, &v1.ServiceAccount{},

View File

@ -19,9 +19,9 @@ package informers
import ( import (
"reflect" "reflect"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
"k8s.io/kubernetes/pkg/api/v1"
extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1" extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/client/legacylisters" "k8s.io/kubernetes/pkg/client/legacylisters"
@ -49,11 +49,11 @@ func (f *daemonSetInformer) Informer() cache.SharedIndexInformer {
} }
informer = cache.NewSharedIndexInformer( informer = cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return f.client.Extensions().DaemonSets(v1.NamespaceAll).List(options) return f.client.Extensions().DaemonSets(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return f.client.Extensions().DaemonSets(v1.NamespaceAll).Watch(options) return f.client.Extensions().DaemonSets(metav1.NamespaceAll).Watch(options)
}, },
}, },
&extensions.DaemonSet{}, &extensions.DaemonSet{},
@ -91,11 +91,11 @@ func (f *deploymentInformer) Informer() cache.SharedIndexInformer {
} }
informer = cache.NewSharedIndexInformer( informer = cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return f.client.Extensions().Deployments(v1.NamespaceAll).List(options) return f.client.Extensions().Deployments(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return f.client.Extensions().Deployments(v1.NamespaceAll).Watch(options) return f.client.Extensions().Deployments(metav1.NamespaceAll).Watch(options)
}, },
}, },
&extensions.Deployment{}, &extensions.Deployment{},
@ -133,11 +133,11 @@ func (f *replicaSetInformer) Informer() cache.SharedIndexInformer {
} }
informer = cache.NewSharedIndexInformer( informer = cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return f.client.Extensions().ReplicaSets(v1.NamespaceAll).List(options) return f.client.Extensions().ReplicaSets(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return f.client.Extensions().ReplicaSets(v1.NamespaceAll).Watch(options) return f.client.Extensions().ReplicaSets(metav1.NamespaceAll).Watch(options)
}, },
}, },
&extensions.ReplicaSet{}, &extensions.ReplicaSet{},

View File

@ -19,10 +19,10 @@ package informers
import ( import (
"reflect" "reflect"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/rbac" "k8s.io/kubernetes/pkg/apis/rbac"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/client/legacylisters" "k8s.io/kubernetes/pkg/client/legacylisters"
@ -48,10 +48,10 @@ func (f *clusterRoleInformer) Informer() cache.SharedIndexInformer {
} }
informer = cache.NewSharedIndexInformer( informer = cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return f.internalclient.Rbac().ClusterRoles().List(convertListOptionsOrDie(options)) return f.internalclient.Rbac().ClusterRoles().List(convertListOptionsOrDie(options))
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return f.internalclient.Rbac().ClusterRoles().Watch(convertListOptionsOrDie(options)) return f.internalclient.Rbac().ClusterRoles().Watch(convertListOptionsOrDie(options))
}, },
}, },
@ -88,10 +88,10 @@ func (f *clusterRoleBindingInformer) Informer() cache.SharedIndexInformer {
} }
informer = cache.NewSharedIndexInformer( informer = cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return f.internalclient.Rbac().ClusterRoleBindings().List(convertListOptionsOrDie(options)) return f.internalclient.Rbac().ClusterRoleBindings().List(convertListOptionsOrDie(options))
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return f.internalclient.Rbac().ClusterRoleBindings().Watch(convertListOptionsOrDie(options)) return f.internalclient.Rbac().ClusterRoleBindings().Watch(convertListOptionsOrDie(options))
}, },
}, },
@ -128,11 +128,11 @@ func (f *roleInformer) Informer() cache.SharedIndexInformer {
} }
informer = cache.NewSharedIndexInformer( informer = cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return f.internalclient.Rbac().Roles(v1.NamespaceAll).List(convertListOptionsOrDie(options)) return f.internalclient.Rbac().Roles(metav1.NamespaceAll).List(convertListOptionsOrDie(options))
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return f.internalclient.Rbac().Roles(v1.NamespaceAll).Watch(convertListOptionsOrDie(options)) return f.internalclient.Rbac().Roles(metav1.NamespaceAll).Watch(convertListOptionsOrDie(options))
}, },
}, },
&rbac.Role{}, &rbac.Role{},
@ -168,11 +168,11 @@ func (f *roleBindingInformer) Informer() cache.SharedIndexInformer {
} }
informer = cache.NewSharedIndexInformer( informer = cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return f.internalclient.Rbac().RoleBindings(v1.NamespaceAll).List(convertListOptionsOrDie(options)) return f.internalclient.Rbac().RoleBindings(metav1.NamespaceAll).List(convertListOptionsOrDie(options))
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return f.internalclient.Rbac().RoleBindings(v1.NamespaceAll).Watch(convertListOptionsOrDie(options)) return f.internalclient.Rbac().RoleBindings(metav1.NamespaceAll).Watch(convertListOptionsOrDie(options))
}, },
}, },
&rbac.RoleBinding{}, &rbac.RoleBinding{},
@ -188,8 +188,8 @@ func (f *roleBindingInformer) Lister() listers.RoleBindingLister {
return listers.NewRoleBindingLister(f.Informer().GetIndexer()) return listers.NewRoleBindingLister(f.Informer().GetIndexer())
} }
func convertListOptionsOrDie(in v1.ListOptions) api.ListOptions { func convertListOptionsOrDie(in metav1.ListOptions) metav1.ListOptions {
out := api.ListOptions{} out := metav1.ListOptions{}
if err := api.Scheme.Convert(&in, &out, nil); err != nil { if err := api.Scheme.Convert(&in, &out, nil); err != nil {
panic(err) panic(err)
} }

View File

@ -19,9 +19,9 @@ package informers
import ( import (
"reflect" "reflect"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
"k8s.io/kubernetes/pkg/api/v1"
storage "k8s.io/kubernetes/pkg/apis/storage/v1beta1" storage "k8s.io/kubernetes/pkg/apis/storage/v1beta1"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/client/legacylisters" "k8s.io/kubernetes/pkg/client/legacylisters"
@ -49,10 +49,10 @@ func (f *storageClassInformer) Informer() cache.SharedIndexInformer {
} }
informer = cache.NewSharedIndexInformer( informer = cache.NewSharedIndexInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return f.client.Storage().StorageClasses().List(options) return f.client.Storage().StorageClasses().List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return f.client.Storage().StorageClasses().Watch(options) return f.client.Storage().StorageClasses().Watch(options)
}, },
}, },

View File

@ -43,7 +43,7 @@ func newJob(parallelism, completions int32) *batch.Job {
j := &batch.Job{ j := &batch.Job{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "foobar", Name: "foobar",
Namespace: v1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
Spec: batch.JobSpec{ Spec: batch.JobSpec{
Selector: &metav1.LabelSelector{ Selector: &metav1.LabelSelector{
@ -526,7 +526,7 @@ func TestJobPodLookup(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "basic"}, ObjectMeta: metav1.ObjectMeta{Name: "basic"},
}, },
pod: &v1.Pod{ pod: &v1.Pod{
ObjectMeta: metav1.ObjectMeta{Name: "foo1", Namespace: v1.NamespaceAll}, ObjectMeta: metav1.ObjectMeta{Name: "foo1", Namespace: metav1.NamespaceAll},
}, },
expectedName: "", expectedName: "",
}, },

View File

@ -129,10 +129,10 @@ func NewNamespaceController(
// configure the backing store/controller // configure the backing store/controller
store, controller := cache.NewInformer( store, controller := cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return kubeClient.Core().Namespaces().List(options) return kubeClient.Core().Namespaces().List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return kubeClient.Core().Namespaces().Watch(options) return kubeClient.Core().Namespaces().Watch(options)
}, },
}, },

View File

@ -178,7 +178,7 @@ func deleteCollection(
// resource deletions generically. it will ensure all resources in the namespace are purged prior to releasing // resource deletions generically. it will ensure all resources in the namespace are purged prior to releasing
// namespace itself. // namespace itself.
orphanDependents := false orphanDependents := false
err := dynamicClient.Resource(&apiResource, namespace).DeleteCollection(&v1.DeleteOptions{OrphanDependents: &orphanDependents}, &v1.ListOptions{}) err := dynamicClient.Resource(&apiResource, namespace).DeleteCollection(&v1.DeleteOptions{OrphanDependents: &orphanDependents}, &metav1.ListOptions{})
if err == nil { if err == nil {
return true, nil return true, nil
@ -220,7 +220,7 @@ func listCollection(
} }
apiResource := metav1.APIResource{Name: gvr.Resource, Namespaced: true} apiResource := metav1.APIResource{Name: gvr.Resource, Namespaced: true}
obj, err := dynamicClient.Resource(&apiResource, namespace).List(&v1.ListOptions{}) obj, err := dynamicClient.Resource(&apiResource, namespace).List(&metav1.ListOptions{})
if err == nil { if err == nil {
unstructuredList, ok := obj.(*unstructured.UnstructuredList) unstructuredList, ok := obj.(*unstructured.UnstructuredList)
if !ok { if !ok {
@ -486,7 +486,7 @@ func estimateGracefulTermination(kubeClient clientset.Interface, groupVersionRes
func estimateGracefulTerminationForPods(kubeClient clientset.Interface, ns string) (int64, error) { func estimateGracefulTerminationForPods(kubeClient clientset.Interface, ns string) (int64, error) {
glog.V(5).Infof("namespace controller - estimateGracefulTerminationForPods - namespace %s", ns) glog.V(5).Infof("namespace controller - estimateGracefulTerminationForPods - namespace %s", ns)
estimate := int64(0) estimate := int64(0)
items, err := kubeClient.Core().Pods(ns).List(v1.ListOptions{}) items, err := kubeClient.Core().Pods(ns).List(metav1.ListOptions{})
if err != nil { if err != nil {
return estimate, err return estimate, err
} }

View File

@ -21,6 +21,7 @@ import (
"strings" "strings"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
utilerrors "k8s.io/apimachinery/pkg/util/errors" utilerrors "k8s.io/apimachinery/pkg/util/errors"
@ -49,8 +50,8 @@ const (
func deletePods(kubeClient clientset.Interface, recorder record.EventRecorder, nodeName, nodeUID string, daemonStore listers.StoreToDaemonSetLister) (bool, error) { func deletePods(kubeClient clientset.Interface, recorder record.EventRecorder, nodeName, nodeUID string, daemonStore listers.StoreToDaemonSetLister) (bool, error) {
remaining := false remaining := false
selector := fields.OneTermEqualSelector(api.PodHostField, nodeName).String() selector := fields.OneTermEqualSelector(api.PodHostField, nodeName).String()
options := v1.ListOptions{FieldSelector: selector} options := metav1.ListOptions{FieldSelector: selector}
pods, err := kubeClient.Core().Pods(v1.NamespaceAll).List(options) pods, err := kubeClient.Core().Pods(metav1.NamespaceAll).List(options)
var updateErrList []error var updateErrList []error
if err != nil { if err != nil {
@ -203,8 +204,8 @@ func markAllPodsNotReady(kubeClient clientset.Interface, node *v1.Node) error {
} }
nodeName := node.Name nodeName := node.Name
glog.V(2).Infof("Update ready status of pods on node [%v]", nodeName) glog.V(2).Infof("Update ready status of pods on node [%v]", nodeName)
opts := v1.ListOptions{FieldSelector: fields.OneTermEqualSelector(api.PodHostField, nodeName).String()} opts := metav1.ListOptions{FieldSelector: fields.OneTermEqualSelector(api.PodHostField, nodeName).String()}
pods, err := kubeClient.Core().Pods(v1.NamespaceAll).List(opts) pods, err := kubeClient.Core().Pods(metav1.NamespaceAll).List(opts)
if err != nil { if err != nil {
return err return err
} }

View File

@ -253,7 +253,7 @@ func NewNodeController(
// We must poll because apiserver might not be up. This error causes // We must poll because apiserver might not be up. This error causes
// controller manager to restart. // controller manager to restart.
if pollErr := wait.Poll(10*time.Second, apiserverStartupGracePeriod, func() (bool, error) { if pollErr := wait.Poll(10*time.Second, apiserverStartupGracePeriod, func() (bool, error) {
nodeList, err = kubeClient.Core().Nodes().List(v1.ListOptions{ nodeList, err = kubeClient.Core().Nodes().List(metav1.ListOptions{
FieldSelector: fields.Everything().String(), FieldSelector: fields.Everything().String(),
LabelSelector: labels.Everything().String(), LabelSelector: labels.Everything().String(),
}) })

View File

@ -80,7 +80,7 @@ func NewNodeControllerFromClient(
} }
func syncNodeStore(nc *NodeController, fakeNodeHandler *testutil.FakeNodeHandler) error { func syncNodeStore(nc *NodeController, fakeNodeHandler *testutil.FakeNodeHandler) error {
nodes, err := fakeNodeHandler.List(v1.ListOptions{}) nodes, err := fakeNodeHandler.List(metav1.ListOptions{})
if err != nil { if err != nil {
return err return err
} }

View File

@ -130,7 +130,7 @@ func (m *FakeNodeHandler) Get(name string, opts metav1.GetOptions) (*v1.Node, er
} }
// List returns a list of Nodes from the fake store. // List returns a list of Nodes from the fake store.
func (m *FakeNodeHandler) List(opts v1.ListOptions) (*v1.NodeList, error) { func (m *FakeNodeHandler) List(opts metav1.ListOptions) (*v1.NodeList, error) {
m.lock.Lock() m.lock.Lock()
defer func() { defer func() {
m.RequestCount++ m.RequestCount++
@ -174,7 +174,7 @@ func (m *FakeNodeHandler) Delete(id string, opt *v1.DeleteOptions) error {
} }
// DeleteCollection deletes a collection of Nodes from the fake store. // DeleteCollection deletes a collection of Nodes from the fake store.
func (m *FakeNodeHandler) DeleteCollection(opt *v1.DeleteOptions, listOpts v1.ListOptions) error { func (m *FakeNodeHandler) DeleteCollection(opt *v1.DeleteOptions, listOpts metav1.ListOptions) error {
return nil return nil
} }
@ -215,7 +215,7 @@ func (m *FakeNodeHandler) PatchStatus(nodeName string, data []byte) (*v1.Node, e
} }
// Watch watches Nodes in a fake store. // Watch watches Nodes in a fake store.
func (m *FakeNodeHandler) Watch(opts v1.ListOptions) (watch.Interface, error) { func (m *FakeNodeHandler) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return watch.NewFake(), nil return watch.NewFake(), nil
} }
@ -263,7 +263,7 @@ func (f *FakeRecorder) makeEvent(ref *v1.ObjectReference, eventtype, reason, mes
t := metav1.Time{Time: f.clock.Now()} t := metav1.Time{Time: f.clock.Now()}
namespace := ref.Namespace namespace := ref.Namespace
if namespace == "" { if namespace == "" {
namespace = v1.NamespaceDefault namespace = metav1.NamespaceDefault
} }
return &v1.Event{ return &v1.Event{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
@ -339,7 +339,7 @@ func contains(node *v1.Node, nodes []*v1.Node) bool {
// GetZones returns list of zones for all Nodes stored in FakeNodeHandler // GetZones returns list of zones for all Nodes stored in FakeNodeHandler
func GetZones(nodeHandler *FakeNodeHandler) []string { func GetZones(nodeHandler *FakeNodeHandler) []string {
nodes, _ := nodeHandler.List(v1.ListOptions{}) nodes, _ := nodeHandler.List(metav1.ListOptions{})
zones := sets.NewString() zones := sets.NewString()
for _, node := range nodes.Items { for _, node := range nodes.Items {
zones.Insert(utilnode.GetZoneKey(&node)) zones.Insert(utilnode.GetZoneKey(&node))

View File

@ -75,11 +75,11 @@ var upscaleForbiddenWindow = 3 * time.Minute
func newInformer(controller *HorizontalController, resyncPeriod time.Duration) (cache.Store, cache.Controller) { func newInformer(controller *HorizontalController, resyncPeriod time.Duration) (cache.Store, cache.Controller) {
return cache.NewInformer( return cache.NewInformer(
&cache.ListWatch{ &cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) { ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return controller.hpaNamespacer.HorizontalPodAutoscalers(v1.NamespaceAll).List(options) return controller.hpaNamespacer.HorizontalPodAutoscalers(metav1.NamespaceAll).List(options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return controller.hpaNamespacer.HorizontalPodAutoscalers(v1.NamespaceAll).Watch(options) return controller.hpaNamespacer.HorizontalPodAutoscalers(metav1.NamespaceAll).Watch(options)
}, },
}, },
&autoscaling.HorizontalPodAutoscaler{}, &autoscaling.HorizontalPodAutoscaler{},

View File

@ -20,6 +20,7 @@ go_library(
"//pkg/client/clientset_generated/clientset:go_default_library", "//pkg/client/clientset_generated/clientset:go_default_library",
"//pkg/client/clientset_generated/clientset/typed/core/v1:go_default_library", "//pkg/client/clientset_generated/clientset/typed/core/v1:go_default_library",
"//vendor:github.com/golang/glog", "//vendor:github.com/golang/glog",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/labels", "//vendor:k8s.io/apimachinery/pkg/labels",
"//vendor:k8s.io/heapster/metrics/api/v1/types", "//vendor:k8s.io/heapster/metrics/api/v1/types",
"//vendor:k8s.io/heapster/metrics/apis/metrics/v1alpha1", "//vendor:k8s.io/heapster/metrics/apis/metrics/v1alpha1",

View File

@ -21,6 +21,7 @@ import (
"math" "math"
"time" "time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
"k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/api/v1"
@ -48,7 +49,7 @@ func (c *ReplicaCalculator) GetResourceReplicas(currentReplicas int32, targetUti
return 0, 0, time.Time{}, fmt.Errorf("unable to get metrics for resource %s: %v", resource, err) return 0, 0, time.Time{}, fmt.Errorf("unable to get metrics for resource %s: %v", resource, err)
} }
podList, err := c.podsGetter.Pods(namespace).List(v1.ListOptions{LabelSelector: selector.String()}) podList, err := c.podsGetter.Pods(namespace).List(metav1.ListOptions{LabelSelector: selector.String()})
if err != nil { if err != nil {
return 0, 0, time.Time{}, fmt.Errorf("unable to get pods while calculating replica count: %v", err) return 0, 0, time.Time{}, fmt.Errorf("unable to get pods while calculating replica count: %v", err)
} }
@ -156,7 +157,7 @@ func (c *ReplicaCalculator) GetMetricReplicas(currentReplicas int32, targetUtili
return 0, 0, time.Time{}, fmt.Errorf("unable to get metric %s: %v", metricName, err) return 0, 0, time.Time{}, fmt.Errorf("unable to get metric %s: %v", metricName, err)
} }
podList, err := c.podsGetter.Pods(namespace).List(v1.ListOptions{LabelSelector: selector.String()}) podList, err := c.podsGetter.Pods(namespace).List(metav1.ListOptions{LabelSelector: selector.String()})
if err != nil { if err != nil {
return 0, 0, time.Time{}, fmt.Errorf("unable to get pods while calculating replica count: %v", err) return 0, 0, time.Time{}, fmt.Errorf("unable to get pods while calculating replica count: %v", err)
} }

View File

@ -24,6 +24,7 @@ go_library(
"//pkg/controller/informers:go_default_library", "//pkg/controller/informers:go_default_library",
"//pkg/util/metrics:go_default_library", "//pkg/util/metrics:go_default_library",
"//vendor:github.com/golang/glog", "//vendor:github.com/golang/glog",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/labels", "//vendor:k8s.io/apimachinery/pkg/labels",
"//vendor:k8s.io/apimachinery/pkg/util/runtime", "//vendor:k8s.io/apimachinery/pkg/util/runtime",
"//vendor:k8s.io/apimachinery/pkg/util/sets", "//vendor:k8s.io/apimachinery/pkg/util/sets",

View File

@ -21,6 +21,7 @@ import (
"sync" "sync"
"time" "time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
utilruntime "k8s.io/apimachinery/pkg/util/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
@ -156,7 +157,7 @@ func (gcc *PodGCController) gcTerminated(pods []*v1.Pod) {
func (gcc *PodGCController) gcOrphaned(pods []*v1.Pod) { func (gcc *PodGCController) gcOrphaned(pods []*v1.Pod) {
glog.V(4).Infof("GC'ing orphaned") glog.V(4).Infof("GC'ing orphaned")
// We want to get list of Nodes from the etcd, to make sure that it's as fresh as possible. // We want to get list of Nodes from the etcd, to make sure that it's as fresh as possible.
nodes, err := gcc.kubeClient.Core().Nodes().List(v1.ListOptions{}) nodes, err := gcc.kubeClient.Core().Nodes().List(metav1.ListOptions{})
if err != nil { if err != nil {
return return
} }

View File

@ -103,7 +103,7 @@ func newReplicaSet(replicas int, selectorMap map[string]string) *extensions.Repl
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
UID: uuid.NewUUID(), UID: uuid.NewUUID(),
Name: "foobar", Name: "foobar",
Namespace: v1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
ResourceVersion: "18", ResourceVersion: "18",
}, },
Spec: extensions.ReplicaSetSpec{ Spec: extensions.ReplicaSetSpec{
@ -465,7 +465,7 @@ func TestPodControllerLookup(t *testing.T) {
{ {
inRSs: []*extensions.ReplicaSet{ inRSs: []*extensions.ReplicaSet{
{ObjectMeta: metav1.ObjectMeta{Name: "basic"}}}, {ObjectMeta: metav1.ObjectMeta{Name: "basic"}}},
pod: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "foo1", Namespace: v1.NamespaceAll}}, pod: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "foo1", Namespace: metav1.NamespaceAll}},
outRSName: "", outRSName: "",
}, },
// Matching labels, not namespace // Matching labels, not namespace

Some files were not shown because too many files have changed in this diff Show More