forked from barak/tarpoon
Add glide.yaml and vendor deps
This commit is contained in:
parent
db918f12ad
commit
5b3d5e81bd
18880 changed files with 5166045 additions and 1 deletions
47
vendor/k8s.io/kubernetes/pkg/registry/batch/cronjob/etcd/BUILD
generated
vendored
Normal file
47
vendor/k8s.io/kubernetes/pkg/registry/batch/cronjob/etcd/BUILD
generated
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
"go_test",
|
||||
"cgo_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["etcd.go"],
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//pkg/api:go_default_library",
|
||||
"//pkg/api/rest:go_default_library",
|
||||
"//pkg/apis/batch:go_default_library",
|
||||
"//pkg/registry/batch/cronjob:go_default_library",
|
||||
"//pkg/registry/cachesize:go_default_library",
|
||||
"//pkg/registry/generic:go_default_library",
|
||||
"//pkg/registry/generic/registry:go_default_library",
|
||||
"//pkg/runtime:go_default_library",
|
||||
"//pkg/storage:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["etcd_test.go"],
|
||||
library = "go_default_library",
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//pkg/api:go_default_library",
|
||||
"//pkg/api/testapi:go_default_library",
|
||||
"//pkg/apis/batch:go_default_library",
|
||||
"//pkg/apis/batch/v2alpha1:go_default_library",
|
||||
"//pkg/fields:go_default_library",
|
||||
"//pkg/labels:go_default_library",
|
||||
"//pkg/registry/generic:go_default_library",
|
||||
"//pkg/registry/registrytest:go_default_library",
|
||||
"//pkg/runtime:go_default_library",
|
||||
"//pkg/storage/etcd/testing:go_default_library",
|
||||
],
|
||||
)
|
||||
111
vendor/k8s.io/kubernetes/pkg/registry/batch/cronjob/etcd/etcd.go
generated
vendored
Normal file
111
vendor/k8s.io/kubernetes/pkg/registry/batch/cronjob/etcd/etcd.go
generated
vendored
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
Copyright 2016 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 etcd
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/rest"
|
||||
"k8s.io/kubernetes/pkg/apis/batch"
|
||||
"k8s.io/kubernetes/pkg/registry/batch/cronjob"
|
||||
"k8s.io/kubernetes/pkg/registry/cachesize"
|
||||
"k8s.io/kubernetes/pkg/registry/generic"
|
||||
genericregistry "k8s.io/kubernetes/pkg/registry/generic/registry"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/storage"
|
||||
)
|
||||
|
||||
// REST implements a RESTStorage for scheduled jobs against etcd
|
||||
type REST struct {
|
||||
*genericregistry.Store
|
||||
}
|
||||
|
||||
// NewREST returns a RESTStorage object that will work against CronJobs.
|
||||
func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
|
||||
prefix := "/" + opts.ResourcePrefix
|
||||
|
||||
newListFunc := func() runtime.Object { return &batch.CronJobList{} }
|
||||
storageInterface, dFunc := opts.Decorator(
|
||||
opts.StorageConfig,
|
||||
cachesize.GetWatchCacheSizeByResource(cachesize.CronJobs),
|
||||
&batch.CronJob{},
|
||||
prefix,
|
||||
cronjob.Strategy,
|
||||
newListFunc,
|
||||
cronjob.GetAttrs,
|
||||
storage.NoTriggerPublisher,
|
||||
)
|
||||
|
||||
store := &genericregistry.Store{
|
||||
NewFunc: func() runtime.Object { return &batch.CronJob{} },
|
||||
|
||||
// NewListFunc returns an object capable of storing results of an etcd list.
|
||||
NewListFunc: newListFunc,
|
||||
// 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 {
|
||||
return genericregistry.NamespaceKeyRootFunc(ctx, prefix)
|
||||
},
|
||||
// Produces a path that etcd understands, to the resource by combining
|
||||
// the namespace in the context with the given prefix
|
||||
KeyFunc: func(ctx api.Context, name string) (string, error) {
|
||||
return genericregistry.NamespaceKeyFunc(ctx, prefix, name)
|
||||
},
|
||||
// Retrieve the name field of a scheduled job
|
||||
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
||||
return obj.(*batch.CronJob).Name, nil
|
||||
},
|
||||
// Used to match objects based on labels/fields for list and watch
|
||||
PredicateFunc: cronjob.MatchCronJob,
|
||||
QualifiedResource: batch.Resource("cronjobs"),
|
||||
EnableGarbageCollection: opts.EnableGarbageCollection,
|
||||
DeleteCollectionWorkers: opts.DeleteCollectionWorkers,
|
||||
|
||||
// Used to validate scheduled job creation
|
||||
CreateStrategy: cronjob.Strategy,
|
||||
|
||||
// Used to validate scheduled job updates
|
||||
UpdateStrategy: cronjob.Strategy,
|
||||
DeleteStrategy: cronjob.Strategy,
|
||||
|
||||
Storage: storageInterface,
|
||||
DestroyFunc: dFunc,
|
||||
}
|
||||
|
||||
statusStore := *store
|
||||
statusStore.UpdateStrategy = cronjob.StatusStrategy
|
||||
|
||||
return &REST{store}, &StatusREST{store: &statusStore}
|
||||
}
|
||||
|
||||
// StatusREST implements the REST endpoint for changing the status of a resourcequota.
|
||||
type StatusREST struct {
|
||||
store *genericregistry.Store
|
||||
}
|
||||
|
||||
func (r *StatusREST) New() runtime.Object {
|
||||
return &batch.CronJob{}
|
||||
}
|
||||
|
||||
// Get retrieves the object from the storage. It is required to support Patch.
|
||||
func (r *StatusREST) Get(ctx api.Context, name string) (runtime.Object, error) {
|
||||
return r.store.Get(ctx, name)
|
||||
}
|
||||
|
||||
// Update alters the status subset of an object.
|
||||
func (r *StatusREST) Update(ctx api.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
}
|
||||
183
vendor/k8s.io/kubernetes/pkg/registry/batch/cronjob/etcd/etcd_test.go
generated
vendored
Normal file
183
vendor/k8s.io/kubernetes/pkg/registry/batch/cronjob/etcd/etcd_test.go
generated
vendored
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
/*
|
||||
Copyright 2016 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 etcd
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/testapi"
|
||||
"k8s.io/kubernetes/pkg/apis/batch"
|
||||
"k8s.io/kubernetes/pkg/apis/batch/v2alpha1"
|
||||
"k8s.io/kubernetes/pkg/fields"
|
||||
"k8s.io/kubernetes/pkg/labels"
|
||||
"k8s.io/kubernetes/pkg/registry/generic"
|
||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
etcdtesting "k8s.io/kubernetes/pkg/storage/etcd/testing"
|
||||
)
|
||||
|
||||
func newStorage(t *testing.T) (*REST, *StatusREST, *etcdtesting.EtcdTestServer) {
|
||||
etcdStorage, server := registrytest.NewEtcdStorage(t, batch.GroupName)
|
||||
restOptions := generic.RESTOptions{StorageConfig: etcdStorage, Decorator: generic.UndecoratedStorage, DeleteCollectionWorkers: 1}
|
||||
storage, statusStorage := NewREST(restOptions)
|
||||
return storage, statusStorage, server
|
||||
}
|
||||
|
||||
func validNewCronJob() *batch.CronJob {
|
||||
return &batch.CronJob{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: batch.CronJobSpec{
|
||||
Schedule: "* * * * ?",
|
||||
ConcurrencyPolicy: batch.AllowConcurrent,
|
||||
JobTemplate: batch.JobTemplateSpec{
|
||||
Spec: batch.JobSpec{
|
||||
Template: api.PodTemplateSpec{
|
||||
Spec: api.PodSpec{
|
||||
RestartPolicy: api.RestartPolicyOnFailure,
|
||||
DNSPolicy: api.DNSClusterFirst,
|
||||
Containers: []api.Container{{Name: "abc", Image: "image", ImagePullPolicy: api.PullIfNotPresent}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreate(t *testing.T) {
|
||||
// scheduled jobs should be tested only when batch/v2alpha1 is enabled
|
||||
if *testapi.Batch.GroupVersion() != v2alpha1.SchemeGroupVersion {
|
||||
return
|
||||
}
|
||||
|
||||
storage, _, server := newStorage(t)
|
||||
defer server.Terminate(t)
|
||||
defer storage.Store.DestroyFunc()
|
||||
test := registrytest.New(t, storage.Store)
|
||||
validCronJob := validNewCronJob()
|
||||
validCronJob.ObjectMeta = api.ObjectMeta{}
|
||||
test.TestCreate(
|
||||
// valid
|
||||
validCronJob,
|
||||
// invalid (empty spec)
|
||||
&batch.CronJob{
|
||||
Spec: batch.CronJobSpec{},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func TestUpdate(t *testing.T) {
|
||||
// scheduled jobs should be tested only when batch/v2alpha1 is enabled
|
||||
if *testapi.Batch.GroupVersion() != v2alpha1.SchemeGroupVersion {
|
||||
return
|
||||
}
|
||||
|
||||
storage, _, server := newStorage(t)
|
||||
defer server.Terminate(t)
|
||||
defer storage.Store.DestroyFunc()
|
||||
test := registrytest.New(t, storage.Store)
|
||||
schedule := "1 1 1 1 ?"
|
||||
test.TestUpdate(
|
||||
// valid
|
||||
validNewCronJob(),
|
||||
// updateFunc
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*batch.CronJob)
|
||||
object.Spec.Schedule = schedule
|
||||
return object
|
||||
},
|
||||
// invalid updateFunc
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*batch.CronJob)
|
||||
object.Spec.Schedule = "* * *"
|
||||
return object
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func TestDelete(t *testing.T) {
|
||||
// scheduled jobs should be tested only when batch/v2alpha1 is enabled
|
||||
if *testapi.Batch.GroupVersion() != v2alpha1.SchemeGroupVersion {
|
||||
return
|
||||
}
|
||||
|
||||
storage, _, server := newStorage(t)
|
||||
defer server.Terminate(t)
|
||||
defer storage.Store.DestroyFunc()
|
||||
test := registrytest.New(t, storage.Store)
|
||||
test.TestDelete(validNewCronJob())
|
||||
}
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
// scheduled jobs should be tested only when batch/v2alpha1 is enabled
|
||||
if *testapi.Batch.GroupVersion() != v2alpha1.SchemeGroupVersion {
|
||||
return
|
||||
}
|
||||
|
||||
storage, _, server := newStorage(t)
|
||||
defer server.Terminate(t)
|
||||
defer storage.Store.DestroyFunc()
|
||||
test := registrytest.New(t, storage.Store)
|
||||
test.TestGet(validNewCronJob())
|
||||
}
|
||||
|
||||
func TestList(t *testing.T) {
|
||||
// scheduled jobs should be tested only when batch/v2alpha1 is enabled
|
||||
if *testapi.Batch.GroupVersion() != v2alpha1.SchemeGroupVersion {
|
||||
return
|
||||
}
|
||||
|
||||
storage, _, server := newStorage(t)
|
||||
defer server.Terminate(t)
|
||||
defer storage.Store.DestroyFunc()
|
||||
test := registrytest.New(t, storage.Store)
|
||||
test.TestList(validNewCronJob())
|
||||
}
|
||||
|
||||
func TestWatch(t *testing.T) {
|
||||
// scheduled jobs should be tested only when batch/v2alpha1 is enabled
|
||||
if *testapi.Batch.GroupVersion() != v2alpha1.SchemeGroupVersion {
|
||||
return
|
||||
}
|
||||
|
||||
storage, _, server := newStorage(t)
|
||||
defer server.Terminate(t)
|
||||
defer storage.Store.DestroyFunc()
|
||||
test := registrytest.New(t, storage.Store)
|
||||
test.TestWatch(
|
||||
validNewCronJob(),
|
||||
// matching labels
|
||||
[]labels.Set{},
|
||||
// not matching labels
|
||||
[]labels.Set{
|
||||
{"x": "y"},
|
||||
},
|
||||
// matching fields
|
||||
[]fields.Set{},
|
||||
// not matching fields
|
||||
[]fields.Set{
|
||||
{"metadata.name": "xyz"},
|
||||
{"name": "foo"},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// TODO: test update /status
|
||||
Loading…
Add table
Add a link
Reference in a new issue