Cleanup util file
Kubernetes-commit: 762518fd47bb058d11b26c60d9cf9f9a9c5b3c05
This commit is contained in:
parent
cc7d4cc1f1
commit
01c4fe2028
|
@ -47,7 +47,7 @@ import (
|
|||
"k8s.io/apiserver/pkg/features"
|
||||
"k8s.io/apiserver/pkg/storage"
|
||||
"k8s.io/apiserver/pkg/storage/etcd"
|
||||
storagetests "k8s.io/apiserver/pkg/storage/tests"
|
||||
storagetesting "k8s.io/apiserver/pkg/storage/testing"
|
||||
"k8s.io/apiserver/pkg/storage/value"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
||||
|
@ -693,13 +693,13 @@ func TestTransformationFailure(t *testing.T) {
|
|||
key: "/one-level/test",
|
||||
obj: &example.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "bar"},
|
||||
Spec: storagetests.DeepEqualSafePodSpec(),
|
||||
Spec: storagetesting.DeepEqualSafePodSpec(),
|
||||
},
|
||||
}, {
|
||||
key: "/two-level/1/test",
|
||||
obj: &example.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "baz"},
|
||||
Spec: storagetests.DeepEqualSafePodSpec(),
|
||||
Spec: storagetesting.DeepEqualSafePodSpec(),
|
||||
},
|
||||
}}
|
||||
for i, ps := range preset[:1] {
|
||||
|
|
|
@ -22,15 +22,16 @@ import (
|
|||
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apiserver/pkg/apis/example"
|
||||
"k8s.io/apiserver/pkg/storage"
|
||||
)
|
||||
|
||||
// CreateObj will create a single object using the storage interface
|
||||
// CreateObj will create a single object using the storage interface.
|
||||
func CreateObj(helper storage.Interface, name string, obj, out runtime.Object, ttl uint64) error {
|
||||
return helper.Create(context.TODO(), name, obj, out, ttl)
|
||||
}
|
||||
|
||||
//CreateObjList will create a list from the array of objects
|
||||
// CreateObjList will create a list from the array of objects.
|
||||
func CreateObjList(prefix string, helper storage.Interface, items []runtime.Object) error {
|
||||
for i := range items {
|
||||
obj := items[i]
|
||||
|
@ -47,7 +48,7 @@ func CreateObjList(prefix string, helper storage.Interface, items []runtime.Obje
|
|||
return nil
|
||||
}
|
||||
|
||||
// CreateList will properly create a list using the storage interface
|
||||
// CreateList will properly create a list using the storage interface.
|
||||
func CreateList(prefix string, helper storage.Interface, list runtime.Object) error {
|
||||
items, err := meta.ExtractList(list)
|
||||
if err != nil {
|
||||
|
@ -59,3 +60,13 @@ func CreateList(prefix string, helper storage.Interface, list runtime.Object) er
|
|||
}
|
||||
return meta.SetList(list, items)
|
||||
}
|
||||
|
||||
// DeepEqualSafePodSpec returns an example.PodSpec safe for deep-equal operations.
|
||||
func DeepEqualSafePodSpec() example.PodSpec {
|
||||
grace := int64(30)
|
||||
return example.PodSpec{
|
||||
RestartPolicy: "Always",
|
||||
TerminationGracePeriodSeconds: &grace,
|
||||
SchedulerName: "default-scheduler",
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ import (
|
|||
"k8s.io/apiserver/pkg/storage/etcd/etcdtest"
|
||||
etcdtesting "k8s.io/apiserver/pkg/storage/etcd/testing"
|
||||
"k8s.io/apiserver/pkg/storage/etcd3"
|
||||
storagetesting "k8s.io/apiserver/pkg/storage/testing"
|
||||
"k8s.io/apiserver/pkg/storage/value"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
||||
|
@ -120,7 +121,7 @@ func newTestCacher(s storage.Interface, cap int) (*cacherstorage.Cacher, storage
|
|||
func makeTestPod(name string) *example.Pod {
|
||||
return &example.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "ns", Name: name},
|
||||
Spec: DeepEqualSafePodSpec(),
|
||||
Spec: storagetesting.DeepEqualSafePodSpec(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
Copyright 2017 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package tests
|
||||
|
||||
import (
|
||||
"k8s.io/apiserver/pkg/apis/example"
|
||||
)
|
||||
|
||||
func DeepEqualSafePodSpec() example.PodSpec {
|
||||
grace := int64(30)
|
||||
return example.PodSpec{
|
||||
RestartPolicy: "Always",
|
||||
TerminationGracePeriodSeconds: &grace,
|
||||
SchedulerName: "default-scheduler",
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue