experimental. -> extensions.

This commit is contained in:
Chao Xu
2015-10-09 15:49:10 -07:00
parent 2816eb0f8a
commit 7c9f4cc42f
81 changed files with 839 additions and 839 deletions

View File

@@ -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,
},

View File

@@ -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)

View File

@@ -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 {

View File

@@ -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.")
}