experimental. -> extensions.
This commit is contained in:
@@ -39,10 +39,10 @@ var daemonPrefix = "/daemonsets"
|
||||
// NewREST returns a RESTStorage object that will work against DaemonSets.
|
||||
func NewREST(s storage.Interface) (*REST, *StatusREST) {
|
||||
store := &etcdgeneric.Etcd{
|
||||
NewFunc: func() runtime.Object { return &experimental.DaemonSet{} },
|
||||
NewFunc: func() runtime.Object { return &extensions.DaemonSet{} },
|
||||
|
||||
// NewListFunc returns an object capable of storing results of an etcd list.
|
||||
NewListFunc: func() runtime.Object { return &experimental.DaemonSetList{} },
|
||||
NewListFunc: func() runtime.Object { return &extensions.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 {
|
||||
@@ -55,7 +55,7 @@ func NewREST(s storage.Interface) (*REST, *StatusREST) {
|
||||
},
|
||||
// Retrieve the name field of a daemon set
|
||||
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
||||
return obj.(*experimental.DaemonSet).Name, nil
|
||||
return obj.(*extensions.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 {
|
||||
@@ -83,7 +83,7 @@ type StatusREST struct {
|
||||
}
|
||||
|
||||
func (r *StatusREST) New() runtime.Object {
|
||||
return &experimental.DaemonSet{}
|
||||
return &extensions.DaemonSet{}
|
||||
}
|
||||
|
||||
// Update alters the status subset of an object.
|
||||
|
||||
@@ -34,13 +34,13 @@ func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient) {
|
||||
return storage, statusStorage, fakeClient
|
||||
}
|
||||
|
||||
func newValidDaemonSet() *experimental.DaemonSet {
|
||||
return &experimental.DaemonSet{
|
||||
func newValidDaemonSet() *extensions.DaemonSet {
|
||||
return &extensions.DaemonSet{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: map[string]string{"a": "b"},
|
||||
Template: &api.PodTemplateSpec{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
@@ -73,8 +73,8 @@ func TestCreate(t *testing.T) {
|
||||
// valid
|
||||
ds,
|
||||
// invalid (invalid selector)
|
||||
&experimental.DaemonSet{
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
&extensions.DaemonSet{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: map[string]string{},
|
||||
Template: validDaemonSet.Spec.Template,
|
||||
},
|
||||
@@ -90,28 +90,28 @@ func TestUpdate(t *testing.T) {
|
||||
newValidDaemonSet(),
|
||||
// updateFunc
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*experimental.DaemonSet)
|
||||
object := obj.(*extensions.DaemonSet)
|
||||
object.Spec.Template.Spec.NodeSelector = map[string]string{"c": "d"}
|
||||
return object
|
||||
},
|
||||
// invalid updateFunc
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*experimental.DaemonSet)
|
||||
object := obj.(*extensions.DaemonSet)
|
||||
object.UID = "newUID"
|
||||
return object
|
||||
},
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*experimental.DaemonSet)
|
||||
object := obj.(*extensions.DaemonSet)
|
||||
object.Name = ""
|
||||
return object
|
||||
},
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*experimental.DaemonSet)
|
||||
object := obj.(*extensions.DaemonSet)
|
||||
object.Spec.Template.Spec.RestartPolicy = api.RestartPolicyOnFailure
|
||||
return object
|
||||
},
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*experimental.DaemonSet)
|
||||
object := obj.(*extensions.DaemonSet)
|
||||
object.Spec.Selector = map[string]string{}
|
||||
return object
|
||||
},
|
||||
|
||||
@@ -46,16 +46,16 @@ func (daemonSetStrategy) NamespaceScoped() bool {
|
||||
|
||||
// PrepareForCreate clears the status of a daemon set before creation.
|
||||
func (daemonSetStrategy) PrepareForCreate(obj runtime.Object) {
|
||||
daemonSet := obj.(*experimental.DaemonSet)
|
||||
daemonSet.Status = experimental.DaemonSetStatus{}
|
||||
daemonSet := obj.(*extensions.DaemonSet)
|
||||
daemonSet.Status = extensions.DaemonSetStatus{}
|
||||
|
||||
daemonSet.Generation = 1
|
||||
}
|
||||
|
||||
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
|
||||
func (daemonSetStrategy) PrepareForUpdate(obj, old runtime.Object) {
|
||||
newDaemonSet := obj.(*experimental.DaemonSet)
|
||||
oldDaemonSet := old.(*experimental.DaemonSet)
|
||||
newDaemonSet := obj.(*extensions.DaemonSet)
|
||||
oldDaemonSet := old.(*extensions.DaemonSet)
|
||||
|
||||
// update is not allowed to set status
|
||||
newDaemonSet.Status = oldDaemonSet.Status
|
||||
@@ -78,7 +78,7 @@ func (daemonSetStrategy) PrepareForUpdate(obj, old runtime.Object) {
|
||||
|
||||
// Validate validates a new daemon set.
|
||||
func (daemonSetStrategy) Validate(ctx api.Context, obj runtime.Object) fielderrors.ValidationErrorList {
|
||||
daemonSet := obj.(*experimental.DaemonSet)
|
||||
daemonSet := obj.(*extensions.DaemonSet)
|
||||
return validation.ValidateDaemonSet(daemonSet)
|
||||
}
|
||||
|
||||
@@ -90,8 +90,8 @@ func (daemonSetStrategy) AllowCreateOnUpdate() bool {
|
||||
|
||||
// ValidateUpdate is the default update validation for an end user.
|
||||
func (daemonSetStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
||||
validationErrorList := validation.ValidateDaemonSet(obj.(*experimental.DaemonSet))
|
||||
updateErrorList := validation.ValidateDaemonSetUpdate(old.(*experimental.DaemonSet), obj.(*experimental.DaemonSet))
|
||||
validationErrorList := validation.ValidateDaemonSet(obj.(*extensions.DaemonSet))
|
||||
updateErrorList := validation.ValidateDaemonSetUpdate(old.(*extensions.DaemonSet), obj.(*extensions.DaemonSet))
|
||||
return append(validationErrorList, updateErrorList...)
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ func (daemonSetStrategy) AllowUnconditionalUpdate() bool {
|
||||
}
|
||||
|
||||
// DaemonSetToSelectableFields returns a field set that represents the object.
|
||||
func DaemonSetToSelectableFields(daemon *experimental.DaemonSet) fields.Set {
|
||||
func DaemonSetToSelectableFields(daemon *extensions.DaemonSet) fields.Set {
|
||||
return fields.Set{
|
||||
"metadata.name": daemon.Name,
|
||||
}
|
||||
@@ -115,7 +115,7 @@ func MatchDaemonSet(label labels.Selector, field fields.Selector) generic.Matche
|
||||
Label: label,
|
||||
Field: field,
|
||||
GetAttrs: func(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||
ds, ok := obj.(*experimental.DaemonSet)
|
||||
ds, ok := obj.(*extensions.DaemonSet)
|
||||
if !ok {
|
||||
return nil, nil, fmt.Errorf("given object is not a ds.")
|
||||
}
|
||||
@@ -131,11 +131,11 @@ type daemonSetStatusStrategy struct {
|
||||
var StatusStrategy = daemonSetStatusStrategy{Strategy}
|
||||
|
||||
func (daemonSetStatusStrategy) PrepareForUpdate(obj, old runtime.Object) {
|
||||
newDaemonSet := obj.(*experimental.DaemonSet)
|
||||
oldDaemonSet := old.(*experimental.DaemonSet)
|
||||
newDaemonSet := obj.(*extensions.DaemonSet)
|
||||
oldDaemonSet := old.(*extensions.DaemonSet)
|
||||
newDaemonSet.Spec = oldDaemonSet.Spec
|
||||
}
|
||||
|
||||
func (daemonSetStatusStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
||||
return validation.ValidateDaemonSetStatusUpdate(obj.(*experimental.DaemonSet), old.(*experimental.DaemonSet))
|
||||
return validation.ValidateDaemonSetStatusUpdate(obj.(*extensions.DaemonSet), old.(*extensions.DaemonSet))
|
||||
}
|
||||
|
||||
@@ -56,9 +56,9 @@ type REST struct {
|
||||
func NewREST(s storage.Interface) *REST {
|
||||
prefix := "/deployments"
|
||||
store := &etcdgeneric.Etcd{
|
||||
NewFunc: func() runtime.Object { return &experimental.Deployment{} },
|
||||
NewFunc: func() runtime.Object { return &extensions.Deployment{} },
|
||||
// NewListFunc returns an object capable of storing results of an etcd list.
|
||||
NewListFunc: func() runtime.Object { return &experimental.DeploymentList{} },
|
||||
NewListFunc: func() runtime.Object { return &extensions.DeploymentList{} },
|
||||
// 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 {
|
||||
@@ -71,7 +71,7 @@ func NewREST(s storage.Interface) *REST {
|
||||
},
|
||||
// Retrieve the name field of a deployment.
|
||||
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
||||
return obj.(*experimental.Deployment).Name, nil
|
||||
return obj.(*extensions.Deployment).Name, nil
|
||||
},
|
||||
// Used to match objects based on labels/fields for list.
|
||||
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
|
||||
@@ -99,7 +99,7 @@ var _ = rest.Patcher(&ScaleREST{})
|
||||
|
||||
// New creates a new Scale object
|
||||
func (r *ScaleREST) New() runtime.Object {
|
||||
return &experimental.Scale{}
|
||||
return &extensions.Scale{}
|
||||
}
|
||||
|
||||
func (r *ScaleREST) Get(ctx api.Context, name string) (runtime.Object, error) {
|
||||
@@ -107,16 +107,16 @@ func (r *ScaleREST) Get(ctx api.Context, name string) (runtime.Object, error) {
|
||||
if err != nil {
|
||||
return nil, errors.NewNotFound("scale", name)
|
||||
}
|
||||
return &experimental.Scale{
|
||||
return &extensions.Scale{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: deployment.Namespace,
|
||||
CreationTimestamp: deployment.CreationTimestamp,
|
||||
},
|
||||
Spec: experimental.ScaleSpec{
|
||||
Spec: extensions.ScaleSpec{
|
||||
Replicas: deployment.Spec.Replicas,
|
||||
},
|
||||
Status: experimental.ScaleStatus{
|
||||
Status: extensions.ScaleStatus{
|
||||
Replicas: deployment.Status.Replicas,
|
||||
Selector: deployment.Spec.Selector,
|
||||
},
|
||||
@@ -127,7 +127,7 @@ func (r *ScaleREST) Update(ctx api.Context, obj runtime.Object) (runtime.Object,
|
||||
if obj == nil {
|
||||
return nil, false, errors.NewBadRequest(fmt.Sprintf("nil update passed to Scale"))
|
||||
}
|
||||
scale, ok := obj.(*experimental.Scale)
|
||||
scale, ok := obj.(*extensions.Scale)
|
||||
if !ok {
|
||||
return nil, false, errors.NewBadRequest(fmt.Sprintf("wrong object passed to Scale update: %v", obj))
|
||||
}
|
||||
@@ -140,16 +140,16 @@ func (r *ScaleREST) Update(ctx api.Context, obj runtime.Object) (runtime.Object,
|
||||
if err != nil {
|
||||
return nil, false, errors.NewConflict("scale", scale.Name, err)
|
||||
}
|
||||
return &experimental.Scale{
|
||||
return &extensions.Scale{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: deployment.Name,
|
||||
Namespace: deployment.Namespace,
|
||||
CreationTimestamp: deployment.CreationTimestamp,
|
||||
},
|
||||
Spec: experimental.ScaleSpec{
|
||||
Spec: extensions.ScaleSpec{
|
||||
Replicas: deployment.Spec.Replicas,
|
||||
},
|
||||
Status: experimental.ScaleStatus{
|
||||
Status: extensions.ScaleStatus{
|
||||
Replicas: deployment.Status.Replicas,
|
||||
Selector: deployment.Spec.Selector,
|
||||
},
|
||||
|
||||
@@ -40,13 +40,13 @@ func newStorage(t *testing.T) (*DeploymentStorage, *tools.FakeEtcdClient) {
|
||||
var namespace = "foo-namespace"
|
||||
var name = "foo-deployment"
|
||||
|
||||
func validNewDeployment() *experimental.Deployment {
|
||||
return &experimental.Deployment{
|
||||
func validNewDeployment() *extensions.Deployment {
|
||||
return &extensions.Deployment{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
},
|
||||
Spec: experimental.DeploymentSpec{
|
||||
Spec: extensions.DeploymentSpec{
|
||||
Selector: map[string]string{"a": "b"},
|
||||
Template: &api.PodTemplateSpec{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
@@ -67,7 +67,7 @@ func validNewDeployment() *experimental.Deployment {
|
||||
UniqueLabelKey: "my-label",
|
||||
Replicas: 7,
|
||||
},
|
||||
Status: experimental.DeploymentStatus{
|
||||
Status: extensions.DeploymentStatus{
|
||||
Replicas: 5,
|
||||
},
|
||||
}
|
||||
@@ -75,13 +75,13 @@ func validNewDeployment() *experimental.Deployment {
|
||||
|
||||
var validDeployment = *validNewDeployment()
|
||||
|
||||
func validNewScale() *experimental.Scale {
|
||||
return &experimental.Scale{
|
||||
func validNewScale() *extensions.Scale {
|
||||
return &extensions.Scale{
|
||||
ObjectMeta: api.ObjectMeta{Name: name, Namespace: namespace},
|
||||
Spec: experimental.ScaleSpec{
|
||||
Spec: extensions.ScaleSpec{
|
||||
Replicas: validDeployment.Spec.Replicas,
|
||||
},
|
||||
Status: experimental.ScaleStatus{
|
||||
Status: extensions.ScaleStatus{
|
||||
Replicas: validDeployment.Status.Replicas,
|
||||
Selector: validDeployment.Spec.Template.Labels,
|
||||
},
|
||||
@@ -99,8 +99,8 @@ func TestCreate(t *testing.T) {
|
||||
// valid
|
||||
deployment,
|
||||
// invalid (invalid selector)
|
||||
&experimental.Deployment{
|
||||
Spec: experimental.DeploymentSpec{
|
||||
&extensions.Deployment{
|
||||
Spec: extensions.DeploymentSpec{
|
||||
Selector: map[string]string{},
|
||||
Template: validDeployment.Spec.Template,
|
||||
},
|
||||
@@ -116,28 +116,28 @@ func TestUpdate(t *testing.T) {
|
||||
validNewDeployment(),
|
||||
// updateFunc
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*experimental.Deployment)
|
||||
object := obj.(*extensions.Deployment)
|
||||
object.Spec.Template.Spec.NodeSelector = map[string]string{"c": "d"}
|
||||
return object
|
||||
},
|
||||
// invalid updateFunc
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*experimental.Deployment)
|
||||
object := obj.(*extensions.Deployment)
|
||||
object.UID = "newUID"
|
||||
return object
|
||||
},
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*experimental.Deployment)
|
||||
object := obj.(*extensions.Deployment)
|
||||
object.Name = ""
|
||||
return object
|
||||
},
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*experimental.Deployment)
|
||||
object := obj.(*extensions.Deployment)
|
||||
object.Spec.Template.Spec.RestartPolicy = api.RestartPolicyOnFailure
|
||||
return object
|
||||
},
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*experimental.Deployment)
|
||||
object := obj.(*extensions.Deployment)
|
||||
object.Spec.Selector = map[string]string{}
|
||||
return object
|
||||
},
|
||||
@@ -197,7 +197,7 @@ func TestScaleGet(t *testing.T) {
|
||||
|
||||
expect := &validScale
|
||||
obj, err := storage.Scale.Get(ctx, name)
|
||||
scale := obj.(*experimental.Scale)
|
||||
scale := obj.(*extensions.Scale)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -215,9 +215,9 @@ func TestScaleUpdate(t *testing.T) {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
replicas := 12
|
||||
update := experimental.Scale{
|
||||
update := extensions.Scale{
|
||||
ObjectMeta: api.ObjectMeta{Name: name, Namespace: namespace},
|
||||
Spec: experimental.ScaleSpec{
|
||||
Spec: extensions.ScaleSpec{
|
||||
Replicas: replicas,
|
||||
},
|
||||
}
|
||||
@@ -230,7 +230,7 @@ func TestScaleUpdate(t *testing.T) {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
var deployment experimental.Deployment
|
||||
var deployment extensions.Deployment
|
||||
testapi.Extensions.Codec().DecodeInto([]byte(response.Node.Value), &deployment)
|
||||
if deployment.Spec.Replicas != replicas {
|
||||
t.Errorf("wrong replicas count expected: %d got: %d", replicas, deployment.Spec.Replicas)
|
||||
|
||||
@@ -28,10 +28,10 @@ import (
|
||||
|
||||
// Registry is an interface for things that know how to store Deployments.
|
||||
type Registry interface {
|
||||
ListDeployments(ctx api.Context, label labels.Selector, field fields.Selector) (*experimental.DeploymentList, error)
|
||||
GetDeployment(ctx api.Context, deploymentID string) (*experimental.Deployment, error)
|
||||
CreateDeployment(ctx api.Context, deployment *experimental.Deployment) (*experimental.Deployment, error)
|
||||
UpdateDeployment(ctx api.Context, deployment *experimental.Deployment) (*experimental.Deployment, error)
|
||||
ListDeployments(ctx api.Context, label labels.Selector, field fields.Selector) (*extensions.DeploymentList, error)
|
||||
GetDeployment(ctx api.Context, deploymentID string) (*extensions.Deployment, error)
|
||||
CreateDeployment(ctx api.Context, deployment *extensions.Deployment) (*extensions.Deployment, error)
|
||||
UpdateDeployment(ctx api.Context, deployment *extensions.Deployment) (*extensions.Deployment, error)
|
||||
DeleteDeployment(ctx api.Context, deploymentID string) error
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
|
||||
}
|
||||
|
||||
// List obtains a list of Deployments that match selector.
|
||||
func (s *storage) ListDeployments(ctx api.Context, label labels.Selector, field fields.Selector) (*experimental.DeploymentList, error) {
|
||||
func (s *storage) ListDeployments(ctx api.Context, label labels.Selector, field fields.Selector) (*extensions.DeploymentList, error) {
|
||||
if !field.Empty() {
|
||||
return nil, fmt.Errorf("field selector not supported yet")
|
||||
}
|
||||
@@ -54,31 +54,31 @@ func (s *storage) ListDeployments(ctx api.Context, label labels.Selector, field
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*experimental.DeploymentList), err
|
||||
return obj.(*extensions.DeploymentList), err
|
||||
}
|
||||
|
||||
func (s *storage) GetDeployment(ctx api.Context, deploymentID string) (*experimental.Deployment, error) {
|
||||
func (s *storage) GetDeployment(ctx api.Context, deploymentID string) (*extensions.Deployment, error) {
|
||||
obj, err := s.Get(ctx, deploymentID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*experimental.Deployment), nil
|
||||
return obj.(*extensions.Deployment), nil
|
||||
}
|
||||
|
||||
func (s *storage) CreateDeployment(ctx api.Context, deployment *experimental.Deployment) (*experimental.Deployment, error) {
|
||||
func (s *storage) CreateDeployment(ctx api.Context, deployment *extensions.Deployment) (*extensions.Deployment, error) {
|
||||
obj, err := s.Create(ctx, deployment)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*experimental.Deployment), nil
|
||||
return obj.(*extensions.Deployment), nil
|
||||
}
|
||||
|
||||
func (s *storage) UpdateDeployment(ctx api.Context, deployment *experimental.Deployment) (*experimental.Deployment, error) {
|
||||
func (s *storage) UpdateDeployment(ctx api.Context, deployment *extensions.Deployment) (*extensions.Deployment, error) {
|
||||
obj, _, err := s.Update(ctx, deployment)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*experimental.Deployment), nil
|
||||
return obj.(*extensions.Deployment), nil
|
||||
}
|
||||
|
||||
func (s *storage) DeleteDeployment(ctx api.Context, deploymentID string) error {
|
||||
|
||||
@@ -50,7 +50,7 @@ func (deploymentStrategy) PrepareForCreate(obj runtime.Object) {
|
||||
|
||||
// Validate validates a new deployment.
|
||||
func (deploymentStrategy) Validate(ctx api.Context, obj runtime.Object) errs.ValidationErrorList {
|
||||
deployment := obj.(*experimental.Deployment)
|
||||
deployment := obj.(*extensions.Deployment)
|
||||
return validation.ValidateDeployment(deployment)
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ func (deploymentStrategy) PrepareForUpdate(obj, old runtime.Object) {
|
||||
|
||||
// ValidateUpdate is the default update validation for an end user.
|
||||
func (deploymentStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) errs.ValidationErrorList {
|
||||
return validation.ValidateDeploymentUpdate(old.(*experimental.Deployment), obj.(*experimental.Deployment))
|
||||
return validation.ValidateDeploymentUpdate(old.(*extensions.Deployment), obj.(*extensions.Deployment))
|
||||
}
|
||||
|
||||
func (deploymentStrategy) AllowUnconditionalUpdate() bool {
|
||||
@@ -73,7 +73,7 @@ func (deploymentStrategy) AllowUnconditionalUpdate() bool {
|
||||
}
|
||||
|
||||
// DeploymentToSelectableFields returns a field set that represents the object.
|
||||
func DeploymentToSelectableFields(deployment *experimental.Deployment) fields.Set {
|
||||
func DeploymentToSelectableFields(deployment *extensions.Deployment) fields.Set {
|
||||
return fields.Set{
|
||||
"metadata.name": deployment.Name,
|
||||
}
|
||||
@@ -87,7 +87,7 @@ func MatchDeployment(label labels.Selector, field fields.Selector) generic.Match
|
||||
Label: label,
|
||||
Field: field,
|
||||
GetAttrs: func(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||
deployment, ok := obj.(*experimental.Deployment)
|
||||
deployment, ok := obj.(*extensions.Deployment)
|
||||
if !ok {
|
||||
return nil, nil, fmt.Errorf("given object is not a deployment.")
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ var _ = rest.Patcher(&ScaleREST{})
|
||||
|
||||
// New creates a new Scale object
|
||||
func (r *ScaleREST) New() runtime.Object {
|
||||
return &experimental.Scale{}
|
||||
return &extensions.Scale{}
|
||||
}
|
||||
|
||||
func (r *ScaleREST) Get(ctx api.Context, name string) (runtime.Object, error) {
|
||||
@@ -65,16 +65,16 @@ func (r *ScaleREST) Get(ctx api.Context, name string) (runtime.Object, error) {
|
||||
if err != nil {
|
||||
return nil, errors.NewNotFound("scale", name)
|
||||
}
|
||||
return &experimental.Scale{
|
||||
return &extensions.Scale{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: rc.Namespace,
|
||||
CreationTimestamp: rc.CreationTimestamp,
|
||||
},
|
||||
Spec: experimental.ScaleSpec{
|
||||
Spec: extensions.ScaleSpec{
|
||||
Replicas: rc.Spec.Replicas,
|
||||
},
|
||||
Status: experimental.ScaleStatus{
|
||||
Status: extensions.ScaleStatus{
|
||||
Replicas: rc.Status.Replicas,
|
||||
Selector: rc.Spec.Selector,
|
||||
},
|
||||
@@ -85,7 +85,7 @@ func (r *ScaleREST) Update(ctx api.Context, obj runtime.Object) (runtime.Object,
|
||||
if obj == nil {
|
||||
return nil, false, errors.NewBadRequest(fmt.Sprintf("nil update passed to Scale"))
|
||||
}
|
||||
scale, ok := obj.(*experimental.Scale)
|
||||
scale, ok := obj.(*extensions.Scale)
|
||||
if !ok {
|
||||
return nil, false, errors.NewBadRequest(fmt.Sprintf("wrong object passed to Scale update: %v", obj))
|
||||
}
|
||||
@@ -98,16 +98,16 @@ func (r *ScaleREST) Update(ctx api.Context, obj runtime.Object) (runtime.Object,
|
||||
if err != nil {
|
||||
return nil, false, errors.NewConflict("scale", scale.Name, err)
|
||||
}
|
||||
return &experimental.Scale{
|
||||
return &extensions.Scale{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: rc.Name,
|
||||
Namespace: rc.Namespace,
|
||||
CreationTimestamp: rc.CreationTimestamp,
|
||||
},
|
||||
Spec: experimental.ScaleSpec{
|
||||
Spec: extensions.ScaleSpec{
|
||||
Replicas: rc.Spec.Replicas,
|
||||
},
|
||||
Status: experimental.ScaleStatus{
|
||||
Status: extensions.ScaleStatus{
|
||||
Replicas: rc.Status.Replicas,
|
||||
Selector: rc.Spec.Selector,
|
||||
},
|
||||
@@ -118,5 +118,5 @@ func (r *ScaleREST) Update(ctx api.Context, obj runtime.Object) (runtime.Object,
|
||||
type RcREST struct{}
|
||||
|
||||
func (r *RcREST) New() runtime.Object {
|
||||
return &experimental.ReplicationControllerDummy{}
|
||||
return &extensions.ReplicationControllerDummy{}
|
||||
}
|
||||
|
||||
@@ -66,12 +66,12 @@ var validController = api.ReplicationController{
|
||||
Spec: validControllerSpec,
|
||||
}
|
||||
|
||||
var validScale = experimental.Scale{
|
||||
var validScale = extensions.Scale{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "test"},
|
||||
Spec: experimental.ScaleSpec{
|
||||
Spec: extensions.ScaleSpec{
|
||||
Replicas: validReplicas,
|
||||
},
|
||||
Status: experimental.ScaleStatus{
|
||||
Status: extensions.ScaleStatus{
|
||||
Replicas: 0,
|
||||
Selector: validPodTemplate.Template.Labels,
|
||||
},
|
||||
@@ -88,7 +88,7 @@ func TestGet(t *testing.T) {
|
||||
|
||||
expect := &validScale
|
||||
obj, err := storage.Get(ctx, "foo")
|
||||
scale := obj.(*experimental.Scale)
|
||||
scale := obj.(*extensions.Scale)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -106,9 +106,9 @@ func TestUpdate(t *testing.T) {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
replicas := 12
|
||||
update := experimental.Scale{
|
||||
update := extensions.Scale{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "test"},
|
||||
Spec: experimental.ScaleSpec{
|
||||
Spec: extensions.ScaleSpec{
|
||||
Replicas: replicas,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ type REST struct {
|
||||
func NewREST(s storage.Interface) *REST {
|
||||
prefix := "/horizontalpodautoscalers"
|
||||
store := &etcdgeneric.Etcd{
|
||||
NewFunc: func() runtime.Object { return &experimental.HorizontalPodAutoscaler{} },
|
||||
NewFunc: func() runtime.Object { return &extensions.HorizontalPodAutoscaler{} },
|
||||
// NewListFunc returns an object capable of storing results of an etcd list.
|
||||
NewListFunc: func() runtime.Object { return &experimental.HorizontalPodAutoscalerList{} },
|
||||
NewListFunc: func() runtime.Object { return &extensions.HorizontalPodAutoscalerList{} },
|
||||
// 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 {
|
||||
@@ -51,7 +51,7 @@ func NewREST(s storage.Interface) *REST {
|
||||
},
|
||||
// Retrieve the name field of an autoscaler
|
||||
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
||||
return obj.(*experimental.HorizontalPodAutoscaler).Name, nil
|
||||
return obj.(*extensions.HorizontalPodAutoscaler).Name, nil
|
||||
},
|
||||
// Used to match objects based on labels/fields for list
|
||||
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
|
||||
|
||||
@@ -36,19 +36,19 @@ func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) {
|
||||
return NewREST(etcdStorage), fakeClient
|
||||
}
|
||||
|
||||
func validNewHorizontalPodAutoscaler(name string) *experimental.HorizontalPodAutoscaler {
|
||||
return &experimental.HorizontalPodAutoscaler{
|
||||
func validNewHorizontalPodAutoscaler(name string) *extensions.HorizontalPodAutoscaler {
|
||||
return &extensions.HorizontalPodAutoscaler{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.HorizontalPodAutoscalerSpec{
|
||||
ScaleRef: &experimental.SubresourceReference{
|
||||
Spec: extensions.HorizontalPodAutoscalerSpec{
|
||||
ScaleRef: &extensions.SubresourceReference{
|
||||
Subresource: "scale",
|
||||
},
|
||||
MinReplicas: 1,
|
||||
MaxReplicas: 5,
|
||||
Target: experimental.ResourceConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("0.8")},
|
||||
Target: extensions.ResourceConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("0.8")},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ func TestCreate(t *testing.T) {
|
||||
// valid
|
||||
autoscaler,
|
||||
// invalid
|
||||
&experimental.HorizontalPodAutoscaler{},
|
||||
&extensions.HorizontalPodAutoscaler{},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ func TestUpdate(t *testing.T) {
|
||||
validNewHorizontalPodAutoscaler("foo"),
|
||||
// updateFunc
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*experimental.HorizontalPodAutoscaler)
|
||||
object := obj.(*extensions.HorizontalPodAutoscaler)
|
||||
object.Spec.MaxReplicas = object.Spec.MaxReplicas + 1
|
||||
return object
|
||||
},
|
||||
|
||||
@@ -46,12 +46,12 @@ func (autoscalerStrategy) NamespaceScoped() bool {
|
||||
|
||||
// PrepareForCreate clears fields that are not allowed to be set by end users on creation.
|
||||
func (autoscalerStrategy) PrepareForCreate(obj runtime.Object) {
|
||||
_ = obj.(*experimental.HorizontalPodAutoscaler)
|
||||
_ = obj.(*extensions.HorizontalPodAutoscaler)
|
||||
}
|
||||
|
||||
// Validate validates a new autoscaler.
|
||||
func (autoscalerStrategy) Validate(ctx api.Context, obj runtime.Object) errs.ValidationErrorList {
|
||||
autoscaler := obj.(*experimental.HorizontalPodAutoscaler)
|
||||
autoscaler := obj.(*extensions.HorizontalPodAutoscaler)
|
||||
return validation.ValidateHorizontalPodAutoscaler(autoscaler)
|
||||
}
|
||||
|
||||
@@ -62,19 +62,19 @@ func (autoscalerStrategy) AllowCreateOnUpdate() bool {
|
||||
|
||||
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
|
||||
func (autoscalerStrategy) PrepareForUpdate(obj, old runtime.Object) {
|
||||
_ = obj.(*experimental.HorizontalPodAutoscaler)
|
||||
_ = obj.(*extensions.HorizontalPodAutoscaler)
|
||||
}
|
||||
|
||||
// ValidateUpdate is the default update validation for an end user.
|
||||
func (autoscalerStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) errs.ValidationErrorList {
|
||||
return validation.ValidateHorizontalPodAutoscalerUpdate(obj.(*experimental.HorizontalPodAutoscaler), old.(*experimental.HorizontalPodAutoscaler))
|
||||
return validation.ValidateHorizontalPodAutoscalerUpdate(obj.(*extensions.HorizontalPodAutoscaler), old.(*extensions.HorizontalPodAutoscaler))
|
||||
}
|
||||
|
||||
func (autoscalerStrategy) AllowUnconditionalUpdate() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func AutoscalerToSelectableFields(limitRange *experimental.HorizontalPodAutoscaler) fields.Set {
|
||||
func AutoscalerToSelectableFields(limitRange *extensions.HorizontalPodAutoscaler) fields.Set {
|
||||
return fields.Set{}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ func MatchAutoscaler(label labels.Selector, field fields.Selector) generic.Match
|
||||
Label: label,
|
||||
Field: field,
|
||||
GetAttrs: func(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||
hpa, ok := obj.(*experimental.HorizontalPodAutoscaler)
|
||||
hpa, ok := obj.(*extensions.HorizontalPodAutoscaler)
|
||||
if !ok {
|
||||
return nil, nil, fmt.Errorf("given object is not a horizontal pod autoscaler.")
|
||||
}
|
||||
|
||||
@@ -40,10 +40,10 @@ type REST struct {
|
||||
// NewREST returns a RESTStorage object that will work against replication controllers.
|
||||
func NewREST(s storage.Interface) *REST {
|
||||
store := &etcdgeneric.Etcd{
|
||||
NewFunc: func() runtime.Object { return &experimental.Ingress{} },
|
||||
NewFunc: func() runtime.Object { return &extensions.Ingress{} },
|
||||
|
||||
// NewListFunc returns an object capable of storing results of an etcd list.
|
||||
NewListFunc: func() runtime.Object { return &experimental.IngressList{} },
|
||||
NewListFunc: func() runtime.Object { return &extensions.IngressList{} },
|
||||
// Produces a ingress 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 {
|
||||
@@ -56,7 +56,7 @@ func NewREST(s storage.Interface) *REST {
|
||||
},
|
||||
// Retrieve the name field of a replication controller
|
||||
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
||||
return obj.(*experimental.Ingress).Name, nil
|
||||
return obj.(*extensions.Ingress).Name, nil
|
||||
},
|
||||
// Used to match objects based on labels/fields for list and watch
|
||||
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
|
||||
|
||||
@@ -48,12 +48,12 @@ var (
|
||||
|
||||
type IngressRuleValues map[string]string
|
||||
|
||||
func toHTTPIngressPaths(pathMap map[string]string) []experimental.HTTPIngressPath {
|
||||
httpPaths := []experimental.HTTPIngressPath{}
|
||||
func toHTTPIngressPaths(pathMap map[string]string) []extensions.HTTPIngressPath {
|
||||
httpPaths := []extensions.HTTPIngressPath{}
|
||||
for path, backend := range pathMap {
|
||||
httpPaths = append(httpPaths, experimental.HTTPIngressPath{
|
||||
httpPaths = append(httpPaths, extensions.HTTPIngressPath{
|
||||
Path: path,
|
||||
Backend: experimental.IngressBackend{
|
||||
Backend: extensions.IngressBackend{
|
||||
ServiceName: backend,
|
||||
ServicePort: defaultBackendPort,
|
||||
},
|
||||
@@ -62,13 +62,13 @@ func toHTTPIngressPaths(pathMap map[string]string) []experimental.HTTPIngressPat
|
||||
return httpPaths
|
||||
}
|
||||
|
||||
func toIngressRules(hostRules map[string]IngressRuleValues) []experimental.IngressRule {
|
||||
rules := []experimental.IngressRule{}
|
||||
func toIngressRules(hostRules map[string]IngressRuleValues) []extensions.IngressRule {
|
||||
rules := []extensions.IngressRule{}
|
||||
for host, pathMap := range hostRules {
|
||||
rules = append(rules, experimental.IngressRule{
|
||||
rules = append(rules, extensions.IngressRule{
|
||||
Host: host,
|
||||
IngressRuleValue: experimental.IngressRuleValue{
|
||||
HTTP: &experimental.HTTPIngressRuleValue{
|
||||
IngressRuleValue: extensions.IngressRuleValue{
|
||||
HTTP: &extensions.HTTPIngressRuleValue{
|
||||
Paths: toHTTPIngressPaths(pathMap),
|
||||
},
|
||||
},
|
||||
@@ -77,14 +77,14 @@ func toIngressRules(hostRules map[string]IngressRuleValues) []experimental.Ingre
|
||||
return rules
|
||||
}
|
||||
|
||||
func newIngress(pathMap map[string]string) *experimental.Ingress {
|
||||
return &experimental.Ingress{
|
||||
func newIngress(pathMap map[string]string) *extensions.Ingress {
|
||||
return &extensions.Ingress{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
},
|
||||
Spec: experimental.IngressSpec{
|
||||
Backend: &experimental.IngressBackend{
|
||||
Spec: extensions.IngressSpec{
|
||||
Backend: &extensions.IngressBackend{
|
||||
ServiceName: defaultBackendName,
|
||||
ServicePort: defaultBackendPort,
|
||||
},
|
||||
@@ -92,7 +92,7 @@ func newIngress(pathMap map[string]string) *experimental.Ingress {
|
||||
defaultHostname: pathMap,
|
||||
}),
|
||||
},
|
||||
Status: experimental.IngressStatus{
|
||||
Status: extensions.IngressStatus{
|
||||
LoadBalancer: api.LoadBalancerStatus{
|
||||
Ingress: []api.LoadBalancerIngress{
|
||||
{IP: defaultLoadBalancer},
|
||||
@@ -102,7 +102,7 @@ func newIngress(pathMap map[string]string) *experimental.Ingress {
|
||||
}
|
||||
}
|
||||
|
||||
func validIngress() *experimental.Ingress {
|
||||
func validIngress() *extensions.Ingress {
|
||||
return newIngress(defaultPathMap)
|
||||
}
|
||||
|
||||
@@ -111,8 +111,8 @@ func TestCreate(t *testing.T) {
|
||||
test := registrytest.New(t, fakeClient, storage.Etcd)
|
||||
ingress := validIngress()
|
||||
noDefaultBackendAndRules := validIngress()
|
||||
noDefaultBackendAndRules.Spec.Backend = &experimental.IngressBackend{}
|
||||
noDefaultBackendAndRules.Spec.Rules = []experimental.IngressRule{}
|
||||
noDefaultBackendAndRules.Spec.Backend = &extensions.IngressBackend{}
|
||||
noDefaultBackendAndRules.Spec.Rules = []extensions.IngressRule{}
|
||||
badPath := validIngress()
|
||||
badPath.Spec.Rules = toIngressRules(map[string]IngressRuleValues{
|
||||
"foo.bar.com": {"/invalid[": "svc"}})
|
||||
@@ -132,7 +132,7 @@ func TestUpdate(t *testing.T) {
|
||||
validIngress(),
|
||||
// updateFunc
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*experimental.Ingress)
|
||||
object := obj.(*extensions.Ingress)
|
||||
object.Spec.Rules = toIngressRules(map[string]IngressRuleValues{
|
||||
"bar.foo.com": {"/bar": defaultBackendName},
|
||||
})
|
||||
@@ -140,19 +140,19 @@ func TestUpdate(t *testing.T) {
|
||||
},
|
||||
// invalid updateFunc: ObjeceMeta is not to be tampered with.
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*experimental.Ingress)
|
||||
object := obj.(*extensions.Ingress)
|
||||
object.UID = "newUID"
|
||||
return object
|
||||
},
|
||||
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*experimental.Ingress)
|
||||
object := obj.(*extensions.Ingress)
|
||||
object.Name = ""
|
||||
return object
|
||||
},
|
||||
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*experimental.Ingress)
|
||||
object := obj.(*extensions.Ingress)
|
||||
object.Spec.Rules = toIngressRules(map[string]IngressRuleValues{
|
||||
"foo.bar.com": {"/invalid[": "svc"}})
|
||||
return object
|
||||
|
||||
@@ -46,16 +46,16 @@ func (ingressStrategy) NamespaceScoped() bool {
|
||||
|
||||
// PrepareForCreate clears the status of an Ingress before creation.
|
||||
func (ingressStrategy) PrepareForCreate(obj runtime.Object) {
|
||||
ingress := obj.(*experimental.Ingress)
|
||||
ingress.Status = experimental.IngressStatus{}
|
||||
ingress := obj.(*extensions.Ingress)
|
||||
ingress.Status = extensions.IngressStatus{}
|
||||
|
||||
ingress.Generation = 1
|
||||
}
|
||||
|
||||
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
|
||||
func (ingressStrategy) PrepareForUpdate(obj, old runtime.Object) {
|
||||
newIngress := obj.(*experimental.Ingress)
|
||||
oldIngress := old.(*experimental.Ingress)
|
||||
newIngress := obj.(*extensions.Ingress)
|
||||
oldIngress := old.(*extensions.Ingress)
|
||||
//TODO: Clear Ingress status once we have a sub-resource.
|
||||
|
||||
// Any changes to the spec increment the generation number, any changes to the
|
||||
@@ -69,7 +69,7 @@ func (ingressStrategy) PrepareForUpdate(obj, old runtime.Object) {
|
||||
|
||||
// Validate validates a new Ingress.
|
||||
func (ingressStrategy) Validate(ctx api.Context, obj runtime.Object) fielderrors.ValidationErrorList {
|
||||
ingress := obj.(*experimental.Ingress)
|
||||
ingress := obj.(*extensions.Ingress)
|
||||
err := validation.ValidateIngress(ingress)
|
||||
return err
|
||||
}
|
||||
@@ -81,8 +81,8 @@ func (ingressStrategy) AllowCreateOnUpdate() bool {
|
||||
|
||||
// ValidateUpdate is the default update validation for an end user.
|
||||
func (ingressStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
||||
validationErrorList := validation.ValidateIngress(obj.(*experimental.Ingress))
|
||||
updateErrorList := validation.ValidateIngressUpdate(old.(*experimental.Ingress), obj.(*experimental.Ingress))
|
||||
validationErrorList := validation.ValidateIngress(obj.(*extensions.Ingress))
|
||||
updateErrorList := validation.ValidateIngressUpdate(old.(*extensions.Ingress), obj.(*extensions.Ingress))
|
||||
return append(validationErrorList, updateErrorList...)
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ func (ingressStrategy) AllowUnconditionalUpdate() bool {
|
||||
}
|
||||
|
||||
// IngressToSelectableFields returns a label set that represents the object.
|
||||
func IngressToSelectableFields(ingress *experimental.Ingress) fields.Set {
|
||||
func IngressToSelectableFields(ingress *extensions.Ingress) fields.Set {
|
||||
return fields.Set{
|
||||
"metadata.name": ingress.Name,
|
||||
}
|
||||
@@ -106,7 +106,7 @@ func MatchIngress(label labels.Selector, field fields.Selector) generic.Matcher
|
||||
Label: label,
|
||||
Field: field,
|
||||
GetAttrs: func(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||
ingress, ok := obj.(*experimental.Ingress)
|
||||
ingress, ok := obj.(*extensions.Ingress)
|
||||
if !ok {
|
||||
return nil, nil, fmt.Errorf("Given object is not an Ingress.")
|
||||
}
|
||||
|
||||
@@ -40,10 +40,10 @@ var jobPrefix = "/jobs"
|
||||
// NewREST returns a RESTStorage object that will work against Jobs.
|
||||
func NewREST(s storage.Interface) (*REST, *StatusREST) {
|
||||
store := &etcdgeneric.Etcd{
|
||||
NewFunc: func() runtime.Object { return &experimental.Job{} },
|
||||
NewFunc: func() runtime.Object { return &extensions.Job{} },
|
||||
|
||||
// NewListFunc returns an object capable of storing results of an etcd list.
|
||||
NewListFunc: func() runtime.Object { return &experimental.JobList{} },
|
||||
NewListFunc: func() runtime.Object { return &extensions.JobList{} },
|
||||
// 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 {
|
||||
@@ -56,7 +56,7 @@ func NewREST(s storage.Interface) (*REST, *StatusREST) {
|
||||
},
|
||||
// Retrieve the name field of a job
|
||||
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
||||
return obj.(*experimental.Job).Name, nil
|
||||
return obj.(*extensions.Job).Name, nil
|
||||
},
|
||||
// Used to match objects based on labels/fields for list and watch
|
||||
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
|
||||
@@ -85,7 +85,7 @@ type StatusREST struct {
|
||||
}
|
||||
|
||||
func (r *StatusREST) New() runtime.Object {
|
||||
return &experimental.Job{}
|
||||
return &extensions.Job{}
|
||||
}
|
||||
|
||||
// Update alters the status subset of an object.
|
||||
|
||||
@@ -36,15 +36,15 @@ func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient) {
|
||||
return storage, statusStorage, fakeClient
|
||||
}
|
||||
|
||||
func validNewJob() *experimental.Job {
|
||||
func validNewJob() *extensions.Job {
|
||||
completions := 1
|
||||
parallelism := 1
|
||||
return &experimental.Job{
|
||||
return &extensions.Job{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "default",
|
||||
},
|
||||
Spec: experimental.JobSpec{
|
||||
Spec: extensions.JobSpec{
|
||||
Completions: &completions,
|
||||
Parallelism: ¶llelism,
|
||||
Selector: map[string]string{"a": "b"},
|
||||
@@ -77,8 +77,8 @@ func TestCreate(t *testing.T) {
|
||||
// valid
|
||||
validJob,
|
||||
// invalid (empty selector)
|
||||
&experimental.Job{
|
||||
Spec: experimental.JobSpec{
|
||||
&extensions.Job{
|
||||
Spec: extensions.JobSpec{
|
||||
Completions: validJob.Spec.Completions,
|
||||
Selector: map[string]string{},
|
||||
Template: validJob.Spec.Template,
|
||||
@@ -96,18 +96,18 @@ func TestUpdate(t *testing.T) {
|
||||
validNewJob(),
|
||||
// updateFunc
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*experimental.Job)
|
||||
object := obj.(*extensions.Job)
|
||||
object.Spec.Parallelism = &two
|
||||
return object
|
||||
},
|
||||
// invalid updateFunc
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*experimental.Job)
|
||||
object := obj.(*extensions.Job)
|
||||
object.Spec.Selector = map[string]string{}
|
||||
return object
|
||||
},
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*experimental.Job)
|
||||
object := obj.(*extensions.Job)
|
||||
object.Spec.Completions = &two
|
||||
return object
|
||||
},
|
||||
|
||||
@@ -30,15 +30,15 @@ import (
|
||||
// Registry is an interface for things that know how to store Jobs.
|
||||
type Registry interface {
|
||||
// ListJobs obtains a list of Jobs having labels and fields which match selector.
|
||||
ListJobs(ctx api.Context, label labels.Selector, field fields.Selector) (*experimental.JobList, error)
|
||||
ListJobs(ctx api.Context, label labels.Selector, field fields.Selector) (*extensions.JobList, error)
|
||||
// WatchJobs watch for new/changed/deleted Jobs.
|
||||
WatchJobs(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
|
||||
// GetJobs gets a specific Job.
|
||||
GetJob(ctx api.Context, name string) (*experimental.Job, error)
|
||||
GetJob(ctx api.Context, name string) (*extensions.Job, error)
|
||||
// CreateJob creates a Job based on a specification.
|
||||
CreateJob(ctx api.Context, job *experimental.Job) (*experimental.Job, error)
|
||||
CreateJob(ctx api.Context, job *extensions.Job) (*extensions.Job, error)
|
||||
// UpdateJob updates an existing Job.
|
||||
UpdateJob(ctx api.Context, job *experimental.Job) (*experimental.Job, error)
|
||||
UpdateJob(ctx api.Context, job *extensions.Job) (*extensions.Job, error)
|
||||
// DeleteJob deletes an existing Job.
|
||||
DeleteJob(ctx api.Context, name string) error
|
||||
}
|
||||
@@ -54,7 +54,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
|
||||
return &storage{s}
|
||||
}
|
||||
|
||||
func (s *storage) ListJobs(ctx api.Context, label labels.Selector, field fields.Selector) (*experimental.JobList, error) {
|
||||
func (s *storage) ListJobs(ctx api.Context, label labels.Selector, field fields.Selector) (*extensions.JobList, error) {
|
||||
if !field.Empty() {
|
||||
return nil, fmt.Errorf("field selector not supported yet")
|
||||
}
|
||||
@@ -62,35 +62,35 @@ func (s *storage) ListJobs(ctx api.Context, label labels.Selector, field fields.
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*experimental.JobList), err
|
||||
return obj.(*extensions.JobList), err
|
||||
}
|
||||
|
||||
func (s *storage) WatchJobs(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
|
||||
return s.Watch(ctx, label, field, resourceVersion)
|
||||
}
|
||||
|
||||
func (s *storage) GetJob(ctx api.Context, name string) (*experimental.Job, error) {
|
||||
func (s *storage) GetJob(ctx api.Context, name string) (*extensions.Job, error) {
|
||||
obj, err := s.Get(ctx, name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*experimental.Job), nil
|
||||
return obj.(*extensions.Job), nil
|
||||
}
|
||||
|
||||
func (s *storage) CreateJob(ctx api.Context, job *experimental.Job) (*experimental.Job, error) {
|
||||
func (s *storage) CreateJob(ctx api.Context, job *extensions.Job) (*extensions.Job, error) {
|
||||
obj, err := s.Create(ctx, job)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*experimental.Job), nil
|
||||
return obj.(*extensions.Job), nil
|
||||
}
|
||||
|
||||
func (s *storage) UpdateJob(ctx api.Context, job *experimental.Job) (*experimental.Job, error) {
|
||||
func (s *storage) UpdateJob(ctx api.Context, job *extensions.Job) (*extensions.Job, error) {
|
||||
obj, _, err := s.Update(ctx, job)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*experimental.Job), nil
|
||||
return obj.(*extensions.Job), nil
|
||||
}
|
||||
|
||||
func (s *storage) DeleteJob(ctx api.Context, name string) error {
|
||||
|
||||
@@ -46,20 +46,20 @@ func (jobStrategy) NamespaceScoped() bool {
|
||||
|
||||
// PrepareForCreate clears the status of a job before creation.
|
||||
func (jobStrategy) PrepareForCreate(obj runtime.Object) {
|
||||
job := obj.(*experimental.Job)
|
||||
job.Status = experimental.JobStatus{}
|
||||
job := obj.(*extensions.Job)
|
||||
job.Status = extensions.JobStatus{}
|
||||
}
|
||||
|
||||
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
|
||||
func (jobStrategy) PrepareForUpdate(obj, old runtime.Object) {
|
||||
newJob := obj.(*experimental.Job)
|
||||
oldJob := old.(*experimental.Job)
|
||||
newJob := obj.(*extensions.Job)
|
||||
oldJob := old.(*extensions.Job)
|
||||
newJob.Status = oldJob.Status
|
||||
}
|
||||
|
||||
// Validate validates a new job.
|
||||
func (jobStrategy) Validate(ctx api.Context, obj runtime.Object) fielderrors.ValidationErrorList {
|
||||
job := obj.(*experimental.Job)
|
||||
job := obj.(*extensions.Job)
|
||||
return validation.ValidateJob(job)
|
||||
}
|
||||
|
||||
@@ -74,8 +74,8 @@ func (jobStrategy) AllowCreateOnUpdate() bool {
|
||||
|
||||
// ValidateUpdate is the default update validation for an end user.
|
||||
func (jobStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
||||
validationErrorList := validation.ValidateJob(obj.(*experimental.Job))
|
||||
updateErrorList := validation.ValidateJobUpdate(old.(*experimental.Job), obj.(*experimental.Job))
|
||||
validationErrorList := validation.ValidateJob(obj.(*extensions.Job))
|
||||
updateErrorList := validation.ValidateJobUpdate(old.(*extensions.Job), obj.(*extensions.Job))
|
||||
return append(validationErrorList, updateErrorList...)
|
||||
}
|
||||
|
||||
@@ -86,17 +86,17 @@ type jobStatusStrategy struct {
|
||||
var StatusStrategy = jobStatusStrategy{Strategy}
|
||||
|
||||
func (jobStatusStrategy) PrepareForUpdate(obj, old runtime.Object) {
|
||||
newJob := obj.(*experimental.Job)
|
||||
oldJob := old.(*experimental.Job)
|
||||
newJob := obj.(*extensions.Job)
|
||||
oldJob := old.(*extensions.Job)
|
||||
newJob.Spec = oldJob.Spec
|
||||
}
|
||||
|
||||
func (jobStatusStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
||||
return validation.ValidateJobUpdateStatus(obj.(*experimental.Job), old.(*experimental.Job))
|
||||
return validation.ValidateJobUpdateStatus(obj.(*extensions.Job), old.(*extensions.Job))
|
||||
}
|
||||
|
||||
// JobSelectableFields returns a field set that represents the object for matching purposes.
|
||||
func JobToSelectableFields(job *experimental.Job) fields.Set {
|
||||
func JobToSelectableFields(job *extensions.Job) fields.Set {
|
||||
return fields.Set{
|
||||
"metadata.name": job.Name,
|
||||
"status.successful": strconv.Itoa(job.Status.Succeeded),
|
||||
@@ -111,7 +111,7 @@ func MatchJob(label labels.Selector, field fields.Selector) generic.Matcher {
|
||||
Label: label,
|
||||
Field: field,
|
||||
GetAttrs: func(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||
job, ok := obj.(*experimental.Job)
|
||||
job, ok := obj.(*extensions.Job)
|
||||
if !ok {
|
||||
return nil, nil, fmt.Errorf("Given object is not a job.")
|
||||
}
|
||||
|
||||
@@ -43,16 +43,16 @@ func TestJobStrategy(t *testing.T) {
|
||||
Containers: []api.Container{{Name: "abc", Image: "image", ImagePullPolicy: "IfNotPresent"}},
|
||||
},
|
||||
}
|
||||
job := &experimental.Job{
|
||||
job := &extensions.Job{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "myjob",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.JobSpec{
|
||||
Spec: extensions.JobSpec{
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplateSpec,
|
||||
},
|
||||
Status: experimental.JobStatus{
|
||||
Status: extensions.JobStatus{
|
||||
Active: 11,
|
||||
},
|
||||
}
|
||||
@@ -66,12 +66,12 @@ func TestJobStrategy(t *testing.T) {
|
||||
t.Errorf("Unexpected error validating %v", errs)
|
||||
}
|
||||
parallelism := 10
|
||||
updatedJob := &experimental.Job{
|
||||
updatedJob := &extensions.Job{
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "4"},
|
||||
Spec: experimental.JobSpec{
|
||||
Spec: extensions.JobSpec{
|
||||
Parallelism: ¶llelism,
|
||||
},
|
||||
Status: experimental.JobStatus{
|
||||
Status: extensions.JobStatus{
|
||||
Active: 11,
|
||||
},
|
||||
}
|
||||
@@ -108,33 +108,33 @@ func TestJobStatusStrategy(t *testing.T) {
|
||||
}
|
||||
oldParallelism := 10
|
||||
newParallelism := 11
|
||||
oldJob := &experimental.Job{
|
||||
oldJob := &extensions.Job{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "myjob",
|
||||
Namespace: api.NamespaceDefault,
|
||||
ResourceVersion: "10",
|
||||
},
|
||||
Spec: experimental.JobSpec{
|
||||
Spec: extensions.JobSpec{
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplateSpec,
|
||||
Parallelism: &oldParallelism,
|
||||
},
|
||||
Status: experimental.JobStatus{
|
||||
Status: extensions.JobStatus{
|
||||
Active: 11,
|
||||
},
|
||||
}
|
||||
newJob := &experimental.Job{
|
||||
newJob := &extensions.Job{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "myjob",
|
||||
Namespace: api.NamespaceDefault,
|
||||
ResourceVersion: "9",
|
||||
},
|
||||
Spec: experimental.JobSpec{
|
||||
Spec: extensions.JobSpec{
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplateSpec,
|
||||
Parallelism: &newParallelism,
|
||||
},
|
||||
Status: experimental.JobStatus{
|
||||
Status: extensions.JobStatus{
|
||||
Active: 12,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ func NewREST(s storage.Interface) *REST {
|
||||
prefix := "/thirdpartyresources"
|
||||
|
||||
store := &etcdgeneric.Etcd{
|
||||
NewFunc: func() runtime.Object { return &experimental.ThirdPartyResource{} },
|
||||
NewListFunc: func() runtime.Object { return &experimental.ThirdPartyResourceList{} },
|
||||
NewFunc: func() runtime.Object { return &extensions.ThirdPartyResource{} },
|
||||
NewListFunc: func() runtime.Object { return &extensions.ThirdPartyResourceList{} },
|
||||
KeyRootFunc: func(ctx api.Context) string {
|
||||
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
|
||||
},
|
||||
@@ -47,7 +47,7 @@ func NewREST(s storage.Interface) *REST {
|
||||
return etcdgeneric.NamespaceKeyFunc(ctx, prefix, id)
|
||||
},
|
||||
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
||||
return obj.(*experimental.ThirdPartyResource).Name, nil
|
||||
return obj.(*extensions.ThirdPartyResource).Name, nil
|
||||
},
|
||||
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
|
||||
return thirdpartyresource.Matcher(label, field)
|
||||
|
||||
@@ -35,13 +35,13 @@ func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) {
|
||||
return NewREST(etcdStorage), fakeClient
|
||||
}
|
||||
|
||||
func validNewThirdPartyResource(name string) *experimental.ThirdPartyResource {
|
||||
return &experimental.ThirdPartyResource{
|
||||
func validNewThirdPartyResource(name string) *extensions.ThirdPartyResource {
|
||||
return &extensions.ThirdPartyResource{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Versions: []experimental.APIVersion{
|
||||
Versions: []extensions.APIVersion{
|
||||
{
|
||||
Name: "stable/v1",
|
||||
},
|
||||
@@ -58,7 +58,7 @@ func TestCreate(t *testing.T) {
|
||||
// valid
|
||||
rsrc,
|
||||
// invalid
|
||||
&experimental.ThirdPartyResource{},
|
||||
&extensions.ThirdPartyResource{},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ func TestUpdate(t *testing.T) {
|
||||
validNewThirdPartyResource("foo"),
|
||||
// updateFunc
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*experimental.ThirdPartyResource)
|
||||
object := obj.(*extensions.ThirdPartyResource)
|
||||
object.Description = "new description"
|
||||
return object
|
||||
},
|
||||
|
||||
@@ -52,7 +52,7 @@ func (strategy) PrepareForCreate(obj runtime.Object) {
|
||||
}
|
||||
|
||||
func (strategy) Validate(ctx api.Context, obj runtime.Object) fielderrors.ValidationErrorList {
|
||||
return validation.ValidateThirdPartyResource(obj.(*experimental.ThirdPartyResource))
|
||||
return validation.ValidateThirdPartyResource(obj.(*extensions.ThirdPartyResource))
|
||||
}
|
||||
|
||||
func (strategy) AllowCreateOnUpdate() bool {
|
||||
@@ -63,7 +63,7 @@ func (strategy) PrepareForUpdate(obj, old runtime.Object) {
|
||||
}
|
||||
|
||||
func (strategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
||||
return validation.ValidateThirdPartyResourceUpdate(old.(*experimental.ThirdPartyResource), obj.(*experimental.ThirdPartyResource))
|
||||
return validation.ValidateThirdPartyResourceUpdate(old.(*extensions.ThirdPartyResource), obj.(*extensions.ThirdPartyResource))
|
||||
}
|
||||
|
||||
func (strategy) AllowUnconditionalUpdate() bool {
|
||||
@@ -73,7 +73,7 @@ func (strategy) AllowUnconditionalUpdate() bool {
|
||||
// Matcher returns a generic matcher for a given label and field selector.
|
||||
func Matcher(label labels.Selector, field fields.Selector) generic.Matcher {
|
||||
return generic.MatcherFunc(func(obj runtime.Object) (bool, error) {
|
||||
sa, ok := obj.(*experimental.ThirdPartyResource)
|
||||
sa, ok := obj.(*extensions.ThirdPartyResource)
|
||||
if !ok {
|
||||
return false, fmt.Errorf("not a ThirdPartyResource")
|
||||
}
|
||||
@@ -83,6 +83,6 @@ func Matcher(label labels.Selector, field fields.Selector) generic.Matcher {
|
||||
}
|
||||
|
||||
// SelectableFields returns a label set that can be used for filter selection
|
||||
func SelectableFields(obj *experimental.ThirdPartyResource) labels.Set {
|
||||
func SelectableFields(obj *extensions.ThirdPartyResource) labels.Set {
|
||||
return labels.Set{}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ func NewCodec(codec runtime.Codec, kind string) runtime.Codec {
|
||||
return &thirdPartyResourceDataCodec{codec, kind}
|
||||
}
|
||||
|
||||
func (t *thirdPartyResourceDataCodec) populate(objIn *experimental.ThirdPartyResourceData, data []byte) error {
|
||||
func (t *thirdPartyResourceDataCodec) populate(objIn *extensions.ThirdPartyResourceData, data []byte) error {
|
||||
var obj interface{}
|
||||
if err := json.Unmarshal(data, &obj); err != nil {
|
||||
fmt.Printf("Invalid JSON:\n%s\n", string(data))
|
||||
@@ -118,7 +118,7 @@ func (t *thirdPartyResourceDataCodec) populate(objIn *experimental.ThirdPartyRes
|
||||
return t.populateFromObject(objIn, mapObj, data)
|
||||
}
|
||||
|
||||
func (t *thirdPartyResourceDataCodec) populateFromObject(objIn *experimental.ThirdPartyResourceData, mapObj map[string]interface{}, data []byte) error {
|
||||
func (t *thirdPartyResourceDataCodec) populateFromObject(objIn *extensions.ThirdPartyResourceData, mapObj map[string]interface{}, data []byte) error {
|
||||
typeMeta := unversioned.TypeMeta{}
|
||||
if err := json.Unmarshal(data, &typeMeta); err != nil {
|
||||
return err
|
||||
@@ -146,7 +146,7 @@ func (t *thirdPartyResourceDataCodec) populateFromObject(objIn *experimental.Thi
|
||||
}
|
||||
|
||||
func (t *thirdPartyResourceDataCodec) Decode(data []byte) (runtime.Object, error) {
|
||||
result := &experimental.ThirdPartyResourceData{}
|
||||
result := &extensions.ThirdPartyResourceData{}
|
||||
if err := t.populate(result, data); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -167,7 +167,7 @@ func (t *thirdPartyResourceDataCodec) DecodeToVersion(data []byte, version strin
|
||||
}
|
||||
|
||||
func (t *thirdPartyResourceDataCodec) DecodeInto(data []byte, obj runtime.Object) error {
|
||||
thirdParty, ok := obj.(*experimental.ThirdPartyResourceData)
|
||||
thirdParty, ok := obj.(*extensions.ThirdPartyResourceData)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected object: %#v", obj)
|
||||
}
|
||||
@@ -175,7 +175,7 @@ func (t *thirdPartyResourceDataCodec) DecodeInto(data []byte, obj runtime.Object
|
||||
}
|
||||
|
||||
func (t *thirdPartyResourceDataCodec) DecodeIntoWithSpecifiedVersionKind(data []byte, obj runtime.Object, version, kind string) error {
|
||||
thirdParty, ok := obj.(*experimental.ThirdPartyResourceData)
|
||||
thirdParty, ok := obj.(*extensions.ThirdPartyResourceData)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected object: %#v", obj)
|
||||
}
|
||||
@@ -226,7 +226,7 @@ const template = `{
|
||||
"items": [ %s ]
|
||||
}`
|
||||
|
||||
func encodeToJSON(obj *experimental.ThirdPartyResourceData, stream io.Writer) error {
|
||||
func encodeToJSON(obj *extensions.ThirdPartyResourceData, stream io.Writer) error {
|
||||
var objOut interface{}
|
||||
if err := json.Unmarshal(obj.Data, &objOut); err != nil {
|
||||
return err
|
||||
@@ -250,9 +250,9 @@ func (t *thirdPartyResourceDataCodec) Encode(obj runtime.Object) ([]byte, error)
|
||||
|
||||
func (t *thirdPartyResourceDataCodec) EncodeToStream(obj runtime.Object, stream io.Writer) (err error) {
|
||||
switch obj := obj.(type) {
|
||||
case *experimental.ThirdPartyResourceData:
|
||||
case *extensions.ThirdPartyResourceData:
|
||||
return encodeToJSON(obj, stream)
|
||||
case *experimental.ThirdPartyResourceDataList:
|
||||
case *extensions.ThirdPartyResourceDataList:
|
||||
// TODO: There must be a better way to do this...
|
||||
dataStrings := make([]string, len(obj.Items))
|
||||
for ix := range obj.Items {
|
||||
@@ -288,12 +288,12 @@ func (t *thirdPartyResourceDataCreator) New(groupVersion, kind string) (out runt
|
||||
if apiutil.GetGroupVersion(t.group, t.version) != groupVersion {
|
||||
return nil, fmt.Errorf("unknown version %s for kind %s", groupVersion, kind)
|
||||
}
|
||||
return &experimental.ThirdPartyResourceData{}, nil
|
||||
return &extensions.ThirdPartyResourceData{}, nil
|
||||
case "ThirdPartyResourceDataList":
|
||||
if apiutil.GetGroupVersion(t.group, t.version) != groupVersion {
|
||||
return nil, fmt.Errorf("unknown version %s for kind %s", groupVersion, kind)
|
||||
}
|
||||
return &experimental.ThirdPartyResourceDataList{}, nil
|
||||
return &extensions.ThirdPartyResourceDataList{}, nil
|
||||
default:
|
||||
return t.delegate.New(groupVersion, kind)
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ func TestCodec(t *testing.T) {
|
||||
}
|
||||
continue
|
||||
}
|
||||
rsrcObj, ok := obj.(*experimental.ThirdPartyResourceData)
|
||||
rsrcObj, ok := obj.(*extensions.ThirdPartyResourceData)
|
||||
if !ok {
|
||||
t.Errorf("[%s] unexpected object: %v", test.name, obj)
|
||||
continue
|
||||
@@ -149,7 +149,7 @@ func TestCreater(t *testing.T) {
|
||||
name: "valid ThirdPartyResourceData creation",
|
||||
version: "creater group/creater version",
|
||||
kind: "ThirdPartyResourceData",
|
||||
expectedObj: &experimental.ThirdPartyResourceData{},
|
||||
expectedObj: &extensions.ThirdPartyResourceData{},
|
||||
expectErr: false,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -40,8 +40,8 @@ func NewREST(s storage.Interface, group, kind string) *REST {
|
||||
prefix := "/ThirdPartyResourceData/" + group + "/" + strings.ToLower(kind) + "s"
|
||||
|
||||
store := &etcdgeneric.Etcd{
|
||||
NewFunc: func() runtime.Object { return &experimental.ThirdPartyResourceData{} },
|
||||
NewListFunc: func() runtime.Object { return &experimental.ThirdPartyResourceDataList{} },
|
||||
NewFunc: func() runtime.Object { return &extensions.ThirdPartyResourceData{} },
|
||||
NewListFunc: func() runtime.Object { return &extensions.ThirdPartyResourceDataList{} },
|
||||
KeyRootFunc: func(ctx api.Context) string {
|
||||
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
|
||||
},
|
||||
@@ -49,7 +49,7 @@ func NewREST(s storage.Interface, group, kind string) *REST {
|
||||
return etcdgeneric.NamespaceKeyFunc(ctx, prefix, id)
|
||||
},
|
||||
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
||||
return obj.(*experimental.ThirdPartyResourceData).Name, nil
|
||||
return obj.(*extensions.ThirdPartyResourceData).Name, nil
|
||||
},
|
||||
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
|
||||
return thirdpartyresourcedata.Matcher(label, field)
|
||||
|
||||
@@ -35,8 +35,8 @@ func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) {
|
||||
return NewREST(etcdStorage, "foo", "bar"), fakeClient
|
||||
}
|
||||
|
||||
func validNewThirdPartyResourceData(name string) *experimental.ThirdPartyResourceData {
|
||||
return &experimental.ThirdPartyResourceData{
|
||||
func validNewThirdPartyResourceData(name string) *extensions.ThirdPartyResourceData {
|
||||
return &extensions.ThirdPartyResourceData{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: api.NamespaceDefault,
|
||||
@@ -54,7 +54,7 @@ func TestCreate(t *testing.T) {
|
||||
// valid
|
||||
rsrc,
|
||||
// invalid
|
||||
&experimental.ThirdPartyResourceData{},
|
||||
&extensions.ThirdPartyResourceData{},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ func TestUpdate(t *testing.T) {
|
||||
validNewThirdPartyResourceData("foo"),
|
||||
// updateFunc
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*experimental.ThirdPartyResourceData)
|
||||
object := obj.(*extensions.ThirdPartyResourceData)
|
||||
object.Data = []byte("new description")
|
||||
return object
|
||||
},
|
||||
|
||||
@@ -28,15 +28,15 @@ import (
|
||||
// Registry is an interface implemented by things that know how to store ThirdPartyResourceData objects.
|
||||
type Registry interface {
|
||||
// ListThirdPartyResourceData obtains a list of ThirdPartyResourceData having labels which match selector.
|
||||
ListThirdPartyResourceData(ctx api.Context, selector labels.Selector) (*experimental.ThirdPartyResourceDataList, error)
|
||||
ListThirdPartyResourceData(ctx api.Context, selector labels.Selector) (*extensions.ThirdPartyResourceDataList, error)
|
||||
// Watch for new/changed/deleted ThirdPartyResourceData
|
||||
WatchThirdPartyResourceData(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
|
||||
// Get a specific ThirdPartyResourceData
|
||||
GetThirdPartyResourceData(ctx api.Context, name string) (*experimental.ThirdPartyResourceData, error)
|
||||
GetThirdPartyResourceData(ctx api.Context, name string) (*extensions.ThirdPartyResourceData, error)
|
||||
// Create a ThirdPartyResourceData based on a specification.
|
||||
CreateThirdPartyResourceData(ctx api.Context, resource *experimental.ThirdPartyResourceData) (*experimental.ThirdPartyResourceData, error)
|
||||
CreateThirdPartyResourceData(ctx api.Context, resource *extensions.ThirdPartyResourceData) (*extensions.ThirdPartyResourceData, error)
|
||||
// Update an existing ThirdPartyResourceData
|
||||
UpdateThirdPartyResourceData(ctx api.Context, resource *experimental.ThirdPartyResourceData) (*experimental.ThirdPartyResourceData, error)
|
||||
UpdateThirdPartyResourceData(ctx api.Context, resource *extensions.ThirdPartyResourceData) (*extensions.ThirdPartyResourceData, error)
|
||||
// Delete an existing ThirdPartyResourceData
|
||||
DeleteThirdPartyResourceData(ctx api.Context, name string) error
|
||||
}
|
||||
@@ -52,34 +52,34 @@ func NewRegistry(s rest.StandardStorage) Registry {
|
||||
return &storage{s}
|
||||
}
|
||||
|
||||
func (s *storage) ListThirdPartyResourceData(ctx api.Context, label labels.Selector) (*experimental.ThirdPartyResourceDataList, error) {
|
||||
func (s *storage) ListThirdPartyResourceData(ctx api.Context, label labels.Selector) (*extensions.ThirdPartyResourceDataList, error) {
|
||||
obj, err := s.List(ctx, label, fields.Everything())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*experimental.ThirdPartyResourceDataList), nil
|
||||
return obj.(*extensions.ThirdPartyResourceDataList), nil
|
||||
}
|
||||
|
||||
func (s *storage) WatchThirdPartyResourceData(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
|
||||
return s.Watch(ctx, label, field, resourceVersion)
|
||||
}
|
||||
|
||||
func (s *storage) GetThirdPartyResourceData(ctx api.Context, name string) (*experimental.ThirdPartyResourceData, error) {
|
||||
func (s *storage) GetThirdPartyResourceData(ctx api.Context, name string) (*extensions.ThirdPartyResourceData, error) {
|
||||
obj, err := s.Get(ctx, name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*experimental.ThirdPartyResourceData), nil
|
||||
return obj.(*extensions.ThirdPartyResourceData), nil
|
||||
}
|
||||
|
||||
func (s *storage) CreateThirdPartyResourceData(ctx api.Context, ThirdPartyResourceData *experimental.ThirdPartyResourceData) (*experimental.ThirdPartyResourceData, error) {
|
||||
func (s *storage) CreateThirdPartyResourceData(ctx api.Context, ThirdPartyResourceData *extensions.ThirdPartyResourceData) (*extensions.ThirdPartyResourceData, error) {
|
||||
obj, err := s.Create(ctx, ThirdPartyResourceData)
|
||||
return obj.(*experimental.ThirdPartyResourceData), err
|
||||
return obj.(*extensions.ThirdPartyResourceData), err
|
||||
}
|
||||
|
||||
func (s *storage) UpdateThirdPartyResourceData(ctx api.Context, ThirdPartyResourceData *experimental.ThirdPartyResourceData) (*experimental.ThirdPartyResourceData, error) {
|
||||
func (s *storage) UpdateThirdPartyResourceData(ctx api.Context, ThirdPartyResourceData *extensions.ThirdPartyResourceData) (*extensions.ThirdPartyResourceData, error) {
|
||||
obj, _, err := s.Update(ctx, ThirdPartyResourceData)
|
||||
return obj.(*experimental.ThirdPartyResourceData), err
|
||||
return obj.(*extensions.ThirdPartyResourceData), err
|
||||
}
|
||||
|
||||
func (s *storage) DeleteThirdPartyResourceData(ctx api.Context, name string) error {
|
||||
|
||||
@@ -52,7 +52,7 @@ func (strategy) PrepareForCreate(obj runtime.Object) {
|
||||
}
|
||||
|
||||
func (strategy) Validate(ctx api.Context, obj runtime.Object) fielderrors.ValidationErrorList {
|
||||
return validation.ValidateThirdPartyResourceData(obj.(*experimental.ThirdPartyResourceData))
|
||||
return validation.ValidateThirdPartyResourceData(obj.(*extensions.ThirdPartyResourceData))
|
||||
}
|
||||
|
||||
func (strategy) AllowCreateOnUpdate() bool {
|
||||
@@ -63,7 +63,7 @@ func (strategy) PrepareForUpdate(obj, old runtime.Object) {
|
||||
}
|
||||
|
||||
func (strategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
||||
return validation.ValidateThirdPartyResourceDataUpdate(old.(*experimental.ThirdPartyResourceData), obj.(*experimental.ThirdPartyResourceData))
|
||||
return validation.ValidateThirdPartyResourceDataUpdate(old.(*extensions.ThirdPartyResourceData), obj.(*extensions.ThirdPartyResourceData))
|
||||
}
|
||||
|
||||
func (strategy) AllowUnconditionalUpdate() bool {
|
||||
@@ -73,7 +73,7 @@ func (strategy) AllowUnconditionalUpdate() bool {
|
||||
// Matcher returns a generic matcher for a given label and field selector.
|
||||
func Matcher(label labels.Selector, field fields.Selector) generic.Matcher {
|
||||
return generic.MatcherFunc(func(obj runtime.Object) (bool, error) {
|
||||
sa, ok := obj.(*experimental.ThirdPartyResourceData)
|
||||
sa, ok := obj.(*extensions.ThirdPartyResourceData)
|
||||
if !ok {
|
||||
return false, fmt.Errorf("not a ThirdPartyResourceData")
|
||||
}
|
||||
@@ -83,6 +83,6 @@ func Matcher(label labels.Selector, field fields.Selector) generic.Matcher {
|
||||
}
|
||||
|
||||
// SelectableFields returns a label set that can be used for filter selection
|
||||
func SelectableFields(obj *experimental.ThirdPartyResourceData) labels.Set {
|
||||
func SelectableFields(obj *extensions.ThirdPartyResourceData) labels.Set {
|
||||
return labels.Set{}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ func convertToCamelCase(input string) string {
|
||||
return result
|
||||
}
|
||||
|
||||
func ExtractApiGroupAndKind(rsrc *experimental.ThirdPartyResource) (kind string, group string, err error) {
|
||||
func ExtractApiGroupAndKind(rsrc *extensions.ThirdPartyResource) (kind string, group string, err error) {
|
||||
parts := strings.Split(rsrc.Name, ".")
|
||||
if len(parts) < 3 {
|
||||
return "", "", fmt.Errorf("unexpectedly short resource name: %s, expected at least <kind>.<domain>.<tld>", rsrc.Name)
|
||||
|
||||
@@ -47,7 +47,7 @@ func TestExtractAPIGroupAndKind(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
kind, group, err := ExtractApiGroupAndKind(&experimental.ThirdPartyResource{ObjectMeta: api.ObjectMeta{Name: test.input}})
|
||||
kind, group, err := ExtractApiGroupAndKind(&extensions.ThirdPartyResource{ObjectMeta: api.ObjectMeta{Name: test.input}})
|
||||
if err != nil && !test.expectErr {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user