Merge pull request #13700 from mikedanese/daemon_set

Auto commit by PR queue bot
pull/6/head
k8s-merge-robot 2015-09-10 10:15:45 -07:00
commit 1313e3b14e
28 changed files with 562 additions and 563 deletions

View File

@ -221,59 +221,59 @@ func (s *StoreToReplicationControllerLister) GetPodControllers(pod *api.Pod) (co
controllers = append(controllers, rc)
}
if len(controllers) == 0 {
err = fmt.Errorf("Could not find controllers for pod %s in namespace %s with labels: %v", pod.Name, pod.Namespace, pod.Labels)
err = fmt.Errorf("Could not find daemon set for pod %s in namespace %s with labels: %v", pod.Name, pod.Namespace, pod.Labels)
}
return
}
// StoreToDaemonLister gives a store List and Exists methods. The store must contain only Daemons.
type StoreToDaemonLister struct {
// StoreToDaemonSetLister gives a store List and Exists methods. The store must contain only DaemonSets.
type StoreToDaemonSetLister struct {
Store
}
// Exists checks if the given dc exists in the store.
func (s *StoreToDaemonLister) Exists(daemon *expapi.Daemon) (bool, error) {
_, exists, err := s.Store.Get(daemon)
// Exists checks if the given daemon set exists in the store.
func (s *StoreToDaemonSetLister) Exists(ds *expapi.DaemonSet) (bool, error) {
_, exists, err := s.Store.Get(ds)
if err != nil {
return false, err
}
return exists, nil
}
// StoreToDaemonLister lists all daemons in the store.
// List lists all daemon sets in the store.
// TODO: converge on the interface in pkg/client
func (s *StoreToDaemonLister) List() (daemons []expapi.Daemon, err error) {
func (s *StoreToDaemonSetLister) List() (dss []expapi.DaemonSet, err error) {
for _, c := range s.Store.List() {
daemons = append(daemons, *(c.(*expapi.Daemon)))
dss = append(dss, *(c.(*expapi.DaemonSet)))
}
return daemons, nil
return dss, nil
}
// GetPodDaemons returns a list of daemons managing a pod. Returns an error iff no matching daemons are found.
func (s *StoreToDaemonLister) GetPodDaemons(pod *api.Pod) (daemons []expapi.Daemon, err error) {
// GetPodDaemonSets returns a list of daemon sets managing a pod. Returns an error iff no matching daemon sets are found.
func (s *StoreToDaemonSetLister) GetPodDaemonSets(pod *api.Pod) (daemonSets []expapi.DaemonSet, err error) {
var selector labels.Selector
var daemonController expapi.Daemon
var daemonSet expapi.DaemonSet
if len(pod.Labels) == 0 {
err = fmt.Errorf("No daemons found for pod %v because it has no labels", pod.Name)
err = fmt.Errorf("No daemon sets found for pod %v because it has no labels", pod.Name)
return
}
for _, m := range s.Store.List() {
daemonController = *m.(*expapi.Daemon)
if daemonController.Namespace != pod.Namespace {
daemonSet = *m.(*expapi.DaemonSet)
if daemonSet.Namespace != pod.Namespace {
continue
}
selector = labels.Set(daemonController.Spec.Selector).AsSelector()
selector = labels.Set(daemonSet.Spec.Selector).AsSelector()
// If a daemonController with a nil or empty selector creeps in, it should match nothing, not everything.
// If a daemonSet with a nil or empty selector creeps in, it should match nothing, not everything.
if selector.Empty() || !selector.Matches(labels.Set(pod.Labels)) {
continue
}
daemons = append(daemons, daemonController)
daemonSets = append(daemonSets, daemonSet)
}
if len(daemons) == 0 {
err = fmt.Errorf("Could not find daemons for pod %s in namespace %s with labels: %v", pod.Name, pod.Namespace, pod.Labels)
if len(daemonSets) == 0 {
err = fmt.Errorf("Could not find daemon set for pod %s in namespace %s with labels: %v", pod.Name, pod.Namespace, pod.Labels)
}
return
}

View File

@ -156,64 +156,64 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
}
}
func TestStoreToDaemonLister(t *testing.T) {
func TestStoreToDaemonSetLister(t *testing.T) {
store := NewStore(MetaNamespaceKeyFunc)
lister := StoreToDaemonLister{store}
lister := StoreToDaemonSetLister{store}
testCases := []struct {
inDCs []*expapi.Daemon
list func() ([]expapi.Daemon, error)
outDCNames util.StringSet
expectErr bool
inDSs []*expapi.DaemonSet
list func() ([]expapi.DaemonSet, error)
outDaemonSetNames util.StringSet
expectErr bool
}{
// Basic listing
{
inDCs: []*expapi.Daemon{
inDSs: []*expapi.DaemonSet{
{ObjectMeta: api.ObjectMeta{Name: "basic"}},
},
list: func() ([]expapi.Daemon, error) {
list: func() ([]expapi.DaemonSet, error) {
return lister.List()
},
outDCNames: util.NewStringSet("basic"),
outDaemonSetNames: util.NewStringSet("basic"),
},
// Listing multiple controllers
// Listing multiple daemon sets
{
inDCs: []*expapi.Daemon{
inDSs: []*expapi.DaemonSet{
{ObjectMeta: api.ObjectMeta{Name: "basic"}},
{ObjectMeta: api.ObjectMeta{Name: "complex"}},
{ObjectMeta: api.ObjectMeta{Name: "complex2"}},
},
list: func() ([]expapi.Daemon, error) {
list: func() ([]expapi.DaemonSet, error) {
return lister.List()
},
outDCNames: util.NewStringSet("basic", "complex", "complex2"),
outDaemonSetNames: util.NewStringSet("basic", "complex", "complex2"),
},
// No pod labels
{
inDCs: []*expapi.Daemon{
inDSs: []*expapi.DaemonSet{
{
ObjectMeta: api.ObjectMeta{Name: "basic", Namespace: "ns"},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: map[string]string{"foo": "baz"},
},
},
},
list: func() ([]expapi.Daemon, error) {
list: func() ([]expapi.DaemonSet, error) {
pod := &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "pod1", Namespace: "ns"},
}
return lister.GetPodDaemons(pod)
return lister.GetPodDaemonSets(pod)
},
outDCNames: util.NewStringSet(),
expectErr: true,
outDaemonSetNames: util.NewStringSet(),
expectErr: true,
},
// No RC selectors
// No DS selectors
{
inDCs: []*expapi.Daemon{
inDSs: []*expapi.DaemonSet{
{
ObjectMeta: api.ObjectMeta{Name: "basic", Namespace: "ns"},
},
},
list: func() ([]expapi.Daemon, error) {
list: func() ([]expapi.DaemonSet, error) {
pod := &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "pod1",
@ -221,28 +221,28 @@ func TestStoreToDaemonLister(t *testing.T) {
Labels: map[string]string{"foo": "bar"},
},
}
return lister.GetPodDaemons(pod)
return lister.GetPodDaemonSets(pod)
},
outDCNames: util.NewStringSet(),
expectErr: true,
outDaemonSetNames: util.NewStringSet(),
expectErr: true,
},
// Matching labels to selectors and namespace
{
inDCs: []*expapi.Daemon{
inDSs: []*expapi.DaemonSet{
{
ObjectMeta: api.ObjectMeta{Name: "foo"},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: map[string]string{"foo": "bar"},
},
},
{
ObjectMeta: api.ObjectMeta{Name: "bar", Namespace: "ns"},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: map[string]string{"foo": "bar"},
},
},
},
list: func() ([]expapi.Daemon, error) {
list: func() ([]expapi.DaemonSet, error) {
pod := &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "pod1",
@ -250,17 +250,17 @@ func TestStoreToDaemonLister(t *testing.T) {
Namespace: "ns",
},
}
return lister.GetPodDaemons(pod)
return lister.GetPodDaemonSets(pod)
},
outDCNames: util.NewStringSet("bar"),
outDaemonSetNames: util.NewStringSet("bar"),
},
}
for _, c := range testCases {
for _, r := range c.inDCs {
for _, r := range c.inDSs {
store.Add(r)
}
gotControllers, err := c.list()
daemonSets, err := c.list()
if err != nil && c.expectErr {
continue
} else if c.expectErr {
@ -268,12 +268,12 @@ func TestStoreToDaemonLister(t *testing.T) {
} else if err != nil {
t.Fatalf("Unexpected error %#v", err)
}
gotNames := make([]string, len(gotControllers))
for ix := range gotControllers {
gotNames[ix] = gotControllers[ix].Name
daemonSetNames := make([]string, len(daemonSets))
for ix := range daemonSets {
daemonSetNames[ix] = daemonSets[ix].Name
}
if !c.outDCNames.HasAll(gotNames...) || len(gotNames) != len(c.outDCNames) {
t.Errorf("Unexpected got controllers %+v expected %+v", gotNames, c.outDCNames)
if !c.outDaemonSetNames.HasAll(daemonSetNames...) || len(daemonSetNames) != len(c.outDaemonSetNames) {
t.Errorf("Unexpected got controllers %+v expected %+v", daemonSetNames, c.outDaemonSetNames)
}
}
}

View File

@ -1,95 +0,0 @@
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
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 unversioned
import (
"k8s.io/kubernetes/pkg/expapi"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
)
// DaemonsNamespacer has methods to work with Daemon resources in a namespace
type DaemonsNamespacer interface {
Daemons(namespace string) DaemonInterface
}
type DaemonInterface interface {
List(selector labels.Selector) (*expapi.DaemonList, error)
Get(name string) (*expapi.Daemon, error)
Create(ctrl *expapi.Daemon) (*expapi.Daemon, error)
Update(ctrl *expapi.Daemon) (*expapi.Daemon, error)
Delete(name string) error
Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
}
// daemons implements DaemonsNamespacer interface
type daemons struct {
r *ExperimentalClient
ns string
}
func newDaemons(c *ExperimentalClient, namespace string) *daemons {
return &daemons{c, namespace}
}
// Ensure statically that daemons implements DaemonInterface.
var _ DaemonInterface = &daemons{}
func (c *daemons) List(selector labels.Selector) (result *expapi.DaemonList, err error) {
result = &expapi.DaemonList{}
err = c.r.Get().Namespace(c.ns).Resource("daemons").LabelsSelectorParam(selector).Do().Into(result)
return
}
// Get returns information about a particular daemon.
func (c *daemons) Get(name string) (result *expapi.Daemon, err error) {
result = &expapi.Daemon{}
err = c.r.Get().Namespace(c.ns).Resource("daemons").Name(name).Do().Into(result)
return
}
// Create creates a new daemon.
func (c *daemons) Create(daemon *expapi.Daemon) (result *expapi.Daemon, err error) {
result = &expapi.Daemon{}
err = c.r.Post().Namespace(c.ns).Resource("daemons").Body(daemon).Do().Into(result)
return
}
// Update updates an existing daemon.
func (c *daemons) Update(daemon *expapi.Daemon) (result *expapi.Daemon, err error) {
result = &expapi.Daemon{}
err = c.r.Put().Namespace(c.ns).Resource("daemons").Name(daemon.Name).Body(daemon).Do().Into(result)
return
}
// Delete deletes an existing daemon.
func (c *daemons) Delete(name string) error {
return c.r.Delete().Namespace(c.ns).Resource("daemons").Name(name).Do().Error()
}
// Watch returns a watch.Interface that watches the requested daemons.
func (c *daemons) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
return c.r.Get().
Prefix("watch").
Namespace(c.ns).
Resource("daemons").
Param("resourceVersion", resourceVersion).
LabelsSelectorParam(label).
FieldsSelectorParam(field).
Watch()
}

View File

@ -0,0 +1,95 @@
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
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 unversioned
import (
"k8s.io/kubernetes/pkg/expapi"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
)
// DaemonsSetsNamespacer has methods to work with DaemonSet resources in a namespace
type DaemonSetsNamespacer interface {
DaemonSets(namespace string) DaemonSetInterface
}
type DaemonSetInterface interface {
List(selector labels.Selector) (*expapi.DaemonSetList, error)
Get(name string) (*expapi.DaemonSet, error)
Create(ctrl *expapi.DaemonSet) (*expapi.DaemonSet, error)
Update(ctrl *expapi.DaemonSet) (*expapi.DaemonSet, error)
Delete(name string) error
Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
}
// daemonSets implements DaemonsSetsNamespacer interface
type daemonSets struct {
r *ExperimentalClient
ns string
}
func newDaemonSets(c *ExperimentalClient, namespace string) *daemonSets {
return &daemonSets{c, namespace}
}
// Ensure statically that daemonSets implements DaemonSetsInterface.
var _ DaemonSetInterface = &daemonSets{}
func (c *daemonSets) List(selector labels.Selector) (result *expapi.DaemonSetList, err error) {
result = &expapi.DaemonSetList{}
err = c.r.Get().Namespace(c.ns).Resource("daemonsets").LabelsSelectorParam(selector).Do().Into(result)
return
}
// Get returns information about a particular daemon set.
func (c *daemonSets) Get(name string) (result *expapi.DaemonSet, err error) {
result = &expapi.DaemonSet{}
err = c.r.Get().Namespace(c.ns).Resource("daemonsets").Name(name).Do().Into(result)
return
}
// Create creates a new daemon set.
func (c *daemonSets) Create(daemon *expapi.DaemonSet) (result *expapi.DaemonSet, err error) {
result = &expapi.DaemonSet{}
err = c.r.Post().Namespace(c.ns).Resource("daemonsets").Body(daemon).Do().Into(result)
return
}
// Update updates an existing daemon set.
func (c *daemonSets) Update(daemon *expapi.DaemonSet) (result *expapi.DaemonSet, err error) {
result = &expapi.DaemonSet{}
err = c.r.Put().Namespace(c.ns).Resource("daemonsets").Name(daemon.Name).Body(daemon).Do().Into(result)
return
}
// Delete deletes an existing daemon set.
func (c *daemonSets) Delete(name string) error {
return c.r.Delete().Namespace(c.ns).Resource("daemonsets").Name(name).Do().Error()
}
// Watch returns a watch.Interface that watches the requested daemon sets.
func (c *daemonSets) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
return c.r.Get().
Prefix("watch").
Namespace(c.ns).
Resource("daemonsets").
Param("resourceVersion", resourceVersion).
LabelsSelectorParam(label).
FieldsSelectorParam(field).
Watch()
}

View File

@ -25,20 +25,20 @@ import (
"k8s.io/kubernetes/pkg/labels"
)
func getDCResourceName() string {
return "daemons"
func getDSResourceName() string {
return "daemonsets"
}
func TestListDaemons(t *testing.T) {
func TestListDaemonSets(t *testing.T) {
ns := api.NamespaceAll
c := &testClient{
Request: testRequest{
Method: "GET",
Path: testapi.Experimental.ResourcePath(getDCResourceName(), ns, ""),
Path: testapi.Experimental.ResourcePath(getDSResourceName(), ns, ""),
},
Response: Response{StatusCode: 200,
Body: &expapi.DaemonList{
Items: []expapi.Daemon{
Body: &expapi.DaemonSetList{
Items: []expapi.DaemonSet{
{
ObjectMeta: api.ObjectMeta{
Name: "foo",
@ -47,7 +47,7 @@ func TestListDaemons(t *testing.T) {
"name": "baz",
},
},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Template: &api.PodTemplateSpec{},
},
},
@ -55,18 +55,18 @@ func TestListDaemons(t *testing.T) {
},
},
}
receivedControllerList, err := c.Setup(t).Experimental().Daemons(ns).List(labels.Everything())
c.Validate(t, receivedControllerList, err)
receivedDSs, err := c.Setup(t).Experimental().DaemonSets(ns).List(labels.Everything())
c.Validate(t, receivedDSs, err)
}
func TestGetDaemon(t *testing.T) {
func TestGetDaemonSet(t *testing.T) {
ns := api.NamespaceDefault
c := &testClient{
Request: testRequest{Method: "GET", Path: testapi.Experimental.ResourcePath(getDCResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
Request: testRequest{Method: "GET", Path: testapi.Experimental.ResourcePath(getDSResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
Response: Response{
StatusCode: 200,
Body: &expapi.Daemon{
Body: &expapi.DaemonSet{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{
@ -74,20 +74,20 @@ func TestGetDaemon(t *testing.T) {
"name": "baz",
},
},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Template: &api.PodTemplateSpec{},
},
},
},
}
receivedController, err := c.Setup(t).Experimental().Daemons(ns).Get("foo")
c.Validate(t, receivedController, err)
receivedDaemonSet, err := c.Setup(t).Experimental().DaemonSets(ns).Get("foo")
c.Validate(t, receivedDaemonSet, err)
}
func TestGetDaemonWithNoName(t *testing.T) {
func TestGetDaemonSetWithNoName(t *testing.T) {
ns := api.NamespaceDefault
c := &testClient{Error: true}
receivedPod, err := c.Setup(t).Experimental().Daemons(ns).Get("")
receivedPod, err := c.Setup(t).Experimental().DaemonSets(ns).Get("")
if (err != nil) && (err.Error() != nameRequiredError) {
t.Errorf("Expected error: %v, but got %v", nameRequiredError, err)
}
@ -95,16 +95,16 @@ func TestGetDaemonWithNoName(t *testing.T) {
c.Validate(t, receivedPod, err)
}
func TestUpdateDaemon(t *testing.T) {
func TestUpdateDaemonSet(t *testing.T) {
ns := api.NamespaceDefault
requestController := &expapi.Daemon{
requestDaemonSet := &expapi.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
}
c := &testClient{
Request: testRequest{Method: "PUT", Path: testapi.Experimental.ResourcePath(getDCResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
Request: testRequest{Method: "PUT", Path: testapi.Experimental.ResourcePath(getDSResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
Response: Response{
StatusCode: 200,
Body: &expapi.Daemon{
Body: &expapi.DaemonSet{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{
@ -112,36 +112,36 @@ func TestUpdateDaemon(t *testing.T) {
"name": "baz",
},
},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Template: &api.PodTemplateSpec{},
},
},
},
}
receivedController, err := c.Setup(t).Experimental().Daemons(ns).Update(requestController)
c.Validate(t, receivedController, err)
receivedDaemonSet, err := c.Setup(t).Experimental().DaemonSets(ns).Update(requestDaemonSet)
c.Validate(t, receivedDaemonSet, err)
}
func TestDeleteDaemon(t *testing.T) {
ns := api.NamespaceDefault
c := &testClient{
Request: testRequest{Method: "DELETE", Path: testapi.Experimental.ResourcePath(getDCResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
Request: testRequest{Method: "DELETE", Path: testapi.Experimental.ResourcePath(getDSResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200},
}
err := c.Setup(t).Experimental().Daemons(ns).Delete("foo")
err := c.Setup(t).Experimental().DaemonSets(ns).Delete("foo")
c.Validate(t, nil, err)
}
func TestCreateDaemon(t *testing.T) {
func TestCreateDaemonSet(t *testing.T) {
ns := api.NamespaceDefault
requestController := &expapi.Daemon{
requestDaemonSet := &expapi.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "foo"},
}
c := &testClient{
Request: testRequest{Method: "POST", Path: testapi.Experimental.ResourcePath(getDCResourceName(), ns, ""), Body: requestController, Query: buildQueryValues(nil)},
Request: testRequest{Method: "POST", Path: testapi.Experimental.ResourcePath(getDSResourceName(), ns, ""), Body: requestDaemonSet, Query: buildQueryValues(nil)},
Response: Response{
StatusCode: 200,
Body: &expapi.Daemon{
Body: &expapi.DaemonSet{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{
@ -149,12 +149,12 @@ func TestCreateDaemon(t *testing.T) {
"name": "baz",
},
},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Template: &api.PodTemplateSpec{},
},
},
},
}
receivedController, err := c.Setup(t).Experimental().Daemons(ns).Create(requestController)
c.Validate(t, receivedController, err)
receivedDaemonSet, err := c.Setup(t).Experimental().DaemonSets(ns).Create(requestDaemonSet)
c.Validate(t, receivedDaemonSet, err)
}

View File

@ -34,7 +34,7 @@ type ExperimentalInterface interface {
VersionInterface
HorizontalPodAutoscalersNamespacer
ScaleNamespacer
DaemonsNamespacer
DaemonSetsNamespacer
DeploymentsNamespacer
}
@ -82,8 +82,8 @@ func (c *ExperimentalClient) Scales(namespace string) ScaleInterface {
return newScales(c, namespace)
}
func (c *ExperimentalClient) Daemons(namespace string) DaemonInterface {
return newDaemons(c, namespace)
func (c *ExperimentalClient) DaemonSets(namespace string) DaemonSetInterface {
return newDaemonSets(c, namespace)
}
func (c *ExperimentalClient) Deployments(namespace string) DeploymentInterface {

View File

@ -0,0 +1,76 @@
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
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 testclient
import (
kClientLib "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/expapi"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
)
// FakeDaemonSet implements DaemonInterface. Meant to be embedded into a struct to get a default
// implementation. This makes faking out just the method you want to test easier.
type FakeDaemonSets struct {
Fake *FakeExperimental
Namespace string
}
// Ensure statically that FakeDaemonSets implements DaemonInterface.
var _ kClientLib.DaemonSetInterface = &FakeDaemonSets{}
func (c *FakeDaemonSets) Get(name string) (*expapi.DaemonSet, error) {
obj, err := c.Fake.Invokes(NewGetAction("daemonsets", c.Namespace, name), &expapi.DaemonSet{})
if obj == nil {
return nil, err
}
return obj.(*expapi.DaemonSet), err
}
func (c *FakeDaemonSets) List(label labels.Selector) (*expapi.DaemonSetList, error) {
obj, err := c.Fake.Invokes(NewListAction("daemonsets", c.Namespace, label, nil), &expapi.DaemonSetList{})
if obj == nil {
return nil, err
}
return obj.(*expapi.DaemonSetList), err
}
func (c *FakeDaemonSets) Create(daemon *expapi.DaemonSet) (*expapi.DaemonSet, error) {
obj, err := c.Fake.Invokes(NewCreateAction("daemonsets", c.Namespace, daemon), &expapi.DaemonSet{})
if obj == nil {
return nil, err
}
return obj.(*expapi.DaemonSet), err
}
func (c *FakeDaemonSets) Update(daemon *expapi.DaemonSet) (*expapi.DaemonSet, error) {
obj, err := c.Fake.Invokes(NewUpdateAction("daemonsets", c.Namespace, daemon), &expapi.DaemonSet{})
if obj == nil {
return nil, err
}
return obj.(*expapi.DaemonSet), err
}
func (c *FakeDaemonSets) Delete(name string) error {
_, err := c.Fake.Invokes(NewDeleteAction("daemonsets", c.Namespace, name), &expapi.DaemonSet{})
return err
}
func (c *FakeDaemonSets) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
return c.Fake.InvokesWatch(NewWatchAction("daemonsets", c.Namespace, label, field, resourceVersion))
}

View File

@ -1,76 +0,0 @@
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
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 testclient
import (
kClientLib "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/expapi"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
)
// FakeDaemons implements DaemonInterface. Meant to be embedded into a struct to get a default
// implementation. This makes faking out just the method you want to test easier.
type FakeDaemons struct {
Fake *FakeExperimental
Namespace string
}
// Ensure statically that FakeDaemons implements DaemonInterface.
var _ kClientLib.DaemonInterface = &FakeDaemons{}
func (c *FakeDaemons) Get(name string) (*expapi.Daemon, error) {
obj, err := c.Fake.Invokes(NewGetAction("daemons", c.Namespace, name), &expapi.Daemon{})
if obj == nil {
return nil, err
}
return obj.(*expapi.Daemon), err
}
func (c *FakeDaemons) List(label labels.Selector) (*expapi.DaemonList, error) {
obj, err := c.Fake.Invokes(NewListAction("daemons", c.Namespace, label, nil), &expapi.DaemonList{})
if obj == nil {
return nil, err
}
return obj.(*expapi.DaemonList), err
}
func (c *FakeDaemons) Create(daemon *expapi.Daemon) (*expapi.Daemon, error) {
obj, err := c.Fake.Invokes(NewCreateAction("daemons", c.Namespace, daemon), &expapi.Daemon{})
if obj == nil {
return nil, err
}
return obj.(*expapi.Daemon), err
}
func (c *FakeDaemons) Update(daemon *expapi.Daemon) (*expapi.Daemon, error) {
obj, err := c.Fake.Invokes(NewUpdateAction("daemons", c.Namespace, daemon), &expapi.Daemon{})
if obj == nil {
return nil, err
}
return obj.(*expapi.Daemon), err
}
func (c *FakeDaemons) Delete(name string) error {
_, err := c.Fake.Invokes(NewDeleteAction("daemons", c.Namespace, name), &expapi.Daemon{})
return err
}
func (c *FakeDaemons) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
return c.Fake.InvokesWatch(NewWatchAction("daemons", c.Namespace, label, field, resourceVersion))
}

View File

@ -246,8 +246,8 @@ type FakeExperimental struct {
*Fake
}
func (c *FakeExperimental) Daemons(namespace string) client.DaemonInterface {
return &FakeDaemons{Fake: c, Namespace: namespace}
func (c *FakeExperimental) DaemonSets(namespace string) client.DaemonSetInterface {
return &FakeDaemonSets{Fake: c, Namespace: namespace}
}
func (c *FakeExperimental) HorizontalPodAutoscalers(namespace string) client.HorizontalPodAutoscalerInterface {

View File

@ -419,12 +419,12 @@ func deleteHorizontalPodAutoscalers(expClient client.ExperimentalInterface, ns s
}
func deleteDaemons(expClient client.ExperimentalInterface, ns string) error {
items, err := expClient.Daemons(ns).List(labels.Everything())
items, err := expClient.DaemonSets(ns).List(labels.Everything())
if err != nil {
return err
}
for i := range items.Items {
err := expClient.Daemons(ns).Delete(items.Items[i].Name)
err := expClient.DaemonSets(ns).Delete(items.Items[i].Name)
if err != nil && !errors.IsNotFound(err) {
return err
}

View File

@ -107,7 +107,7 @@ func testSyncNamespaceThatIsTerminating(t *testing.T, experimentalMode bool) {
if experimentalMode {
expectedActionSet.Insert(
strings.Join([]string{"list", "horizontalpodautoscalers", ""}, "-"),
strings.Join([]string{"list", "daemons", ""}, "-"),
strings.Join([]string{"list", "daemonsets", ""}, "-"),
strings.Join([]string{"list", "deployments", ""}, "-"),
)
}

View File

@ -763,23 +763,23 @@ func deepCopy_expapi_APIVersion(in APIVersion, out *APIVersion, c *conversion.Cl
return nil
}
func deepCopy_expapi_Daemon(in Daemon, out *Daemon, c *conversion.Cloner) error {
func deepCopy_expapi_DaemonSet(in DaemonSet, out *DaemonSet, c *conversion.Cloner) error {
if err := deepCopy_api_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
return err
}
if err := deepCopy_api_ObjectMeta(in.ObjectMeta, &out.ObjectMeta, c); err != nil {
return err
}
if err := deepCopy_expapi_DaemonSpec(in.Spec, &out.Spec, c); err != nil {
if err := deepCopy_expapi_DaemonSetSpec(in.Spec, &out.Spec, c); err != nil {
return err
}
if err := deepCopy_expapi_DaemonStatus(in.Status, &out.Status, c); err != nil {
if err := deepCopy_expapi_DaemonSetStatus(in.Status, &out.Status, c); err != nil {
return err
}
return nil
}
func deepCopy_expapi_DaemonList(in DaemonList, out *DaemonList, c *conversion.Cloner) error {
func deepCopy_expapi_DaemonSetList(in DaemonSetList, out *DaemonSetList, c *conversion.Cloner) error {
if err := deepCopy_api_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
return err
}
@ -787,9 +787,9 @@ func deepCopy_expapi_DaemonList(in DaemonList, out *DaemonList, c *conversion.Cl
return err
}
if in.Items != nil {
out.Items = make([]Daemon, len(in.Items))
out.Items = make([]DaemonSet, len(in.Items))
for i := range in.Items {
if err := deepCopy_expapi_Daemon(in.Items[i], &out.Items[i], c); err != nil {
if err := deepCopy_expapi_DaemonSet(in.Items[i], &out.Items[i], c); err != nil {
return err
}
}
@ -799,7 +799,7 @@ func deepCopy_expapi_DaemonList(in DaemonList, out *DaemonList, c *conversion.Cl
return nil
}
func deepCopy_expapi_DaemonSpec(in DaemonSpec, out *DaemonSpec, c *conversion.Cloner) error {
func deepCopy_expapi_DaemonSetSpec(in DaemonSetSpec, out *DaemonSetSpec, c *conversion.Cloner) error {
if in.Selector != nil {
out.Selector = make(map[string]string)
for key, val := range in.Selector {
@ -819,7 +819,7 @@ func deepCopy_expapi_DaemonSpec(in DaemonSpec, out *DaemonSpec, c *conversion.Cl
return nil
}
func deepCopy_expapi_DaemonStatus(in DaemonStatus, out *DaemonStatus, c *conversion.Cloner) error {
func deepCopy_expapi_DaemonSetStatus(in DaemonSetStatus, out *DaemonSetStatus, c *conversion.Cloner) error {
out.CurrentNumberScheduled = in.CurrentNumberScheduled
out.NumberMisscheduled = in.NumberMisscheduled
out.DesiredNumberScheduled = in.DesiredNumberScheduled
@ -1193,10 +1193,10 @@ func init() {
deepCopy_api_VolumeSource,
deepCopy_resource_Quantity,
deepCopy_expapi_APIVersion,
deepCopy_expapi_Daemon,
deepCopy_expapi_DaemonList,
deepCopy_expapi_DaemonSpec,
deepCopy_expapi_DaemonStatus,
deepCopy_expapi_DaemonSet,
deepCopy_expapi_DaemonSetList,
deepCopy_expapi_DaemonSetSpec,
deepCopy_expapi_DaemonSetStatus,
deepCopy_expapi_Deployment,
deepCopy_expapi_DeploymentList,
deepCopy_expapi_DeploymentSpec,

View File

@ -36,8 +36,8 @@ func addKnownTypes() {
&Scale{},
&ThirdPartyResource{},
&ThirdPartyResourceList{},
&DaemonList{},
&Daemon{},
&DaemonSetList{},
&DaemonSet{},
&ThirdPartyResourceData{},
&ThirdPartyResourceDataList{},
)
@ -51,7 +51,7 @@ func (*ReplicationControllerDummy) IsAnAPIObject() {}
func (*Scale) IsAnAPIObject() {}
func (*ThirdPartyResource) IsAnAPIObject() {}
func (*ThirdPartyResourceList) IsAnAPIObject() {}
func (*Daemon) IsAnAPIObject() {}
func (*DaemonList) IsAnAPIObject() {}
func (*DaemonSet) IsAnAPIObject() {}
func (*DaemonSetList) IsAnAPIObject() {}
func (*ThirdPartyResourceData) IsAnAPIObject() {}
func (*ThirdPartyResourceDataList) IsAnAPIObject() {}

View File

@ -293,65 +293,65 @@ type DeploymentList struct {
Items []Deployment `json:"items"`
}
// DaemonSpec is the specification of a daemon.
type DaemonSpec struct {
// Selector is a label query over pods that are managed by the daemon.
// DaemonSetSpec is the specification of a daemon set.
type DaemonSetSpec struct {
// Selector is a label query over pods that are managed by the daemon set.
// Must match in order to be controlled.
// If empty, defaulted to labels on Pod template.
// More info: http://releases.k8s.io/HEAD/docs/user-guide/labels.md#label-selectors
Selector map[string]string `json:"selector,omitempty"`
// Template is the object that describes the pod that will be created.
// The Daemon will create exactly one copy of this pod on every node
// The DaemonSet will create exactly one copy of this pod on every node
// that matches the template's node selector (or on every node if no node
// selector is specified).
// More info: http://releases.k8s.io/HEAD/docs/user-guide/replication-controller.md#pod-template
Template *api.PodTemplateSpec `json:"template,omitempty"`
}
// DaemonStatus represents the current status of a daemon.
type DaemonStatus struct {
// CurrentNumberScheduled is the number of nodes that are running exactly 1 copy of the
// daemon and are supposed to run the daemon.
// DaemonSetStatus represents the current status of a daemon set.
type DaemonSetStatus struct {
// CurrentNumberScheduled is the number of nodes that are running exactly 1
// daemon pod and are supposed to run the daemon pod.
CurrentNumberScheduled int `json:"currentNumberScheduled"`
// NumberMisscheduled is the number of nodes that are running the daemon, but are
// not supposed to run the daemon.
// NumberMisscheduled is the number of nodes that are running the daemon pod, but are
// not supposed to run the daemon pod.
NumberMisscheduled int `json:"numberMisscheduled"`
// DesiredNumberScheduled is the total number of nodes that should be running the daemon
// (including nodes correctly running the daemon).
// pod (including nodes correctly running the daemon pod).
DesiredNumberScheduled int `json:"desiredNumberScheduled"`
}
// Daemon represents the configuration of a daemon.
type Daemon struct {
// DaemonSet represents the configuration of a daemon set.
type DaemonSet struct {
api.TypeMeta `json:",inline"`
// Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
api.ObjectMeta `json:"metadata,omitempty"`
// Spec defines the desired behavior of this daemon.
// Spec defines the desired behavior of this daemon set.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
Spec DaemonSpec `json:"spec,omitempty"`
Spec DaemonSetSpec `json:"spec,omitempty"`
// Status is the current status of this daemon. This data may be
// Status is the current status of this daemon set. This data may be
// out of date by some window of time.
// Populated by the system.
// Read-only.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
Status DaemonStatus `json:"status,omitempty"`
Status DaemonSetStatus `json:"status,omitempty"`
}
// DaemonList is a collection of daemon.
type DaemonList struct {
// DaemonSetList is a collection of daemon sets.
type DaemonSetList struct {
api.TypeMeta `json:",inline"`
// Standard list metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
api.ListMeta `json:"metadata,omitempty"`
// Items is a list of daemons.
Items []Daemon `json:"items"`
// Items is a list of daemon sets.
Items []DaemonSet `json:"items"`
}
type ThirdPartyResourceDataList struct {

View File

@ -1571,9 +1571,9 @@ func convert_expapi_APIVersion_To_v1_APIVersion(in *expapi.APIVersion, out *APIV
return nil
}
func convert_expapi_Daemon_To_v1_Daemon(in *expapi.Daemon, out *Daemon, s conversion.Scope) error {
func convert_expapi_DaemonSet_To_v1_DaemonSet(in *expapi.DaemonSet, out *DaemonSet, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*expapi.Daemon))(in)
defaulting.(func(*expapi.DaemonSet))(in)
}
if err := convert_api_TypeMeta_To_v1_TypeMeta(&in.TypeMeta, &out.TypeMeta, s); err != nil {
return err
@ -1581,18 +1581,18 @@ func convert_expapi_Daemon_To_v1_Daemon(in *expapi.Daemon, out *Daemon, s conver
if err := convert_api_ObjectMeta_To_v1_ObjectMeta(&in.ObjectMeta, &out.ObjectMeta, s); err != nil {
return err
}
if err := convert_expapi_DaemonSpec_To_v1_DaemonSpec(&in.Spec, &out.Spec, s); err != nil {
if err := convert_expapi_DaemonSetSpec_To_v1_DaemonSetSpec(&in.Spec, &out.Spec, s); err != nil {
return err
}
if err := convert_expapi_DaemonStatus_To_v1_DaemonStatus(&in.Status, &out.Status, s); err != nil {
if err := convert_expapi_DaemonSetStatus_To_v1_DaemonSetStatus(&in.Status, &out.Status, s); err != nil {
return err
}
return nil
}
func convert_expapi_DaemonList_To_v1_DaemonList(in *expapi.DaemonList, out *DaemonList, s conversion.Scope) error {
func convert_expapi_DaemonSetList_To_v1_DaemonSetList(in *expapi.DaemonSetList, out *DaemonSetList, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*expapi.DaemonList))(in)
defaulting.(func(*expapi.DaemonSetList))(in)
}
if err := convert_api_TypeMeta_To_v1_TypeMeta(&in.TypeMeta, &out.TypeMeta, s); err != nil {
return err
@ -1601,9 +1601,9 @@ func convert_expapi_DaemonList_To_v1_DaemonList(in *expapi.DaemonList, out *Daem
return err
}
if in.Items != nil {
out.Items = make([]Daemon, len(in.Items))
out.Items = make([]DaemonSet, len(in.Items))
for i := range in.Items {
if err := convert_expapi_Daemon_To_v1_Daemon(&in.Items[i], &out.Items[i], s); err != nil {
if err := convert_expapi_DaemonSet_To_v1_DaemonSet(&in.Items[i], &out.Items[i], s); err != nil {
return err
}
}
@ -1613,9 +1613,9 @@ func convert_expapi_DaemonList_To_v1_DaemonList(in *expapi.DaemonList, out *Daem
return nil
}
func convert_expapi_DaemonSpec_To_v1_DaemonSpec(in *expapi.DaemonSpec, out *DaemonSpec, s conversion.Scope) error {
func convert_expapi_DaemonSetSpec_To_v1_DaemonSetSpec(in *expapi.DaemonSetSpec, out *DaemonSetSpec, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*expapi.DaemonSpec))(in)
defaulting.(func(*expapi.DaemonSetSpec))(in)
}
if in.Selector != nil {
out.Selector = make(map[string]string)
@ -1636,9 +1636,9 @@ func convert_expapi_DaemonSpec_To_v1_DaemonSpec(in *expapi.DaemonSpec, out *Daem
return nil
}
func convert_expapi_DaemonStatus_To_v1_DaemonStatus(in *expapi.DaemonStatus, out *DaemonStatus, s conversion.Scope) error {
func convert_expapi_DaemonSetStatus_To_v1_DaemonSetStatus(in *expapi.DaemonSetStatus, out *DaemonSetStatus, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*expapi.DaemonStatus))(in)
defaulting.(func(*expapi.DaemonSetStatus))(in)
}
out.CurrentNumberScheduled = in.CurrentNumberScheduled
out.NumberMisscheduled = in.NumberMisscheduled
@ -1959,9 +1959,9 @@ func convert_v1_APIVersion_To_expapi_APIVersion(in *APIVersion, out *expapi.APIV
return nil
}
func convert_v1_Daemon_To_expapi_Daemon(in *Daemon, out *expapi.Daemon, s conversion.Scope) error {
func convert_v1_DaemonSet_To_expapi_DaemonSet(in *DaemonSet, out *expapi.DaemonSet, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*Daemon))(in)
defaulting.(func(*DaemonSet))(in)
}
if err := convert_v1_TypeMeta_To_api_TypeMeta(&in.TypeMeta, &out.TypeMeta, s); err != nil {
return err
@ -1969,18 +1969,18 @@ func convert_v1_Daemon_To_expapi_Daemon(in *Daemon, out *expapi.Daemon, s conver
if err := convert_v1_ObjectMeta_To_api_ObjectMeta(&in.ObjectMeta, &out.ObjectMeta, s); err != nil {
return err
}
if err := convert_v1_DaemonSpec_To_expapi_DaemonSpec(&in.Spec, &out.Spec, s); err != nil {
if err := convert_v1_DaemonSetSpec_To_expapi_DaemonSetSpec(&in.Spec, &out.Spec, s); err != nil {
return err
}
if err := convert_v1_DaemonStatus_To_expapi_DaemonStatus(&in.Status, &out.Status, s); err != nil {
if err := convert_v1_DaemonSetStatus_To_expapi_DaemonSetStatus(&in.Status, &out.Status, s); err != nil {
return err
}
return nil
}
func convert_v1_DaemonList_To_expapi_DaemonList(in *DaemonList, out *expapi.DaemonList, s conversion.Scope) error {
func convert_v1_DaemonSetList_To_expapi_DaemonSetList(in *DaemonSetList, out *expapi.DaemonSetList, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*DaemonList))(in)
defaulting.(func(*DaemonSetList))(in)
}
if err := convert_v1_TypeMeta_To_api_TypeMeta(&in.TypeMeta, &out.TypeMeta, s); err != nil {
return err
@ -1989,9 +1989,9 @@ func convert_v1_DaemonList_To_expapi_DaemonList(in *DaemonList, out *expapi.Daem
return err
}
if in.Items != nil {
out.Items = make([]expapi.Daemon, len(in.Items))
out.Items = make([]expapi.DaemonSet, len(in.Items))
for i := range in.Items {
if err := convert_v1_Daemon_To_expapi_Daemon(&in.Items[i], &out.Items[i], s); err != nil {
if err := convert_v1_DaemonSet_To_expapi_DaemonSet(&in.Items[i], &out.Items[i], s); err != nil {
return err
}
}
@ -2001,9 +2001,9 @@ func convert_v1_DaemonList_To_expapi_DaemonList(in *DaemonList, out *expapi.Daem
return nil
}
func convert_v1_DaemonSpec_To_expapi_DaemonSpec(in *DaemonSpec, out *expapi.DaemonSpec, s conversion.Scope) error {
func convert_v1_DaemonSetSpec_To_expapi_DaemonSetSpec(in *DaemonSetSpec, out *expapi.DaemonSetSpec, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*DaemonSpec))(in)
defaulting.(func(*DaemonSetSpec))(in)
}
if in.Selector != nil {
out.Selector = make(map[string]string)
@ -2024,9 +2024,9 @@ func convert_v1_DaemonSpec_To_expapi_DaemonSpec(in *DaemonSpec, out *expapi.Daem
return nil
}
func convert_v1_DaemonStatus_To_expapi_DaemonStatus(in *DaemonStatus, out *expapi.DaemonStatus, s conversion.Scope) error {
func convert_v1_DaemonSetStatus_To_expapi_DaemonSetStatus(in *DaemonSetStatus, out *expapi.DaemonSetStatus, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*DaemonStatus))(in)
defaulting.(func(*DaemonSetStatus))(in)
}
out.CurrentNumberScheduled = in.CurrentNumberScheduled
out.NumberMisscheduled = in.NumberMisscheduled
@ -2379,10 +2379,10 @@ func init() {
convert_api_VolumeSource_To_v1_VolumeSource,
convert_api_Volume_To_v1_Volume,
convert_expapi_APIVersion_To_v1_APIVersion,
convert_expapi_DaemonList_To_v1_DaemonList,
convert_expapi_DaemonSpec_To_v1_DaemonSpec,
convert_expapi_DaemonStatus_To_v1_DaemonStatus,
convert_expapi_Daemon_To_v1_Daemon,
convert_expapi_DaemonSetList_To_v1_DaemonSetList,
convert_expapi_DaemonSetSpec_To_v1_DaemonSetSpec,
convert_expapi_DaemonSetStatus_To_v1_DaemonSetStatus,
convert_expapi_DaemonSet_To_v1_DaemonSet,
convert_expapi_DeploymentList_To_v1_DeploymentList,
convert_expapi_DeploymentStatus_To_v1_DeploymentStatus,
convert_expapi_Deployment_To_v1_Deployment,
@ -2407,10 +2407,10 @@ func init() {
convert_v1_CinderVolumeSource_To_api_CinderVolumeSource,
convert_v1_ContainerPort_To_api_ContainerPort,
convert_v1_Container_To_api_Container,
convert_v1_DaemonList_To_expapi_DaemonList,
convert_v1_DaemonSpec_To_expapi_DaemonSpec,
convert_v1_DaemonStatus_To_expapi_DaemonStatus,
convert_v1_Daemon_To_expapi_Daemon,
convert_v1_DaemonSetList_To_expapi_DaemonSetList,
convert_v1_DaemonSetSpec_To_expapi_DaemonSetSpec,
convert_v1_DaemonSetStatus_To_expapi_DaemonSetStatus,
convert_v1_DaemonSet_To_expapi_DaemonSet,
convert_v1_DeploymentList_To_expapi_DeploymentList,
convert_v1_DeploymentStatus_To_expapi_DeploymentStatus,
convert_v1_Deployment_To_expapi_Deployment,

View File

@ -765,23 +765,23 @@ func deepCopy_v1_APIVersion(in APIVersion, out *APIVersion, c *conversion.Cloner
return nil
}
func deepCopy_v1_Daemon(in Daemon, out *Daemon, c *conversion.Cloner) error {
func deepCopy_v1_DaemonSet(in DaemonSet, out *DaemonSet, c *conversion.Cloner) error {
if err := deepCopy_v1_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
return err
}
if err := deepCopy_v1_ObjectMeta(in.ObjectMeta, &out.ObjectMeta, c); err != nil {
return err
}
if err := deepCopy_v1_DaemonSpec(in.Spec, &out.Spec, c); err != nil {
if err := deepCopy_v1_DaemonSetSpec(in.Spec, &out.Spec, c); err != nil {
return err
}
if err := deepCopy_v1_DaemonStatus(in.Status, &out.Status, c); err != nil {
if err := deepCopy_v1_DaemonSetStatus(in.Status, &out.Status, c); err != nil {
return err
}
return nil
}
func deepCopy_v1_DaemonList(in DaemonList, out *DaemonList, c *conversion.Cloner) error {
func deepCopy_v1_DaemonSetList(in DaemonSetList, out *DaemonSetList, c *conversion.Cloner) error {
if err := deepCopy_v1_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
return err
}
@ -789,9 +789,9 @@ func deepCopy_v1_DaemonList(in DaemonList, out *DaemonList, c *conversion.Cloner
return err
}
if in.Items != nil {
out.Items = make([]Daemon, len(in.Items))
out.Items = make([]DaemonSet, len(in.Items))
for i := range in.Items {
if err := deepCopy_v1_Daemon(in.Items[i], &out.Items[i], c); err != nil {
if err := deepCopy_v1_DaemonSet(in.Items[i], &out.Items[i], c); err != nil {
return err
}
}
@ -801,7 +801,7 @@ func deepCopy_v1_DaemonList(in DaemonList, out *DaemonList, c *conversion.Cloner
return nil
}
func deepCopy_v1_DaemonSpec(in DaemonSpec, out *DaemonSpec, c *conversion.Cloner) error {
func deepCopy_v1_DaemonSetSpec(in DaemonSetSpec, out *DaemonSetSpec, c *conversion.Cloner) error {
if in.Selector != nil {
out.Selector = make(map[string]string)
for key, val := range in.Selector {
@ -821,7 +821,7 @@ func deepCopy_v1_DaemonSpec(in DaemonSpec, out *DaemonSpec, c *conversion.Cloner
return nil
}
func deepCopy_v1_DaemonStatus(in DaemonStatus, out *DaemonStatus, c *conversion.Cloner) error {
func deepCopy_v1_DaemonSetStatus(in DaemonSetStatus, out *DaemonSetStatus, c *conversion.Cloner) error {
out.CurrentNumberScheduled = in.CurrentNumberScheduled
out.NumberMisscheduled = in.NumberMisscheduled
out.DesiredNumberScheduled = in.DesiredNumberScheduled
@ -1215,10 +1215,10 @@ func init() {
deepCopy_v1_VolumeMount,
deepCopy_v1_VolumeSource,
deepCopy_v1_APIVersion,
deepCopy_v1_Daemon,
deepCopy_v1_DaemonList,
deepCopy_v1_DaemonSpec,
deepCopy_v1_DaemonStatus,
deepCopy_v1_DaemonSet,
deepCopy_v1_DaemonSetList,
deepCopy_v1_DaemonSetSpec,
deepCopy_v1_DaemonSetStatus,
deepCopy_v1_Deployment,
deepCopy_v1_DeploymentList,
deepCopy_v1_DeploymentSpec,

View File

@ -28,7 +28,7 @@ func addDefaultingFuncs() {
obj.APIGroup = "experimental"
}
},
func(obj *Daemon) {
func(obj *DaemonSet) {
var labels map[string]string
if obj.Spec.Template != nil {
labels = obj.Spec.Template.Labels

View File

@ -26,14 +26,14 @@ import (
"k8s.io/kubernetes/pkg/util"
)
func TestSetDefaultDaemon(t *testing.T) {
func TestSetDefaultDaemonSet(t *testing.T) {
tests := []struct {
dc *Daemon
ds *DaemonSet
expectLabelsChange bool
}{
{
dc: &Daemon{
Spec: DaemonSpec{
ds: &DaemonSet{
Spec: DaemonSetSpec{
Template: &v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{
Labels: map[string]string{
@ -46,13 +46,13 @@ func TestSetDefaultDaemon(t *testing.T) {
expectLabelsChange: true,
},
{
dc: &Daemon{
ds: &DaemonSet{
ObjectMeta: v1.ObjectMeta{
Labels: map[string]string{
"bar": "foo",
},
},
Spec: DaemonSpec{
Spec: DaemonSetSpec{
Template: &v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{
Labels: map[string]string{
@ -67,18 +67,18 @@ func TestSetDefaultDaemon(t *testing.T) {
}
for _, test := range tests {
dc := test.dc
obj2 := roundTrip(t, runtime.Object(dc))
dc2, ok := obj2.(*Daemon)
ds := test.ds
obj2 := roundTrip(t, runtime.Object(ds))
ds2, ok := obj2.(*DaemonSet)
if !ok {
t.Errorf("unexpected object: %v", dc2)
t.Errorf("unexpected object: %v", ds2)
t.FailNow()
}
if test.expectLabelsChange != reflect.DeepEqual(dc2.Labels, dc2.Spec.Template.Labels) {
if test.expectLabelsChange != reflect.DeepEqual(ds2.Labels, ds2.Spec.Template.Labels) {
if test.expectLabelsChange {
t.Errorf("expected: %v, got: %v", dc2.Spec.Template.Labels, dc2.Labels)
t.Errorf("expected: %v, got: %v", ds2.Spec.Template.Labels, ds2.Labels)
} else {
t.Errorf("unexpected equality: %v", dc.Labels)
t.Errorf("unexpected equality: %v", ds.Labels)
}
}
}

View File

@ -40,8 +40,8 @@ func addKnownTypes() {
&Scale{},
&ThirdPartyResource{},
&ThirdPartyResourceList{},
&DaemonList{},
&Daemon{},
&DaemonSetList{},
&DaemonSet{},
&ThirdPartyResourceData{},
&ThirdPartyResourceDataList{},
)
@ -55,7 +55,7 @@ func (*ReplicationControllerDummy) IsAnAPIObject() {}
func (*Scale) IsAnAPIObject() {}
func (*ThirdPartyResource) IsAnAPIObject() {}
func (*ThirdPartyResourceList) IsAnAPIObject() {}
func (*Daemon) IsAnAPIObject() {}
func (*DaemonList) IsAnAPIObject() {}
func (*DaemonSet) IsAnAPIObject() {}
func (*DaemonSetList) IsAnAPIObject() {}
func (*ThirdPartyResourceData) IsAnAPIObject() {}
func (*ThirdPartyResourceDataList) IsAnAPIObject() {}

View File

@ -292,65 +292,65 @@ type DeploymentList struct {
Items []Deployment `json:"items"`
}
// DaemonSpec is the specification of a daemon.
type DaemonSpec struct {
// Selector is a label query over pods that are managed by the daemon.
// DaemonSetSpec is the specification of a daemon set.
type DaemonSetSpec struct {
// Selector is a label query over pods that are managed by the daemon set.
// Must match in order to be controlled.
// If empty, defaulted to labels on Pod template.
// More info: http://releases.k8s.io/HEAD/docs/user-guide/labels.md#label-selectors
Selector map[string]string `json:"selector,omitempty"`
// Template is the object that describes the pod that will be created.
// The Daemon will create exactly one copy of this pod on every node
// The DaemonSet will create exactly one copy of this pod on every node
// that matches the template's node selector (or on every node if no node
// selector is specified).
// More info: http://releases.k8s.io/HEAD/docs/user-guide/replication-controller.md#pod-template
Template *v1.PodTemplateSpec `json:"template,omitempty"`
}
// DaemonStatus represents the current status of a daemon.
type DaemonStatus struct {
// CurrentNumberScheduled is the number of nodes that are running exactly 1 copy of the
// daemon and are supposed to run the daemon.
// DaemonSetStatus represents the current status of a daemon set.
type DaemonSetStatus struct {
// CurrentNumberScheduled is the number of nodes that are running exactly 1
// daemon pod and are supposed to run the daemon pod.
CurrentNumberScheduled int `json:"currentNumberScheduled"`
// NumberMisscheduled is the number of nodes that are running the daemon, but are
// not supposed to run the daemon.
// NumberMisscheduled is the number of nodes that are running the daemon pod, but are
// not supposed to run the daemon pod.
NumberMisscheduled int `json:"numberMisscheduled"`
// DesiredNumberScheduled is the total number of nodes that should be running the daemon
// (including nodes correctly running the daemon).
// pod (including nodes correctly running the daemon pod).
DesiredNumberScheduled int `json:"desiredNumberScheduled"`
}
// Daemon represents the configuration of a daemon.
type Daemon struct {
// DaemonSet represents the configuration of a daemon set.
type DaemonSet struct {
v1.TypeMeta `json:",inline"`
// Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
v1.ObjectMeta `json:"metadata,omitempty"`
// Spec defines the desired behavior of this daemon.
// Spec defines the desired behavior of this daemon set.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
Spec DaemonSpec `json:"spec,omitempty"`
Spec DaemonSetSpec `json:"spec,omitempty"`
// Status is the current status of this daemon. This data may be
// Status is the current status of this daemon set. This data may be
// out of date by some window of time.
// Populated by the system.
// Read-only.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
Status DaemonStatus `json:"status,omitempty"`
Status DaemonSetStatus `json:"status,omitempty"`
}
// DaemonList is a list of Daemons.
type DaemonList struct {
// DaemonSetList is a collection of daemon sets.
type DaemonSetList struct {
v1.TypeMeta `json:",inline"`
// Standard list metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
v1.ListMeta `json:"metadata,omitempty"`
// Items is the list of Daemons.
Items []Daemon `json:"items"`
// Items is a list of daemon sets.
Items []DaemonSet `json:"items"`
}
// ThirdPartyResrouceDataList is a list of ThirdPartyResourceData.

View File

@ -37,46 +37,46 @@ func (APIVersion) SwaggerDoc() map[string]string {
return map_APIVersion
}
var map_Daemon = map[string]string{
"": "Daemon represents the configuration of a daemon.",
var map_DaemonSet = map[string]string{
"": "DaemonSet represents the configuration of a daemon set.",
"metadata": "Standard object's metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata",
"spec": "Spec defines the desired behavior of this daemon. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status",
"status": "Status is the current status of this daemon. This data may be out of date by some window of time. Populated by the system. Read-only. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status",
"spec": "Spec defines the desired behavior of this daemon set. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status",
"status": "Status is the current status of this daemon set. This data may be out of date by some window of time. Populated by the system. Read-only. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status",
}
func (Daemon) SwaggerDoc() map[string]string {
return map_Daemon
func (DaemonSet) SwaggerDoc() map[string]string {
return map_DaemonSet
}
var map_DaemonList = map[string]string{
"": "DaemonList is a list of Daemons.",
var map_DaemonSetList = map[string]string{
"": "DaemonSetList is a collection of daemon sets.",
"metadata": "Standard list metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata",
"items": "Items is the list of Daemons.",
"items": "Items is a list of daemon sets.",
}
func (DaemonList) SwaggerDoc() map[string]string {
return map_DaemonList
func (DaemonSetList) SwaggerDoc() map[string]string {
return map_DaemonSetList
}
var map_DaemonSpec = map[string]string{
"": "DaemonSpec is the specification of a daemon.",
"selector": "Selector is a label query over pods that are managed by the daemon. Must match in order to be controlled. If empty, defaulted to labels on Pod template. More info: http://releases.k8s.io/HEAD/docs/user-guide/labels.md#label-selectors",
"template": "Template is the object that describes the pod that will be created. The Daemon will create exactly one copy of this pod on every node that matches the template's node selector (or on every node if no node selector is specified). More info: http://releases.k8s.io/HEAD/docs/user-guide/replication-controller.md#pod-template",
var map_DaemonSetSpec = map[string]string{
"": "DaemonSetSpec is the specification of a daemon set.",
"selector": "Selector is a label query over pods that are managed by the daemon set. Must match in order to be controlled. If empty, defaulted to labels on Pod template. More info: http://releases.k8s.io/HEAD/docs/user-guide/labels.md#label-selectors",
"template": "Template is the object that describes the pod that will be created. The DaemonSet will create exactly one copy of this pod on every node that matches the template's node selector (or on every node if no node selector is specified). More info: http://releases.k8s.io/HEAD/docs/user-guide/replication-controller.md#pod-template",
}
func (DaemonSpec) SwaggerDoc() map[string]string {
return map_DaemonSpec
func (DaemonSetSpec) SwaggerDoc() map[string]string {
return map_DaemonSetSpec
}
var map_DaemonStatus = map[string]string{
"": "DaemonStatus represents the current status of a daemon.",
"currentNumberScheduled": "CurrentNumberScheduled is the number of nodes that are running exactly 1 copy of the daemon and are supposed to run the daemon.",
"numberMisscheduled": "NumberMisscheduled is the number of nodes that are running the daemon, but are not supposed to run the daemon.",
"desiredNumberScheduled": "DesiredNumberScheduled is the total number of nodes that should be running the daemon (including nodes correctly running the daemon).",
var map_DaemonSetStatus = map[string]string{
"": "DaemonSetStatus represents the current status of a daemon set.",
"currentNumberScheduled": "CurrentNumberScheduled is the number of nodes that are running exactly 1 daemon pod and are supposed to run the daemon pod.",
"numberMisscheduled": "NumberMisscheduled is the number of nodes that are running the daemon pod, but are not supposed to run the daemon pod.",
"desiredNumberScheduled": "DesiredNumberScheduled is the total number of nodes that should be running the daemon pod (including nodes correctly running the daemon pod).",
}
func (DaemonStatus) SwaggerDoc() map[string]string {
return map_DaemonStatus
func (DaemonSetStatus) SwaggerDoc() map[string]string {
return map_DaemonSetStatus
}
var map_Deployment = map[string]string{

View File

@ -93,25 +93,25 @@ func ValidateThirdPartyResource(obj *expapi.ThirdPartyResource) errs.ValidationE
return allErrs
}
// ValidateDaemon tests if required fields in the daemon are set.
func ValidateDaemon(controller *expapi.Daemon) errs.ValidationErrorList {
// ValidateDaemonSet tests if required fields in the DaemonSet are set.
func ValidateDaemonSet(controller *expapi.DaemonSet) errs.ValidationErrorList {
allErrs := errs.ValidationErrorList{}
allErrs = append(allErrs, apivalidation.ValidateObjectMeta(&controller.ObjectMeta, true, apivalidation.ValidateReplicationControllerName).Prefix("metadata")...)
allErrs = append(allErrs, ValidateDaemonSpec(&controller.Spec).Prefix("spec")...)
allErrs = append(allErrs, ValidateDaemonSetSpec(&controller.Spec).Prefix("spec")...)
return allErrs
}
// ValidateDaemonUpdate tests if required fields in the daemon are set.
func ValidateDaemonUpdate(oldController, controller *expapi.Daemon) errs.ValidationErrorList {
// ValidateDaemonSetUpdate tests if required fields in the DaemonSet are set.
func ValidateDaemonSetUpdate(oldController, controller *expapi.DaemonSet) errs.ValidationErrorList {
allErrs := errs.ValidationErrorList{}
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&controller.ObjectMeta, &oldController.ObjectMeta).Prefix("metadata")...)
allErrs = append(allErrs, ValidateDaemonSpec(&controller.Spec).Prefix("spec")...)
allErrs = append(allErrs, ValidateDaemonTemplateUpdate(oldController.Spec.Template, controller.Spec.Template).Prefix("spec.template")...)
allErrs = append(allErrs, ValidateDaemonSetSpec(&controller.Spec).Prefix("spec")...)
allErrs = append(allErrs, ValidateDaemonSetTemplateUpdate(oldController.Spec.Template, controller.Spec.Template).Prefix("spec.template")...)
return allErrs
}
// ValidateDaemonTemplateUpdate tests that certain fields in the daemon's pod template are not updated.
func ValidateDaemonTemplateUpdate(oldPodTemplate, podTemplate *api.PodTemplateSpec) errs.ValidationErrorList {
// ValidateDaemonSetTemplateUpdate tests that certain fields in the daemon set's pod template are not updated.
func ValidateDaemonSetTemplateUpdate(oldPodTemplate, podTemplate *api.PodTemplateSpec) errs.ValidationErrorList {
allErrs := errs.ValidationErrorList{}
podSpec := podTemplate.Spec
// podTemplate.Spec is not a pointer, so we can modify NodeSelector and NodeName directly.
@ -125,8 +125,8 @@ func ValidateDaemonTemplateUpdate(oldPodTemplate, podTemplate *api.PodTemplateSp
return allErrs
}
// ValidateDaemonSpec tests if required fields in the daemon spec are set.
func ValidateDaemonSpec(spec *expapi.DaemonSpec) errs.ValidationErrorList {
// ValidateDaemonSetSpec tests if required fields in the DaemonSetSpec are set.
func ValidateDaemonSetSpec(spec *expapi.DaemonSetSpec) errs.ValidationErrorList {
allErrs := errs.ValidationErrorList{}
selector := labels.Set(spec.Selector).AsSelector()
@ -152,10 +152,10 @@ func ValidateDaemonSpec(spec *expapi.DaemonSpec) errs.ValidationErrorList {
return allErrs
}
// ValidateDaemonName can be used to check whether the given daemon name is valid.
// ValidateDaemonSetName can be used to check whether the given daemon set name is valid.
// Prefix indicates this name will be used as part of generation, in which case
// trailing dashes are allowed.
func ValidateDaemonName(name string, prefix bool) (bool, string) {
func ValidateDaemonSetName(name string, prefix bool) (bool, string) {
return apivalidation.NameIsDNSSubdomain(name, prefix)
}

View File

@ -130,7 +130,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
}
}
func TestValidateDaemonUpdate(t *testing.T) {
func TestValidateDaemonSetUpdate(t *testing.T) {
validSelector := map[string]string{"a": "b"}
validSelector2 := map[string]string{"c": "d"}
invalidSelector := map[string]string{"NoUppercaseOrSpecialCharsLike=Equals": "b"}
@ -211,54 +211,54 @@ func TestValidateDaemonUpdate(t *testing.T) {
},
}
type dcUpdateTest struct {
old expapi.Daemon
update expapi.Daemon
type dsUpdateTest struct {
old expapi.DaemonSet
update expapi.DaemonSet
}
successCases := []dcUpdateTest{
successCases := []dsUpdateTest{
{
old: expapi.Daemon{
old: expapi.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
Template: &validPodTemplateAbc.Template,
},
},
update: expapi.Daemon{
update: expapi.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
Template: &validPodTemplateAbc.Template,
},
},
},
{
old: expapi.Daemon{
old: expapi.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
Template: &validPodTemplateAbc.Template,
},
},
update: expapi.Daemon{
update: expapi.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector2,
Template: &validPodTemplateAbc2.Template,
},
},
},
{
old: expapi.Daemon{
old: expapi.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
Template: &validPodTemplateAbc.Template,
},
},
update: expapi.Daemon{
update: expapi.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
Template: &validPodTemplateNodeSelector.Template,
},
@ -268,86 +268,86 @@ func TestValidateDaemonUpdate(t *testing.T) {
for _, successCase := range successCases {
successCase.old.ObjectMeta.ResourceVersion = "1"
successCase.update.ObjectMeta.ResourceVersion = "1"
if errs := ValidateDaemonUpdate(&successCase.old, &successCase.update); len(errs) != 0 {
if errs := ValidateDaemonSetUpdate(&successCase.old, &successCase.update); len(errs) != 0 {
t.Errorf("expected success: %v", errs)
}
}
errorCases := map[string]dcUpdateTest{
errorCases := map[string]dsUpdateTest{
"change daemon name": {
old: expapi.Daemon{
old: expapi.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
Template: &validPodTemplateAbc.Template,
},
},
update: expapi.Daemon{
update: expapi.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
Template: &validPodTemplateAbc.Template,
},
},
},
"invalid selector": {
old: expapi.Daemon{
old: expapi.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
Template: &validPodTemplateAbc.Template,
},
},
update: expapi.Daemon{
update: expapi.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: invalidSelector,
Template: &validPodTemplateAbc.Template,
},
},
},
"invalid pod": {
old: expapi.Daemon{
old: expapi.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
Template: &validPodTemplateAbc.Template,
},
},
update: expapi.Daemon{
update: expapi.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
Template: &invalidPodTemplate.Template,
},
},
},
"change container image": {
old: expapi.Daemon{
old: expapi.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
Template: &validPodTemplateAbc.Template,
},
},
update: expapi.Daemon{
update: expapi.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
Template: &validPodTemplateDef.Template,
},
},
},
"read-write volume": {
old: expapi.Daemon{
old: expapi.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
Template: &validPodTemplateAbc.Template,
},
},
update: expapi.Daemon{
update: expapi.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
Template: &readWriteVolumePodTemplate.Template,
},
@ -355,13 +355,13 @@ func TestValidateDaemonUpdate(t *testing.T) {
},
}
for testName, errorCase := range errorCases {
if errs := ValidateDaemonUpdate(&errorCase.old, &errorCase.update); len(errs) == 0 {
if errs := ValidateDaemonSetUpdate(&errorCase.old, &errorCase.update); len(errs) == 0 {
t.Errorf("expected failure: %s", testName)
}
}
}
func TestValidateDaemon(t *testing.T) {
func TestValidateDaemonSet(t *testing.T) {
validSelector := map[string]string{"a": "b"}
validPodTemplate := api.PodTemplate{
Template: api.PodTemplateSpec{
@ -387,59 +387,59 @@ func TestValidateDaemon(t *testing.T) {
},
},
}
successCases := []expapi.Daemon{
successCases := []expapi.DaemonSet{
{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
Template: &validPodTemplate.Template,
},
},
{
ObjectMeta: api.ObjectMeta{Name: "abc-123", Namespace: api.NamespaceDefault},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
Template: &validPodTemplate.Template,
},
},
}
for _, successCase := range successCases {
if errs := ValidateDaemon(&successCase); len(errs) != 0 {
if errs := ValidateDaemonSet(&successCase); len(errs) != 0 {
t.Errorf("expected success: %v", errs)
}
}
errorCases := map[string]expapi.Daemon{
errorCases := map[string]expapi.DaemonSet{
"zero-length ID": {
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
Template: &validPodTemplate.Template,
},
},
"missing-namespace": {
ObjectMeta: api.ObjectMeta{Name: "abc-123"},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
Template: &validPodTemplate.Template,
},
},
"empty selector": {
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Template: &validPodTemplate.Template,
},
},
"selector_doesnt_match": {
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: map[string]string{"foo": "bar"},
Template: &validPodTemplate.Template,
},
},
"invalid manifest": {
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
},
},
@ -451,7 +451,7 @@ func TestValidateDaemon(t *testing.T) {
"NoUppercaseOrSpecialCharsLike=Equals": "bar",
},
},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
Template: &validPodTemplate.Template,
},
@ -464,7 +464,7 @@ func TestValidateDaemon(t *testing.T) {
"NoUppercaseOrSpecialCharsLike=Equals": "bar",
},
},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Template: &invalidPodTemplate.Template,
},
},
@ -476,7 +476,7 @@ func TestValidateDaemon(t *testing.T) {
"NoUppercaseOrSpecialCharsLike=Equals": "bar",
},
},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
Template: &validPodTemplate.Template,
},
@ -486,7 +486,7 @@ func TestValidateDaemon(t *testing.T) {
Name: "abc-123",
Namespace: api.NamespaceDefault,
},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
Template: &api.PodTemplateSpec{
Spec: api.PodSpec{
@ -505,7 +505,7 @@ func TestValidateDaemon(t *testing.T) {
Name: "abc-123",
Namespace: api.NamespaceDefault,
},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: validSelector,
Template: &api.PodTemplateSpec{
Spec: api.PodSpec{
@ -521,7 +521,7 @@ func TestValidateDaemon(t *testing.T) {
},
}
for k, v := range errorCases {
errs := ValidateDaemon(&v)
errs := ValidateDaemonSet(&v)
if len(errs) == 0 {
t.Errorf("expected failure for %s", k)
}

View File

@ -80,7 +80,7 @@ import (
"k8s.io/kubernetes/pkg/ui"
"k8s.io/kubernetes/pkg/util"
daemonetcd "k8s.io/kubernetes/pkg/registry/daemon/etcd"
daemonetcd "k8s.io/kubernetes/pkg/registry/daemonset/etcd"
horizontalpodautoscaleretcd "k8s.io/kubernetes/pkg/registry/horizontalpodautoscaler/etcd"
"github.com/emicklei/go-restful"
@ -824,7 +824,7 @@ func (m *Master) expapi(c *Config) *apiserver.APIGroupVersion {
controllerStorage := expcontrolleretcd.NewStorage(c.ExpDatabaseStorage)
autoscalerStorage := horizontalpodautoscaleretcd.NewREST(c.ExpDatabaseStorage)
thirdPartyResourceStorage := thirdpartyresourceetcd.NewREST(c.ExpDatabaseStorage)
daemonStorage := daemonetcd.NewREST(c.ExpDatabaseStorage)
daemonSetStorage := daemonetcd.NewREST(c.ExpDatabaseStorage)
deploymentStorage := deploymentetcd.NewREST(c.ExpDatabaseStorage)
storage := map[string]rest.Storage{
@ -832,7 +832,7 @@ func (m *Master) expapi(c *Config) *apiserver.APIGroupVersion {
strings.ToLower("replicationControllers/scale"): controllerStorage.Scale,
strings.ToLower("horizontalpodautoscalers"): autoscalerStorage,
strings.ToLower("thirdpartyresources"): thirdPartyResourceStorage,
strings.ToLower("daemons"): daemonStorage,
strings.ToLower("daemonsets"): daemonSetStorage,
strings.ToLower("deployments"): deploymentStorage,
}

View File

@ -14,6 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// Package daemon provides Registry interface and its RESTStorage
// implementation for storing Daemon api objects.
package daemon
// Package daemonset provides Registry interface and its RESTStorage
// implementation for storing DaemonSet api objects.
package daemonset

View File

@ -21,29 +21,28 @@ import (
"k8s.io/kubernetes/pkg/expapi"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/daemon"
"k8s.io/kubernetes/pkg/registry/daemonset"
"k8s.io/kubernetes/pkg/registry/generic"
etcdgeneric "k8s.io/kubernetes/pkg/registry/generic/etcd"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
)
// rest implements a RESTStorage for daemons against etcd
// rest implements a RESTStorage for DaemonSets against etcd
type REST struct {
*etcdgeneric.Etcd
}
// daemonPrefix is the location for daemons in etcd, only exposed
// for testing
var daemonPrefix = "/daemons"
// daemonPrefix is the location for daemons in etcd
var daemonPrefix = "/daemonsets"
// NewREST returns a RESTStorage object that will work against daemons.
// NewREST returns a RESTStorage object that will work against DaemonSets.
func NewREST(s storage.Interface) *REST {
store := &etcdgeneric.Etcd{
NewFunc: func() runtime.Object { return &expapi.Daemon{} },
NewFunc: func() runtime.Object { return &expapi.DaemonSet{} },
// NewListFunc returns an object capable of storing results of an etcd list.
NewListFunc: func() runtime.Object { return &expapi.DaemonList{} },
NewListFunc: func() runtime.Object { return &expapi.DaemonSetList{} },
// Produces a path that etcd understands, to the root of the resource
// by combining the namespace in the context with the given prefix
KeyRootFunc: func(ctx api.Context) string {
@ -54,21 +53,21 @@ func NewREST(s storage.Interface) *REST {
KeyFunc: func(ctx api.Context, name string) (string, error) {
return etcdgeneric.NamespaceKeyFunc(ctx, daemonPrefix, name)
},
// Retrieve the name field of a daemon
// Retrieve the name field of a daemon set
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*expapi.Daemon).Name, nil
return obj.(*expapi.DaemonSet).Name, nil
},
// Used to match objects based on labels/fields for list and watch
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
return daemon.MatchDaemon(label, field)
return daemonset.MatchDaemonSet(label, field)
},
EndpointName: "daemons",
EndpointName: "daemonsets",
// Used to validate daemon creation
CreateStrategy: daemon.Strategy,
// Used to validate daemon set creation
CreateStrategy: daemonset.Strategy,
// Used to validate daemon updates
UpdateStrategy: daemon.Strategy,
// Used to validate daemon set updates
UpdateStrategy: daemonset.Strategy,
Storage: s,
}

View File

@ -33,13 +33,13 @@ func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) {
return NewREST(etcdStorage), fakeClient
}
func validNewDaemon() *expapi.Daemon {
return &expapi.Daemon{
func newValidDaemonSet() *expapi.DaemonSet {
return &expapi.DaemonSet{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Namespace: api.NamespaceDefault,
},
Spec: expapi.DaemonSpec{
Spec: expapi.DaemonSetSpec{
Selector: map[string]string{"a": "b"},
Template: &api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{
@ -61,21 +61,21 @@ func validNewDaemon() *expapi.Daemon {
}
}
var validDaemon = validNewDaemon()
var validDaemonSet = newValidDaemonSet()
func TestCreate(t *testing.T) {
storage, fakeClient := newStorage(t)
test := registrytest.New(t, fakeClient, storage.Etcd)
daemon := validNewDaemon()
daemon.ObjectMeta = api.ObjectMeta{}
ds := newValidDaemonSet()
ds.ObjectMeta = api.ObjectMeta{}
test.TestCreate(
// valid
daemon,
ds,
// invalid (invalid selector)
&expapi.Daemon{
Spec: expapi.DaemonSpec{
&expapi.DaemonSet{
Spec: expapi.DaemonSetSpec{
Selector: map[string]string{},
Template: validDaemon.Spec.Template,
Template: validDaemonSet.Spec.Template,
},
},
)
@ -86,31 +86,31 @@ func TestUpdate(t *testing.T) {
test := registrytest.New(t, fakeClient, storage.Etcd)
test.TestUpdate(
// valid
validNewDaemon(),
newValidDaemonSet(),
// updateFunc
func(obj runtime.Object) runtime.Object {
object := obj.(*expapi.Daemon)
object := obj.(*expapi.DaemonSet)
object.Spec.Template.Spec.NodeSelector = map[string]string{"c": "d"}
return object
},
// invalid updateFunc
func(obj runtime.Object) runtime.Object {
object := obj.(*expapi.Daemon)
object := obj.(*expapi.DaemonSet)
object.UID = "newUID"
return object
},
func(obj runtime.Object) runtime.Object {
object := obj.(*expapi.Daemon)
object := obj.(*expapi.DaemonSet)
object.Name = ""
return object
},
func(obj runtime.Object) runtime.Object {
object := obj.(*expapi.Daemon)
object := obj.(*expapi.DaemonSet)
object.Spec.Template.Spec.RestartPolicy = api.RestartPolicyOnFailure
return object
},
func(obj runtime.Object) runtime.Object {
object := obj.(*expapi.Daemon)
object := obj.(*expapi.DaemonSet)
object.Spec.Selector = map[string]string{}
return object
},
@ -120,26 +120,26 @@ func TestUpdate(t *testing.T) {
func TestDelete(t *testing.T) {
storage, fakeClient := newStorage(t)
test := registrytest.New(t, fakeClient, storage.Etcd)
test.TestDelete(validNewDaemon())
test.TestDelete(newValidDaemonSet())
}
func TestGet(t *testing.T) {
storage, fakeClient := newStorage(t)
test := registrytest.New(t, fakeClient, storage.Etcd)
test.TestGet(validNewDaemon())
test.TestGet(newValidDaemonSet())
}
func TestList(t *testing.T) {
storage, fakeClient := newStorage(t)
test := registrytest.New(t, fakeClient, storage.Etcd)
test.TestList(validNewDaemon())
test.TestList(newValidDaemonSet())
}
func TestWatch(t *testing.T) {
storage, fakeClient := newStorage(t)
test := registrytest.New(t, fakeClient, storage.Etcd)
test.TestWatch(
validDaemon,
validDaemonSet,
// matching labels
[]labels.Set{
{"a": "b"},

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package daemon
package daemonset
import (
"fmt"
@ -30,32 +30,32 @@ import (
"k8s.io/kubernetes/pkg/util/fielderrors"
)
// daemonStrategy implements verification logic for daemons.
type daemonStrategy struct {
// daemonSetStrategy implements verification logic for daemon sets.
type daemonSetStrategy struct {
runtime.ObjectTyper
api.NameGenerator
}
// Strategy is the default logic that applies when creating and updating Daemon objects.
var Strategy = daemonStrategy{api.Scheme, api.SimpleNameGenerator}
// Strategy is the default logic that applies when creating and updating DaemonSet objects.
var Strategy = daemonSetStrategy{api.Scheme, api.SimpleNameGenerator}
// NamespaceScoped returns true because all Daemons need to be within a namespace.
func (daemonStrategy) NamespaceScoped() bool {
// NamespaceScoped returns true because all DaemonSets need to be within a namespace.
func (daemonSetStrategy) NamespaceScoped() bool {
return true
}
// PrepareForCreate clears the status of a daemon before creation.
func (daemonStrategy) PrepareForCreate(obj runtime.Object) {
daemon := obj.(*expapi.Daemon)
daemon.Status = expapi.DaemonStatus{}
// PrepareForCreate clears the status of a daemon set before creation.
func (daemonSetStrategy) PrepareForCreate(obj runtime.Object) {
daemonSet := obj.(*expapi.DaemonSet)
daemonSet.Status = expapi.DaemonSetStatus{}
daemon.Generation = 1
daemonSet.Generation = 1
}
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (daemonStrategy) PrepareForUpdate(obj, old runtime.Object) {
newDaemon := obj.(*expapi.Daemon)
oldDaemon := old.(*expapi.Daemon)
func (daemonSetStrategy) PrepareForUpdate(obj, old runtime.Object) {
newDaemonSet := obj.(*expapi.DaemonSet)
oldDaemonSet := old.(*expapi.DaemonSet)
// Any changes to the spec increment the generation number, any changes to the
// status should reflect the generation number of the corresponding object. We push
@ -64,59 +64,59 @@ func (daemonStrategy) PrepareForUpdate(obj, old runtime.Object) {
// we can at first -- since obj contains spec -- but in the future we will probably make
// status its own object, and even if we don't, writes may be the result of a
// read-update-write loop, so the contents of spec may not actually be the spec that
// the controller has *seen*.
// the manager has *seen*.
//
// TODO: Any changes to a part of the object that represents desired state (labels,
// annotations etc) should also increment the generation.
if !reflect.DeepEqual(oldDaemon.Spec, newDaemon.Spec) {
newDaemon.Generation = oldDaemon.Generation + 1
if !reflect.DeepEqual(oldDaemonSet.Spec, newDaemonSet.Spec) {
newDaemonSet.Generation = oldDaemonSet.Generation + 1
}
}
// Validate validates a new daemon.
func (daemonStrategy) Validate(ctx api.Context, obj runtime.Object) fielderrors.ValidationErrorList {
daemon := obj.(*expapi.Daemon)
return validation.ValidateDaemon(daemon)
// Validate validates a new daemon set.
func (daemonSetStrategy) Validate(ctx api.Context, obj runtime.Object) fielderrors.ValidationErrorList {
daemonSet := obj.(*expapi.DaemonSet)
return validation.ValidateDaemonSet(daemonSet)
}
// AllowCreateOnUpdate is false for daemon; this means a POST is
// AllowCreateOnUpdate is false for daemon set; this means a POST is
// needed to create one
func (daemonStrategy) AllowCreateOnUpdate() bool {
func (daemonSetStrategy) AllowCreateOnUpdate() bool {
return false
}
// ValidateUpdate is the default update validation for an end user.
func (daemonStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
validationErrorList := validation.ValidateDaemon(obj.(*expapi.Daemon))
updateErrorList := validation.ValidateDaemonUpdate(old.(*expapi.Daemon), obj.(*expapi.Daemon))
func (daemonSetStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
validationErrorList := validation.ValidateDaemonSet(obj.(*expapi.DaemonSet))
updateErrorList := validation.ValidateDaemonSetUpdate(old.(*expapi.DaemonSet), obj.(*expapi.DaemonSet))
return append(validationErrorList, updateErrorList...)
}
// AllowUnconditionalUpdate is the default update policy for daemon objects.
func (daemonStrategy) AllowUnconditionalUpdate() bool {
// AllowUnconditionalUpdate is the default update policy for daemon set objects.
func (daemonSetStrategy) AllowUnconditionalUpdate() bool {
return true
}
// DaemonToSelectableFields returns a field set that represents the object.
func DaemonToSelectableFields(daemon *expapi.Daemon) fields.Set {
// DaemonSetToSelectableFields returns a field set that represents the object.
func DaemonSetToSelectableFields(daemon *expapi.DaemonSet) fields.Set {
return fields.Set{
"metadata.name": daemon.Name,
}
}
// MatchDaemon is the filter used by the generic etcd backend to route
// MatchSetDaemon is the filter used by the generic etcd backend to route
// watch events from etcd to clients of the apiserver only interested in specific
// labels/fields.
func MatchDaemon(label labels.Selector, field fields.Selector) generic.Matcher {
func MatchDaemonSet(label labels.Selector, field fields.Selector) generic.Matcher {
return &generic.SelectionPredicate{
Label: label,
Field: field,
GetAttrs: func(obj runtime.Object) (labels.Set, fields.Set, error) {
daemon, ok := obj.(*expapi.Daemon)
ds, ok := obj.(*expapi.DaemonSet)
if !ok {
return nil, nil, fmt.Errorf("given object is not a daemon.")
return nil, nil, fmt.Errorf("given object is not a ds.")
}
return labels.Set(daemon.ObjectMeta.Labels), DaemonToSelectableFields(daemon), nil
return labels.Set(ds.ObjectMeta.Labels), DaemonSetToSelectableFields(ds), nil
},
}
}