Set uid during object create

This commit is contained in:
derekwaynecarr
2014-11-12 16:27:10 -05:00
parent d4108ec47e
commit 15701ff403
13 changed files with 106 additions and 11 deletions

View File

@@ -29,7 +29,6 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/master/ports"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
)
// REST implements the RESTStorage interface, backed by a MinionRegistry.
@@ -57,7 +56,7 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan apiserver.RE
return nil, kerrors.NewInvalid("minion", minion.Name, errs)
}
minion.CreationTimestamp = util.Now()
api.FillObjectMetaSystemFields(ctx, &minion.ObjectMeta)
return apiserver.MakeAsync(func() (runtime.Object, error) {
err := rs.registry.CreateMinion(ctx, minion)

View File

@@ -43,6 +43,9 @@ func TestMinionREST(t *testing.T) {
t.Errorf("insert failed")
}
obj := <-c
if !api.HasObjectMetaSystemFieldValues(&obj.Object.(*api.Minion).ObjectMeta) {
t.Errorf("storage did not populate object meta field values")
}
if m, ok := obj.Object.(*api.Minion); !ok || m.Name != "baz" {
t.Errorf("insert return value was weird: %#v", obj)
}