Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
da4a875e
Commit
da4a875e
authored
Jul 04, 2017
by
Shiyang Wang
Committed by
shiywang
Jul 08, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move pkg/apimachinery/test to apimachinery
parent
62ba00e4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
1595 additions
and
132 deletions
+1595
-132
.linted_packages
hack/.linted_packages
+2
-0
BUILD
pkg/apimachinery/tests/BUILD
+1
-34
BUILD
pkg/generated/openapi/BUILD
+1
-0
BUILD
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/BUILD
+25
-0
doc.go
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/doc.go
+22
-0
BUILD
...rc/k8s.io/apimachinery/pkg/apis/testapigroup/fuzzer/BUILD
+22
-0
fuzzer.go
...8s.io/apimachinery/pkg/apis/testapigroup/fuzzer/fuzzer.go
+99
-0
BUILD
...c/k8s.io/apimachinery/pkg/apis/testapigroup/install/BUILD
+21
-0
install.go
....io/apimachinery/pkg/apis/testapigroup/install/install.go
+44
-0
register.go
...src/k8s.io/apimachinery/pkg/apis/testapigroup/register.go
+51
-0
types.go
...ng/src/k8s.io/apimachinery/pkg/apis/testapigroup/types.go
+134
-0
BUILD
...ng/src/k8s.io/apimachinery/pkg/apis/testapigroup/v1/BUILD
+36
-0
conversion.go
...8s.io/apimachinery/pkg/apis/testapigroup/v1/conversion.go
+26
-0
defaults.go
.../k8s.io/apimachinery/pkg/apis/testapigroup/v1/defaults.go
+26
-0
doc.go
...g/src/k8s.io/apimachinery/pkg/apis/testapigroup/v1/doc.go
+23
-0
generated.pb.go
....io/apimachinery/pkg/apis/testapigroup/v1/generated.pb.go
+0
-0
generated.proto
....io/apimachinery/pkg/apis/testapigroup/v1/generated.proto
+212
-0
register.go
.../k8s.io/apimachinery/pkg/apis/testapigroup/v1/register.go
+63
-0
types.generated.go
.../apimachinery/pkg/apis/testapigroup/v1/types.generated.go
+0
-0
types.go
...src/k8s.io/apimachinery/pkg/apis/testapigroup/v1/types.go
+192
-0
types_swagger_doc_generated.go
...y/pkg/apis/testapigroup/v1/types_swagger_doc_generated.go
+2
-5
zz_generated.conversion.go
...inery/pkg/apis/testapigroup/v1/zz_generated.conversion.go
+35
-0
zz_generated.deepcopy.go
...chinery/pkg/apis/testapigroup/v1/zz_generated.deepcopy.go
+155
-0
zz_generated.defaults.go
...chinery/pkg/apis/testapigroup/v1/zz_generated.defaults.go
+32
-0
zz_generated.deepcopy.go
...imachinery/pkg/apis/testapigroup/zz_generated.deepcopy.go
+155
-0
BUILD
staging/src/k8s.io/apimachinery/pkg/test/BUILD
+52
-0
api_meta_help_test.go
...ng/src/k8s.io/apimachinery/pkg/test/api_meta_help_test.go
+32
-32
api_meta_meta_test.go
...ng/src/k8s.io/apimachinery/pkg/test/api_meta_meta_test.go
+4
-4
apis_meta_v1_unstructed_unstructure_test.go
...nery/pkg/test/apis_meta_v1_unstructed_unstructure_test.go
+15
-23
runtime_helper_test.go
...g/src/k8s.io/apimachinery/pkg/test/runtime_helper_test.go
+13
-9
runtime_serializer_protobuf_protobuf_test.go
...ery/pkg/test/runtime_serializer_protobuf_protobuf_test.go
+5
-5
runtime_unversioned_test.go
.../k8s.io/apimachinery/pkg/test/runtime_unversioned_test.go
+10
-8
util.go
staging/src/k8s.io/apimachinery/pkg/test/util.go
+57
-0
BUILD
staging/src/k8s.io/apimachinery/pkg/watch/BUILD
+11
-0
until_test.go
staging/src/k8s.io/apimachinery/pkg/watch/until_test.go
+17
-12
No files found.
hack/.linted_packages
View file @
da4a875e
...
@@ -69,6 +69,7 @@ pkg/api/service
...
@@ -69,6 +69,7 @@ pkg/api/service
pkg/api/v1
pkg/api/v1
pkg/api/v1/node
pkg/api/v1/node
pkg/api/v1/service
pkg/api/v1/service
pkg/apimachinery/tests
pkg/apis/abac/v0
pkg/apis/abac/v0
pkg/apis/abac/v1beta1
pkg/apis/abac/v1beta1
pkg/apis/admission/install
pkg/apis/admission/install
...
@@ -341,6 +342,7 @@ staging/src/k8s.io/apimachinery/pkg/api/equality
...
@@ -341,6 +342,7 @@ staging/src/k8s.io/apimachinery/pkg/api/equality
staging/src/k8s.io/apimachinery/pkg/api/errors
staging/src/k8s.io/apimachinery/pkg/api/errors
staging/src/k8s.io/apimachinery/pkg/api/resource
staging/src/k8s.io/apimachinery/pkg/api/resource
staging/src/k8s.io/apimachinery/pkg/apimachinery
staging/src/k8s.io/apimachinery/pkg/apimachinery
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/install
staging/src/k8s.io/apimachinery/pkg/conversion/queryparams
staging/src/k8s.io/apimachinery/pkg/conversion/queryparams
staging/src/k8s.io/apimachinery/pkg/fields
staging/src/k8s.io/apimachinery/pkg/fields
staging/src/k8s.io/apimachinery/pkg/labels
staging/src/k8s.io/apimachinery/pkg/labels
...
...
pkg/apimachinery/tests/BUILD
View file @
da4a875e
...
@@ -4,53 +4,20 @@ licenses(["notice"])
...
@@ -4,53 +4,20 @@ licenses(["notice"])
load(
load(
"@io_bazel_rules_go//go:def.bzl",
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
"go_test",
)
)
go_test(
go_test(
name = "go_default_test",
name = "go_default_test",
srcs = [
srcs = ["api_meta_scheme_test.go"],
"api_meta_help_test.go",
"api_meta_meta_test.go",
"api_meta_scheme_test.go",
"apis_meta_v1_unstructed_unstructure_test.go",
"runtime_helper_test.go",
"runtime_serializer_protobuf_protobuf_test.go",
"runtime_unversioned_test.go",
"watch_until_test.go",
],
library = ":go_default_library",
tags = ["automanaged"],
tags = ["automanaged"],
deps = [
deps = [
"//pkg/api:go_default_library",
"//pkg/api/install:go_default_library",
"//pkg/api/testapi:go_default_library",
"//pkg/api/testapi:go_default_library",
"//pkg/api/validation:go_default_library",
"//pkg/apis/extensions:go_default_library",
"//vendor/github.com/google/gofuzz:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer/protobuf:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/diff:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
],
],
)
)
go_library(
name = "go_default_library",
srcs = ["doc.go"],
tags = ["automanaged"],
)
filegroup(
filegroup(
name = "package-srcs",
name = "package-srcs",
srcs = glob(["**"]),
srcs = glob(["**"]),
...
...
pkg/generated/openapi/BUILD
View file @
da4a875e
...
@@ -42,6 +42,7 @@ openapi_library(
...
@@ -42,6 +42,7 @@ openapi_library(
"k8s.io/apimachinery/pkg/api/resource",
"k8s.io/apimachinery/pkg/api/resource",
"k8s.io/apimachinery/pkg/apis/meta/v1",
"k8s.io/apimachinery/pkg/apis/meta/v1",
"k8s.io/apimachinery/pkg/apis/meta/v1alpha1",
"k8s.io/apimachinery/pkg/apis/meta/v1alpha1",
"k8s.io/apimachinery/pkg/apis/testapigroup/v1",
"k8s.io/apimachinery/pkg/runtime",
"k8s.io/apimachinery/pkg/runtime",
"k8s.io/apimachinery/pkg/util/intstr",
"k8s.io/apimachinery/pkg/util/intstr",
"k8s.io/apimachinery/pkg/version",
"k8s.io/apimachinery/pkg/version",
...
...
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/BUILD
0 → 100644
View file @
da4a875e
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"doc.go",
"register.go",
"types.go",
"zz_generated.deepcopy.go",
],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
],
)
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/doc.go
0 → 100644
View file @
da4a875e
/*
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.
*/
// +k8s:deepcopy-gen=package,register
// +groupName=example.k8s.io
//
// package example contains an example API used to demonstrate how to create api groups. Moreover, this is
// used within tests.
package
testapigroup
// import "k8s.io/apiserver/pkg/apis/example"
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/fuzzer/BUILD
0 → 100644
View file @
da4a875e
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["fuzzer.go"],
tags = ["automanaged"],
deps = [
"//vendor/github.com/google/gofuzz:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/testing:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/testapigroup:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/testapigroup/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
],
)
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/fuzzer/fuzzer.go
0 → 100644
View file @
da4a875e
/*
Copyright 2015 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
fuzzer
import
(
"github.com/google/gofuzz"
apitesting
"k8s.io/apimachinery/pkg/api/testing"
example
"k8s.io/apimachinery/pkg/apis/testapigroup"
examplev1
"k8s.io/apimachinery/pkg/apis/testapigroup/v1"
"k8s.io/apimachinery/pkg/runtime"
runtimeserializer
"k8s.io/apimachinery/pkg/runtime/serializer"
)
// overrideGenericFuncs override some generic fuzzer funcs from k8s.io/apiserver in order to have more realistic
// values in a Kubernetes context.
func
overrideGenericFuncs
(
t
apitesting
.
TestingCommon
,
codecs
runtimeserializer
.
CodecFactory
)
[]
interface
{}
{
return
[]
interface
{}{
func
(
j
*
runtime
.
Object
,
c
fuzz
.
Continue
)
{
// TODO: uncomment when round trip starts from a versioned object
if
true
{
//c.RandBool() {
*
j
=
&
runtime
.
Unknown
{
// We do not set TypeMeta here because it is not carried through a round trip
Raw
:
[]
byte
(
`{"apiVersion":"unknown.group/unknown","kind":"Something","someKey":"someValue"}`
),
ContentType
:
runtime
.
ContentTypeJSON
,
}
}
else
{
types
:=
[]
runtime
.
Object
{
&
example
.
Carp
{}}
t
:=
types
[
c
.
Rand
.
Intn
(
len
(
types
))]
c
.
Fuzz
(
t
)
*
j
=
t
}
},
func
(
r
*
runtime
.
RawExtension
,
c
fuzz
.
Continue
)
{
// Pick an arbitrary type and fuzz it
types
:=
[]
runtime
.
Object
{
&
example
.
Carp
{}}
obj
:=
types
[
c
.
Rand
.
Intn
(
len
(
types
))]
c
.
Fuzz
(
obj
)
// Convert the object to raw bytes
bytes
,
err
:=
runtime
.
Encode
(
apitesting
.
TestCodec
(
codecs
,
examplev1
.
SchemeGroupVersion
),
obj
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to encode object: %v"
,
err
)
return
}
// Set the bytes field on the RawExtension
r
.
Raw
=
bytes
},
}
}
func
exampleFuncs
(
t
apitesting
.
TestingCommon
)
[]
interface
{}
{
return
[]
interface
{}{
func
(
s
*
example
.
CarpSpec
,
c
fuzz
.
Continue
)
{
c
.
FuzzNoCustom
(
s
)
// has a default value
ttl
:=
int64
(
30
)
if
c
.
RandBool
()
{
ttl
=
int64
(
c
.
Uint32
())
}
s
.
TerminationGracePeriodSeconds
=
&
ttl
if
s
.
SchedulerName
==
""
{
s
.
SchedulerName
=
"default-scheduler"
}
},
func
(
j
*
example
.
CarpPhase
,
c
fuzz
.
Continue
)
{
statuses
:=
[]
example
.
CarpPhase
{
"Pending"
,
"Running"
,
"Succeeded"
,
"Failed"
,
"Unknown"
}
*
j
=
statuses
[
c
.
Rand
.
Intn
(
len
(
statuses
))]
},
func
(
rp
*
example
.
RestartPolicy
,
c
fuzz
.
Continue
)
{
policies
:=
[]
example
.
RestartPolicy
{
"Always"
,
"Never"
,
"OnFailure"
}
*
rp
=
policies
[
c
.
Rand
.
Intn
(
len
(
policies
))]
},
}
}
func
Funcs
(
t
apitesting
.
TestingCommon
,
codecs
runtimeserializer
.
CodecFactory
)
[]
interface
{}
{
return
apitesting
.
MergeFuzzerFuncs
(
t
,
apitesting
.
GenericFuzzerFuncs
(
t
,
codecs
),
overrideGenericFuncs
(
t
,
codecs
),
exampleFuncs
(
t
),
)
}
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/install/BUILD
0 → 100644
View file @
da4a875e
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["install.go"],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/apimachinery/announced:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apimachinery/registered:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/testapigroup:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/testapigroup/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
],
)
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/install/install.go
0 → 100644
View file @
da4a875e
/*
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 install installs the certificates API group, making it available as
// an option to all of the API encoding/decoding machinery.
package
install
import
(
"k8s.io/apimachinery/pkg/apimachinery/announced"
"k8s.io/apimachinery/pkg/apimachinery/registered"
example
"k8s.io/apimachinery/pkg/apis/testapigroup"
examplev1
"k8s.io/apimachinery/pkg/apis/testapigroup/v1"
"k8s.io/apimachinery/pkg/runtime"
)
// Install registers the API group and adds types to a scheme
func
Install
(
groupFactoryRegistry
announced
.
APIGroupFactoryRegistry
,
registry
*
registered
.
APIRegistrationManager
,
scheme
*
runtime
.
Scheme
)
{
if
err
:=
announced
.
NewGroupMetaFactory
(
&
announced
.
GroupMetaFactoryArgs
{
GroupName
:
example
.
GroupName
,
VersionPreferenceOrder
:
[]
string
{
examplev1
.
SchemeGroupVersion
.
Version
},
ImportPrefix
:
"k8s.io/apiserver/pkg/apis/example"
,
AddInternalObjectsToScheme
:
example
.
AddToScheme
,
},
announced
.
VersionToSchemeFunc
{
examplev1
.
SchemeGroupVersion
.
Version
:
examplev1
.
AddToScheme
,
},
)
.
Announce
(
groupFactoryRegistry
)
.
RegisterAndEnable
(
registry
,
scheme
);
err
!=
nil
{
panic
(
err
)
}
}
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/register.go
0 → 100644
View file @
da4a875e
/*
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
testapigroup
import
(
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
var
(
SchemeBuilder
=
runtime
.
NewSchemeBuilder
(
addKnownTypes
)
AddToScheme
=
SchemeBuilder
.
AddToScheme
)
// GroupName is the group name use in this package
const
GroupName
=
"example.apiserver.k8s.io"
// SchemeGroupVersion is group version used to register these objects
var
SchemeGroupVersion
=
schema
.
GroupVersion
{
Group
:
GroupName
,
Version
:
runtime
.
APIVersionInternal
}
// Kind takes an unqualified kind and returns a Group qualified GroupKind
func
Kind
(
kind
string
)
schema
.
GroupKind
{
return
SchemeGroupVersion
.
WithKind
(
kind
)
.
GroupKind
()
}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func
Resource
(
resource
string
)
schema
.
GroupResource
{
return
SchemeGroupVersion
.
WithResource
(
resource
)
.
GroupResource
()
}
// Adds the list of known types to api.Scheme.
func
addKnownTypes
(
scheme
*
runtime
.
Scheme
)
error
{
scheme
.
AddKnownTypes
(
SchemeGroupVersion
,
&
Carp
{},
)
return
nil
}
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/types.go
0 → 100644
View file @
da4a875e
/*
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
testapigroup
import
(
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
)
type
(
ConditionStatus
string
CarpConditionType
string
CarpPhase
string
RestartPolicy
string
)
// Carp is a collection of containers, used as either input (create, update) or as output (list, get).
type
Carp
struct
{
metav1
.
TypeMeta
// +optional
metav1
.
ObjectMeta
// Spec defines the behavior of a pod.
// +optional
Spec
CarpSpec
// Status represents the current information about a pod. This data may not be up
// to date.
// +optional
Status
CarpStatus
}
// CarpStatus represents information about the status of a pod. Status may trail the actual
// state of a system.
type
CarpStatus
struct
{
// +optional
Phase
CarpPhase
// +optional
Conditions
[]
CarpCondition
// A human readable message indicating details about why the pod is in this state.
// +optional
Message
string
// A brief CamelCase message indicating details about why the pod is in this state. e.g. 'OutOfDisk'
// +optional
Reason
string
// +optional
HostIP
string
// +optional
CarpIP
string
// Date and time at which the object was acknowledged by the Kubelet.
// This is before the Kubelet pulled the container image(s) for the pod.
// +optional
StartTime
*
metav1
.
Time
}
type
CarpCondition
struct
{
Type
CarpConditionType
Status
ConditionStatus
// +optional
LastProbeTime
metav1
.
Time
// +optional
LastTransitionTime
metav1
.
Time
// +optional
Reason
string
// +optional
Message
string
}
// CarpSpec is a description of a pod
type
CarpSpec
struct
{
// +optional
RestartPolicy
RestartPolicy
// Optional duration in seconds the pod needs to terminate gracefully. May be decreased in delete request.
// Value must be non-negative integer. The value zero indicates delete immediately.
// If this value is nil, the default grace period will be used instead.
// The grace period is the duration in seconds after the processes running in the pod are sent
// a termination signal and the time when the processes are forcibly halted with a kill signal.
// Set this value longer than the expected cleanup time for your process.
// +optional
TerminationGracePeriodSeconds
*
int64
// Optional duration in seconds relative to the StartTime that the pod may be active on a node
// before the system actively tries to terminate the pod; value must be positive integer
// +optional
ActiveDeadlineSeconds
*
int64
// NodeSelector is a selector which must be true for the pod to fit on a node
// +optional
NodeSelector
map
[
string
]
string
// ServiceAccountName is the name of the ServiceAccount to use to run this pod
// The pod will be allowed to use secrets referenced by the ServiceAccount
ServiceAccountName
string
// NodeName is a request to schedule this pod onto a specific node. If it is non-empty,
// the scheduler simply schedules this pod onto that node, assuming that it fits resource
// requirements.
// +optional
NodeName
string
// Specifies the hostname of the Carp.
// If not specified, the pod's hostname will be set to a system-defined value.
// +optional
Hostname
string
// If specified, the fully qualified Carp hostname will be "<hostname>.<subdomain>.<pod namespace>.svc.<cluster domain>".
// If not specified, the pod will not have a domainname at all.
// +optional
Subdomain
string
// If specified, the pod will be dispatched by specified scheduler.
// If not specified, the pod will be dispatched by default scheduler.
// +optional
SchedulerName
string
}
// CarpList is a list of Carps.
type
CarpList
struct
{
metav1
.
TypeMeta
// +optional
metav1
.
ListMeta
Items
[]
Carp
}
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/v1/BUILD
0 → 100644
View file @
da4a875e
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"conversion.go",
"defaults.go",
"doc.go",
"generated.pb.go",
"register.go",
"types.generated.go",
"types.go",
"types_swagger_doc_generated.go",
"zz_generated.conversion.go",
"zz_generated.deepcopy.go",
"zz_generated.defaults.go",
],
tags = ["automanaged"],
deps = [
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
"//vendor/github.com/gogo/protobuf/sortkeys:go_default_library",
"//vendor/github.com/ugorji/go/codec:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
],
)
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/v1/conversion.go
0 → 100644
View file @
da4a875e
/*
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
v1
import
(
"k8s.io/apimachinery/pkg/runtime"
)
func
addConversionFuncs
(
scheme
*
runtime
.
Scheme
)
error
{
// Add non-generated conversion functions here. Currently there are none.
return
nil
}
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/v1/defaults.go
0 → 100644
View file @
da4a875e
/*
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
v1
import
(
"k8s.io/apimachinery/pkg/runtime"
)
func
addDefaultingFuncs
(
scheme
*
runtime
.
Scheme
)
error
{
// return RegisterDefaults(scheme)
return
nil
}
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/v1/doc.go
0 → 100644
View file @
da4a875e
/*
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.
*/
// +k8s:deepcopy-gen=package,register
// +k8s:conversion-gen=k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/apis/example
// +k8s:openapi-gen=false
// +k8s:defaulter-gen=TypeMeta
// +groupName=example.apiserver.k8s.io
package
v1
// import "k8s.io/apiserver/pkg/apis/example/v1"
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/v1/generated.pb.go
0 → 100644
View file @
da4a875e
This diff is collapsed.
Click to expand it.
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/v1/generated.proto
0 → 100644
View file @
da4a875e
/*
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.
*/
// This file was autogenerated by go-to-protobuf. Do not edit it manually!
syntax
=
'proto2'
;
package
k8s
.
io.apiserver.pkg.apis.example.v1
;
import
"k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto"
;
import
"k8s.io/apimachinery/pkg/runtime/generated.proto"
;
import
"k8s.io/apimachinery/pkg/runtime/schema/generated.proto"
;
import
"k8s.io/apimachinery/pkg/util/intstr/generated.proto"
;
// Package-wide variables from generator "generated".
option
go_package
=
"v1"
;
// Carp is a collection of containers, used as either input (create, update) or as output (list, get).
message
Carp
{
// Standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
// +optional
optional
k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta
metadata
=
1
;
// Specification of the desired behavior of the pod.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
// +optional
optional
CarpSpec
spec
=
2
;
// Most recently observed status of the pod.
// This data may not be up to date.
// Populated by the system.
// Read-only.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
// +optional
optional
CarpStatus
status
=
3
;
}
message
CarpCondition
{
// Type is the type of the condition.
// Currently only Ready.
// More info: http://kubernetes.io/docs/user-guide/pod-states#pod-conditions
optional
string
type
=
1
;
// Status is the status of the condition.
// Can be True, False, Unknown.
// More info: http://kubernetes.io/docs/user-guide/pod-states#pod-conditions
optional
string
status
=
2
;
// Last time we probed the condition.
// +optional
optional
k8s.io.apimachinery.pkg.apis.meta.v1.Time
lastProbeTime
=
3
;
// Last time the condition transitioned from one status to another.
// +optional
optional
k8s.io.apimachinery.pkg.apis.meta.v1.Time
lastTransitionTime
=
4
;
// Unique, one-word, CamelCase reason for the condition's last transition.
// +optional
optional
string
reason
=
5
;
// Human-readable message indicating details about last transition.
// +optional
optional
string
message
=
6
;
}
// CarpList is a list of Carps.
message
CarpList
{
// Standard list metadata.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds
// +optional
optional
k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta
metadata
=
1
;
// List of pods.
// More info: http://kubernetes.io/docs/user-guide/pods
repeated
Carp
items
=
2
;
}
// CarpSpec is a description of a pod
message
CarpSpec
{
// Restart policy for all containers within the pod.
// One of Always, OnFailure, Never.
// Default to Always.
// More info: http://kubernetes.io/docs/user-guide/pod-states#restartpolicy
// +optional
optional
string
restartPolicy
=
3
;
// Optional duration in seconds the pod needs to terminate gracefully. May be decreased in delete request.
// Value must be non-negative integer. The value zero indicates delete immediately.
// If this value is nil, the default grace period will be used instead.
// The grace period is the duration in seconds after the processes running in the pod are sent
// a termination signal and the time when the processes are forcibly halted with a kill signal.
// Set this value longer than the expected cleanup time for your process.
// Defaults to 30 seconds.
// +optional
optional
int64
terminationGracePeriodSeconds
=
4
;
// Optional duration in seconds the pod may be active on the node relative to
// StartTime before the system will actively try to mark it failed and kill associated containers.
// Value must be a positive integer.
// +optional
optional
int64
activeDeadlineSeconds
=
5
;
// NodeSelector is a selector which must be true for the pod to fit on a node.
// Selector which must match a node's labels for the pod to be scheduled on that node.
// More info: http://kubernetes.io/docs/user-guide/node-selection/README
// +optional
map
<
string
,
string
>
nodeSelector
=
7
;
// ServiceAccountName is the name of the ServiceAccount to use to run this pod.
// More info: http://releases.k8s.io/HEAD/docs/design/service_accounts.md
// +optional
optional
string
serviceAccountName
=
8
;
// DeprecatedServiceAccount is a depreciated alias for ServiceAccountName.
// Deprecated: Use serviceAccountName instead.
// +k8s:conversion-gen=false
// +optional
optional
string
serviceAccount
=
9
;
// NodeName is a request to schedule this pod onto a specific node. If it is non-empty,
// the scheduler simply schedules this pod onto that node, assuming that it fits resource
// requirements.
// +optional
optional
string
nodeName
=
10
;
// Host networking requested for this pod. Use the host's network namespace.
// If this option is set, the ports that will be used must be specified.
// Default to false.
// +k8s:conversion-gen=false
// +optional
optional
bool
hostNetwork
=
11
;
// Use the host's pid namespace.
// Optional: Default to false.
// +k8s:conversion-gen=false
// +optional
optional
bool
hostPID
=
12
;
// Use the host's ipc namespace.
// Optional: Default to false.
// +k8s:conversion-gen=false
// +optional
optional
bool
hostIPC
=
13
;
// Specifies the hostname of the Carp
// If not specified, the pod's hostname will be set to a system-defined value.
// +optional
optional
string
hostname
=
16
;
// If specified, the fully qualified Carp hostname will be "<hostname>.<subdomain>.<pod namespace>.svc.<cluster domain>".
// If not specified, the pod will not have a domainname at all.
// +optional
optional
string
subdomain
=
17
;
// If specified, the pod will be dispatched by specified scheduler.
// If not specified, the pod will be dispatched by default scheduler.
// +optional
optional
string
schedulername
=
19
;
}
// CarpStatus represents information about the status of a pod. Status may trail the actual
// state of a system.
message
CarpStatus
{
// Current condition of the pod.
// More info: http://kubernetes.io/docs/user-guide/pod-states#pod-phase
// +optional
optional
string
phase
=
1
;
// Current service state of pod.
// More info: http://kubernetes.io/docs/user-guide/pod-states#pod-conditions
// +optional
repeated
CarpCondition
conditions
=
2
;
// A human readable message indicating details about why the pod is in this condition.
// +optional
optional
string
message
=
3
;
// A brief CamelCase message indicating details about why the pod is in this state.
// e.g. 'OutOfDisk'
// +optional
optional
string
reason
=
4
;
// IP address of the host to which the pod is assigned. Empty if not yet scheduled.
// +optional
optional
string
hostIP
=
5
;
// IP address allocated to the pod. Routable at least within the cluster.
// Empty if not yet allocated.
// +optional
optional
string
podIP
=
6
;
// RFC 3339 date and time at which the object was acknowledged by the Kubelet.
// This is before the Kubelet pulled the container image(s) for the pod.
// +optional
optional
k8s.io.apimachinery.pkg.apis.meta.v1.Time
startTime
=
7
;
}
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/v1/register.go
0 → 100644
View file @
da4a875e
/*
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
v1
import
(
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// GroupName is the group name use in this package
const
GroupName
=
"example.apiserver.k8s.io"
// SchemeGroupVersion is group version used to register these objects
var
SchemeGroupVersion
=
schema
.
GroupVersion
{
Group
:
GroupName
,
Version
:
"v1"
}
// Kind takes an unqualified kind and returns a Group qualified GroupKind
func
Kind
(
kind
string
)
schema
.
GroupKind
{
return
SchemeGroupVersion
.
WithKind
(
kind
)
.
GroupKind
()
}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func
Resource
(
resource
string
)
schema
.
GroupResource
{
return
SchemeGroupVersion
.
WithResource
(
resource
)
.
GroupResource
()
}
var
(
// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api.
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
SchemeBuilder
runtime
.
SchemeBuilder
localSchemeBuilder
=
&
SchemeBuilder
AddToScheme
=
localSchemeBuilder
.
AddToScheme
)
func
init
()
{
// We only register manually written functions here. The registration of the
// generated functions takes place in the generated files. The separation
// makes the code compile even when the generated files are missing.
localSchemeBuilder
.
Register
(
addKnownTypes
,
addConversionFuncs
,
addDefaultingFuncs
)
}
// Adds the list of known types to api.Scheme.
func
addKnownTypes
(
scheme
*
runtime
.
Scheme
)
error
{
scheme
.
AddKnownTypes
(
SchemeGroupVersion
,
&
Carp
{},
)
metav1
.
AddToGroupVersion
(
scheme
,
SchemeGroupVersion
)
return
nil
}
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/v1/types.generated.go
0 → 100644
View file @
da4a875e
This diff is collapsed.
Click to expand it.
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/v1/types.go
0 → 100644
View file @
da4a875e
/*
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
v1
import
(
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
)
type
(
ConditionStatus
string
CarpConditionType
string
CarpPhase
string
RestartPolicy
string
)
// Carp is a collection of containers, used as either input (create, update) or as output (list, get).
type
Carp
struct
{
metav1
.
TypeMeta
`json:",inline"`
// Standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
// +optional
metav1
.
ObjectMeta
`json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Specification of the desired behavior of the pod.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
// +optional
Spec
CarpSpec
`json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
// Most recently observed status of the pod.
// This data may not be up to date.
// Populated by the system.
// Read-only.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
// +optional
Status
CarpStatus
`json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
}
// CarpStatus represents information about the status of a pod. Status may trail the actual
// state of a system.
type
CarpStatus
struct
{
// Current condition of the pod.
// More info: http://kubernetes.io/docs/user-guide/pod-states#pod-phase
// +optional
Phase
CarpPhase
`json:"phase,omitempty" protobuf:"bytes,1,opt,name=phase,casttype=CarpPhase"`
// Current service state of pod.
// More info: http://kubernetes.io/docs/user-guide/pod-states#pod-conditions
// +optional
Conditions
[]
CarpCondition
`json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,2,rep,name=conditions"`
// A human readable message indicating details about why the pod is in this condition.
// +optional
Message
string
`json:"message,omitempty" protobuf:"bytes,3,opt,name=message"`
// A brief CamelCase message indicating details about why the pod is in this state.
// e.g. 'OutOfDisk'
// +optional
Reason
string
`json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"`
// IP address of the host to which the pod is assigned. Empty if not yet scheduled.
// +optional
HostIP
string
`json:"hostIP,omitempty" protobuf:"bytes,5,opt,name=hostIP"`
// IP address allocated to the pod. Routable at least within the cluster.
// Empty if not yet allocated.
// +optional
CarpIP
string
`json:"podIP,omitempty" protobuf:"bytes,6,opt,name=podIP"`
// RFC 3339 date and time at which the object was acknowledged by the Kubelet.
// This is before the Kubelet pulled the container image(s) for the pod.
// +optional
StartTime
*
metav1
.
Time
`json:"startTime,omitempty" protobuf:"bytes,7,opt,name=startTime"`
}
type
CarpCondition
struct
{
// Type is the type of the condition.
// Currently only Ready.
// More info: http://kubernetes.io/docs/user-guide/pod-states#pod-conditions
Type
CarpConditionType
`json:"type" protobuf:"bytes,1,opt,name=type,casttype=CarpConditionType"`
// Status is the status of the condition.
// Can be True, False, Unknown.
// More info: http://kubernetes.io/docs/user-guide/pod-states#pod-conditions
Status
ConditionStatus
`json:"status" protobuf:"bytes,2,opt,name=status,casttype=ConditionStatus"`
// Last time we probed the condition.
// +optional
LastProbeTime
metav1
.
Time
`json:"lastProbeTime,omitempty" protobuf:"bytes,3,opt,name=lastProbeTime"`
// Last time the condition transitioned from one status to another.
// +optional
LastTransitionTime
metav1
.
Time
`json:"lastTransitionTime,omitempty" protobuf:"bytes,4,opt,name=lastTransitionTime"`
// Unique, one-word, CamelCase reason for the condition's last transition.
// +optional
Reason
string
`json:"reason,omitempty" protobuf:"bytes,5,opt,name=reason"`
// Human-readable message indicating details about last transition.
// +optional
Message
string
`json:"message,omitempty" protobuf:"bytes,6,opt,name=message"`
}
// CarpSpec is a description of a pod
type
CarpSpec
struct
{
// Restart policy for all containers within the pod.
// One of Always, OnFailure, Never.
// Default to Always.
// More info: http://kubernetes.io/docs/user-guide/pod-states#restartpolicy
// +optional
RestartPolicy
RestartPolicy
`json:"restartPolicy,omitempty" protobuf:"bytes,3,opt,name=restartPolicy,casttype=RestartPolicy"`
// Optional duration in seconds the pod needs to terminate gracefully. May be decreased in delete request.
// Value must be non-negative integer. The value zero indicates delete immediately.
// If this value is nil, the default grace period will be used instead.
// The grace period is the duration in seconds after the processes running in the pod are sent
// a termination signal and the time when the processes are forcibly halted with a kill signal.
// Set this value longer than the expected cleanup time for your process.
// Defaults to 30 seconds.
// +optional
TerminationGracePeriodSeconds
*
int64
`json:"terminationGracePeriodSeconds,omitempty" protobuf:"varint,4,opt,name=terminationGracePeriodSeconds"`
// Optional duration in seconds the pod may be active on the node relative to
// StartTime before the system will actively try to mark it failed and kill associated containers.
// Value must be a positive integer.
// +optional
ActiveDeadlineSeconds
*
int64
`json:"activeDeadlineSeconds,omitempty" protobuf:"varint,5,opt,name=activeDeadlineSeconds"`
// NodeSelector is a selector which must be true for the pod to fit on a node.
// Selector which must match a node's labels for the pod to be scheduled on that node.
// More info: http://kubernetes.io/docs/user-guide/node-selection/README
// +optional
NodeSelector
map
[
string
]
string
`json:"nodeSelector,omitempty" protobuf:"bytes,7,rep,name=nodeSelector"`
// ServiceAccountName is the name of the ServiceAccount to use to run this pod.
// More info: http://releases.k8s.io/HEAD/docs/design/service_accounts.md
// +optional
ServiceAccountName
string
`json:"serviceAccountName,omitempty" protobuf:"bytes,8,opt,name=serviceAccountName"`
// DeprecatedServiceAccount is a depreciated alias for ServiceAccountName.
// Deprecated: Use serviceAccountName instead.
// +k8s:conversion-gen=false
// +optional
DeprecatedServiceAccount
string
`json:"serviceAccount,omitempty" protobuf:"bytes,9,opt,name=serviceAccount"`
// NodeName is a request to schedule this pod onto a specific node. If it is non-empty,
// the scheduler simply schedules this pod onto that node, assuming that it fits resource
// requirements.
// +optional
NodeName
string
`json:"nodeName,omitempty" protobuf:"bytes,10,opt,name=nodeName"`
// Host networking requested for this pod. Use the host's network namespace.
// If this option is set, the ports that will be used must be specified.
// Default to false.
// +k8s:conversion-gen=false
// +optional
HostNetwork
bool
`json:"hostNetwork,omitempty" protobuf:"varint,11,opt,name=hostNetwork"`
// Use the host's pid namespace.
// Optional: Default to false.
// +k8s:conversion-gen=false
// +optional
HostPID
bool
`json:"hostPID,omitempty" protobuf:"varint,12,opt,name=hostPID"`
// Use the host's ipc namespace.
// Optional: Default to false.
// +k8s:conversion-gen=false
// +optional
HostIPC
bool
`json:"hostIPC,omitempty" protobuf:"varint,13,opt,name=hostIPC"`
// Specifies the hostname of the Carp
// If not specified, the pod's hostname will be set to a system-defined value.
// +optional
Hostname
string
`json:"hostname,omitempty" protobuf:"bytes,16,opt,name=hostname"`
// If specified, the fully qualified Carp hostname will be "<hostname>.<subdomain>.<pod namespace>.svc.<cluster domain>".
// If not specified, the pod will not have a domainname at all.
// +optional
Subdomain
string
`json:"subdomain,omitempty" protobuf:"bytes,17,opt,name=subdomain"`
// If specified, the pod will be dispatched by specified scheduler.
// If not specified, the pod will be dispatched by default scheduler.
// +optional
SchedulerName
string
`json:"schedulername,omitempty" protobuf:"bytes,19,opt,name=schedulername"`
}
// CarpList is a list of Carps.
type
CarpList
struct
{
metav1
.
TypeMeta
`json:",inline"`
// Standard list metadata.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds
// +optional
metav1
.
ListMeta
`json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// List of pods.
// More info: http://kubernetes.io/docs/user-guide/pods
Items
[]
Carp
`json:"items" protobuf:"bytes,2,rep,name=items"`
}
pkg/apimachinery/tests/doc
.go
→
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/v1/types_swagger_doc_generated
.go
View file @
da4a875e
/*
/*
Copyright 201
7
The Kubernetes Authors.
Copyright 201
6
The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
you may not use this file except in compliance with the License.
...
@@ -14,7 +14,4 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,4 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
// This package runs tests against the apimachinery which require a Scheme
package
v1
// TODO Refactor the base types into the machinery and move these tests back.
// See https://github.com/kubernetes/kubernetes/issues/39611
package
tests
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/v1/zz_generated.conversion.go
0 → 100644
View file @
da4a875e
// +build !ignore_autogenerated
/*
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.
*/
// This file was autogenerated by conversion-gen. Do not edit it manually!
package
v1
import
(
runtime
"k8s.io/apimachinery/pkg/runtime"
)
func
init
()
{
localSchemeBuilder
.
Register
(
RegisterConversions
)
}
// RegisterConversions adds conversion functions to the given scheme.
// Public to allow building arbitrary schemes.
func
RegisterConversions
(
scheme
*
runtime
.
Scheme
)
error
{
return
scheme
.
AddGeneratedConversionFuncs
()
}
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/v1/zz_generated.deepcopy.go
0 → 100644
View file @
da4a875e
// +build !ignore_autogenerated
/*
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.
*/
// This file was autogenerated by deepcopy-gen. Do not edit it manually!
package
v1
import
(
meta_v1
"k8s.io/apimachinery/pkg/apis/meta/v1"
conversion
"k8s.io/apimachinery/pkg/conversion"
runtime
"k8s.io/apimachinery/pkg/runtime"
reflect
"reflect"
)
func
init
()
{
SchemeBuilder
.
Register
(
RegisterDeepCopies
)
}
// RegisterDeepCopies adds deep-copy functions to the given scheme. Public
// to allow building arbitrary schemes.
func
RegisterDeepCopies
(
scheme
*
runtime
.
Scheme
)
error
{
return
scheme
.
AddGeneratedDeepCopyFuncs
(
conversion
.
GeneratedDeepCopyFunc
{
Fn
:
DeepCopy_v1_Carp
,
InType
:
reflect
.
TypeOf
(
&
Carp
{})},
conversion
.
GeneratedDeepCopyFunc
{
Fn
:
DeepCopy_v1_CarpCondition
,
InType
:
reflect
.
TypeOf
(
&
CarpCondition
{})},
conversion
.
GeneratedDeepCopyFunc
{
Fn
:
DeepCopy_v1_CarpList
,
InType
:
reflect
.
TypeOf
(
&
CarpList
{})},
conversion
.
GeneratedDeepCopyFunc
{
Fn
:
DeepCopy_v1_CarpSpec
,
InType
:
reflect
.
TypeOf
(
&
CarpSpec
{})},
conversion
.
GeneratedDeepCopyFunc
{
Fn
:
DeepCopy_v1_CarpStatus
,
InType
:
reflect
.
TypeOf
(
&
CarpStatus
{})},
)
}
// DeepCopy_v1_Carp is an autogenerated deepcopy function.
func
DeepCopy_v1_Carp
(
in
interface
{},
out
interface
{},
c
*
conversion
.
Cloner
)
error
{
{
in
:=
in
.
(
*
Carp
)
out
:=
out
.
(
*
Carp
)
*
out
=
*
in
if
newVal
,
err
:=
c
.
DeepCopy
(
&
in
.
ObjectMeta
);
err
!=
nil
{
return
err
}
else
{
out
.
ObjectMeta
=
*
newVal
.
(
*
meta_v1
.
ObjectMeta
)
}
if
newVal
,
err
:=
c
.
DeepCopy
(
&
in
.
Spec
);
err
!=
nil
{
return
err
}
else
{
out
.
Spec
=
*
newVal
.
(
*
CarpSpec
)
}
if
newVal
,
err
:=
c
.
DeepCopy
(
&
in
.
Status
);
err
!=
nil
{
return
err
}
else
{
out
.
Status
=
*
newVal
.
(
*
CarpStatus
)
}
return
nil
}
}
// DeepCopy_v1_CarpCondition is an autogenerated deepcopy function.
func
DeepCopy_v1_CarpCondition
(
in
interface
{},
out
interface
{},
c
*
conversion
.
Cloner
)
error
{
{
in
:=
in
.
(
*
CarpCondition
)
out
:=
out
.
(
*
CarpCondition
)
*
out
=
*
in
out
.
LastProbeTime
=
in
.
LastProbeTime
.
DeepCopy
()
out
.
LastTransitionTime
=
in
.
LastTransitionTime
.
DeepCopy
()
return
nil
}
}
// DeepCopy_v1_CarpList is an autogenerated deepcopy function.
func
DeepCopy_v1_CarpList
(
in
interface
{},
out
interface
{},
c
*
conversion
.
Cloner
)
error
{
{
in
:=
in
.
(
*
CarpList
)
out
:=
out
.
(
*
CarpList
)
*
out
=
*
in
if
in
.
Items
!=
nil
{
in
,
out
:=
&
in
.
Items
,
&
out
.
Items
*
out
=
make
([]
Carp
,
len
(
*
in
))
for
i
:=
range
*
in
{
if
newVal
,
err
:=
c
.
DeepCopy
(
&
(
*
in
)[
i
]);
err
!=
nil
{
return
err
}
else
{
(
*
out
)[
i
]
=
*
newVal
.
(
*
Carp
)
}
}
}
return
nil
}
}
// DeepCopy_v1_CarpSpec is an autogenerated deepcopy function.
func
DeepCopy_v1_CarpSpec
(
in
interface
{},
out
interface
{},
c
*
conversion
.
Cloner
)
error
{
{
in
:=
in
.
(
*
CarpSpec
)
out
:=
out
.
(
*
CarpSpec
)
*
out
=
*
in
if
in
.
TerminationGracePeriodSeconds
!=
nil
{
in
,
out
:=
&
in
.
TerminationGracePeriodSeconds
,
&
out
.
TerminationGracePeriodSeconds
*
out
=
new
(
int64
)
**
out
=
**
in
}
if
in
.
ActiveDeadlineSeconds
!=
nil
{
in
,
out
:=
&
in
.
ActiveDeadlineSeconds
,
&
out
.
ActiveDeadlineSeconds
*
out
=
new
(
int64
)
**
out
=
**
in
}
if
in
.
NodeSelector
!=
nil
{
in
,
out
:=
&
in
.
NodeSelector
,
&
out
.
NodeSelector
*
out
=
make
(
map
[
string
]
string
)
for
key
,
val
:=
range
*
in
{
(
*
out
)[
key
]
=
val
}
}
return
nil
}
}
// DeepCopy_v1_CarpStatus is an autogenerated deepcopy function.
func
DeepCopy_v1_CarpStatus
(
in
interface
{},
out
interface
{},
c
*
conversion
.
Cloner
)
error
{
{
in
:=
in
.
(
*
CarpStatus
)
out
:=
out
.
(
*
CarpStatus
)
*
out
=
*
in
if
in
.
Conditions
!=
nil
{
in
,
out
:=
&
in
.
Conditions
,
&
out
.
Conditions
*
out
=
make
([]
CarpCondition
,
len
(
*
in
))
for
i
:=
range
*
in
{
if
newVal
,
err
:=
c
.
DeepCopy
(
&
(
*
in
)[
i
]);
err
!=
nil
{
return
err
}
else
{
(
*
out
)[
i
]
=
*
newVal
.
(
*
CarpCondition
)
}
}
}
if
in
.
StartTime
!=
nil
{
in
,
out
:=
&
in
.
StartTime
,
&
out
.
StartTime
*
out
=
new
(
meta_v1
.
Time
)
**
out
=
(
*
in
)
.
DeepCopy
()
}
return
nil
}
}
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/v1/zz_generated.defaults.go
0 → 100644
View file @
da4a875e
// +build !ignore_autogenerated
/*
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.
*/
// This file was autogenerated by defaulter-gen. Do not edit it manually!
package
v1
import
(
runtime
"k8s.io/apimachinery/pkg/runtime"
)
// RegisterDefaults adds defaulters functions to the given scheme.
// Public to allow building arbitrary schemes.
// All generated defaulters are covering - they call all nested defaulters.
func
RegisterDefaults
(
scheme
*
runtime
.
Scheme
)
error
{
return
nil
}
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/zz_generated.deepcopy.go
0 → 100644
View file @
da4a875e
// +build !ignore_autogenerated
/*
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.
*/
// This file was autogenerated by deepcopy-gen. Do not edit it manually!
package
testapigroup
import
(
v1
"k8s.io/apimachinery/pkg/apis/meta/v1"
conversion
"k8s.io/apimachinery/pkg/conversion"
runtime
"k8s.io/apimachinery/pkg/runtime"
reflect
"reflect"
)
func
init
()
{
SchemeBuilder
.
Register
(
RegisterDeepCopies
)
}
// RegisterDeepCopies adds deep-copy functions to the given scheme. Public
// to allow building arbitrary schemes.
func
RegisterDeepCopies
(
scheme
*
runtime
.
Scheme
)
error
{
return
scheme
.
AddGeneratedDeepCopyFuncs
(
conversion
.
GeneratedDeepCopyFunc
{
Fn
:
DeepCopy_testapigroup_Carp
,
InType
:
reflect
.
TypeOf
(
&
Carp
{})},
conversion
.
GeneratedDeepCopyFunc
{
Fn
:
DeepCopy_testapigroup_CarpCondition
,
InType
:
reflect
.
TypeOf
(
&
CarpCondition
{})},
conversion
.
GeneratedDeepCopyFunc
{
Fn
:
DeepCopy_testapigroup_CarpList
,
InType
:
reflect
.
TypeOf
(
&
CarpList
{})},
conversion
.
GeneratedDeepCopyFunc
{
Fn
:
DeepCopy_testapigroup_CarpSpec
,
InType
:
reflect
.
TypeOf
(
&
CarpSpec
{})},
conversion
.
GeneratedDeepCopyFunc
{
Fn
:
DeepCopy_testapigroup_CarpStatus
,
InType
:
reflect
.
TypeOf
(
&
CarpStatus
{})},
)
}
// DeepCopy_testapigroup_Carp is an autogenerated deepcopy function.
func
DeepCopy_testapigroup_Carp
(
in
interface
{},
out
interface
{},
c
*
conversion
.
Cloner
)
error
{
{
in
:=
in
.
(
*
Carp
)
out
:=
out
.
(
*
Carp
)
*
out
=
*
in
if
newVal
,
err
:=
c
.
DeepCopy
(
&
in
.
ObjectMeta
);
err
!=
nil
{
return
err
}
else
{
out
.
ObjectMeta
=
*
newVal
.
(
*
v1
.
ObjectMeta
)
}
if
newVal
,
err
:=
c
.
DeepCopy
(
&
in
.
Spec
);
err
!=
nil
{
return
err
}
else
{
out
.
Spec
=
*
newVal
.
(
*
CarpSpec
)
}
if
newVal
,
err
:=
c
.
DeepCopy
(
&
in
.
Status
);
err
!=
nil
{
return
err
}
else
{
out
.
Status
=
*
newVal
.
(
*
CarpStatus
)
}
return
nil
}
}
// DeepCopy_testapigroup_CarpCondition is an autogenerated deepcopy function.
func
DeepCopy_testapigroup_CarpCondition
(
in
interface
{},
out
interface
{},
c
*
conversion
.
Cloner
)
error
{
{
in
:=
in
.
(
*
CarpCondition
)
out
:=
out
.
(
*
CarpCondition
)
*
out
=
*
in
out
.
LastProbeTime
=
in
.
LastProbeTime
.
DeepCopy
()
out
.
LastTransitionTime
=
in
.
LastTransitionTime
.
DeepCopy
()
return
nil
}
}
// DeepCopy_testapigroup_CarpList is an autogenerated deepcopy function.
func
DeepCopy_testapigroup_CarpList
(
in
interface
{},
out
interface
{},
c
*
conversion
.
Cloner
)
error
{
{
in
:=
in
.
(
*
CarpList
)
out
:=
out
.
(
*
CarpList
)
*
out
=
*
in
if
in
.
Items
!=
nil
{
in
,
out
:=
&
in
.
Items
,
&
out
.
Items
*
out
=
make
([]
Carp
,
len
(
*
in
))
for
i
:=
range
*
in
{
if
newVal
,
err
:=
c
.
DeepCopy
(
&
(
*
in
)[
i
]);
err
!=
nil
{
return
err
}
else
{
(
*
out
)[
i
]
=
*
newVal
.
(
*
Carp
)
}
}
}
return
nil
}
}
// DeepCopy_testapigroup_CarpSpec is an autogenerated deepcopy function.
func
DeepCopy_testapigroup_CarpSpec
(
in
interface
{},
out
interface
{},
c
*
conversion
.
Cloner
)
error
{
{
in
:=
in
.
(
*
CarpSpec
)
out
:=
out
.
(
*
CarpSpec
)
*
out
=
*
in
if
in
.
TerminationGracePeriodSeconds
!=
nil
{
in
,
out
:=
&
in
.
TerminationGracePeriodSeconds
,
&
out
.
TerminationGracePeriodSeconds
*
out
=
new
(
int64
)
**
out
=
**
in
}
if
in
.
ActiveDeadlineSeconds
!=
nil
{
in
,
out
:=
&
in
.
ActiveDeadlineSeconds
,
&
out
.
ActiveDeadlineSeconds
*
out
=
new
(
int64
)
**
out
=
**
in
}
if
in
.
NodeSelector
!=
nil
{
in
,
out
:=
&
in
.
NodeSelector
,
&
out
.
NodeSelector
*
out
=
make
(
map
[
string
]
string
)
for
key
,
val
:=
range
*
in
{
(
*
out
)[
key
]
=
val
}
}
return
nil
}
}
// DeepCopy_testapigroup_CarpStatus is an autogenerated deepcopy function.
func
DeepCopy_testapigroup_CarpStatus
(
in
interface
{},
out
interface
{},
c
*
conversion
.
Cloner
)
error
{
{
in
:=
in
.
(
*
CarpStatus
)
out
:=
out
.
(
*
CarpStatus
)
*
out
=
*
in
if
in
.
Conditions
!=
nil
{
in
,
out
:=
&
in
.
Conditions
,
&
out
.
Conditions
*
out
=
make
([]
CarpCondition
,
len
(
*
in
))
for
i
:=
range
*
in
{
if
newVal
,
err
:=
c
.
DeepCopy
(
&
(
*
in
)[
i
]);
err
!=
nil
{
return
err
}
else
{
(
*
out
)[
i
]
=
*
newVal
.
(
*
CarpCondition
)
}
}
}
if
in
.
StartTime
!=
nil
{
in
,
out
:=
&
in
.
StartTime
,
&
out
.
StartTime
*
out
=
new
(
v1
.
Time
)
**
out
=
(
*
in
)
.
DeepCopy
()
}
return
nil
}
}
staging/src/k8s.io/apimachinery/pkg/test/BUILD
0 → 100644
View file @
da4a875e
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
go_test(
name = "go_default_test",
srcs = [
"api_meta_help_test.go",
"api_meta_meta_test.go",
"apis_meta_v1_unstructed_unstructure_test.go",
"runtime_helper_test.go",
"runtime_serializer_protobuf_protobuf_test.go",
"runtime_unversioned_test.go",
],
library = ":go_default_library",
tags = ["automanaged"],
deps = [
"//vendor/github.com/google/gofuzz:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/testing:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/testapigroup:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer/protobuf:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/diff:go_default_library",
],
)
go_library(
name = "go_default_library",
srcs = ["util.go"],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/testapigroup:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/testapigroup/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
],
)
pkg/apimachinery/tests
/api_meta_help_test.go
→
staging/src/k8s.io/apimachinery/pkg/test
/api_meta_help_test.go
View file @
da4a875e
...
@@ -14,22 +14,22 @@ See the License for the specific language governing permissions and
...
@@ -14,22 +14,22 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
test
s
package
test
import
(
import
(
"reflect"
"reflect"
"testing"
"testing"
"github.com/google/gofuzz"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
example
"k8s.io/apimachinery/pkg/apis/testapigroup"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/kubernetes/pkg/api"
"github.com/google/gofuzz"
)
)
func
TestIsList
(
t
*
testing
.
T
)
{
func
TestIsList
(
t
*
testing
.
T
)
{
...
@@ -37,8 +37,8 @@ func TestIsList(t *testing.T) {
...
@@ -37,8 +37,8 @@ func TestIsList(t *testing.T) {
obj
runtime
.
Object
obj
runtime
.
Object
isList
bool
isList
bool
}{
}{
{
&
api
.
Pod
List
{},
true
},
{
&
example
.
Carp
List
{},
true
},
{
&
api
.
Pod
{},
false
},
{
&
example
.
Carp
{},
false
},
}
}
for
_
,
item
:=
range
tests
{
for
_
,
item
:=
range
tests
{
if
e
,
a
:=
item
.
isList
,
meta
.
IsListType
(
item
.
obj
);
e
!=
a
{
if
e
,
a
:=
item
.
isList
,
meta
.
IsListType
(
item
.
obj
);
e
!=
a
{
...
@@ -49,8 +49,8 @@ func TestIsList(t *testing.T) {
...
@@ -49,8 +49,8 @@ func TestIsList(t *testing.T) {
func
TestExtractList
(
t
*
testing
.
T
)
{
func
TestExtractList
(
t
*
testing
.
T
)
{
list1
:=
[]
runtime
.
Object
{
list1
:=
[]
runtime
.
Object
{
&
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"1"
}},
&
example
.
Carp
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"1"
}},
&
api
.
Service
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
&
example
.
Carp
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
}
}
list2
:=
&
v1
.
List
{
list2
:=
&
v1
.
List
{
Items
:
[]
runtime
.
RawExtension
{
Items
:
[]
runtime
.
RawExtension
{
...
@@ -60,13 +60,13 @@ func TestExtractList(t *testing.T) {
...
@@ -60,13 +60,13 @@ func TestExtractList(t *testing.T) {
},
},
}
}
list3
:=
&
fakePtrValueList
{
list3
:=
&
fakePtrValueList
{
Items
:
[]
*
api
.
Pod
{
Items
:
[]
*
example
.
Carp
{
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"1"
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"1"
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
},
},
}
}
list4
:=
&
api
.
Pod
List
{
list4
:=
&
example
.
Carp
List
{
Items
:
[]
api
.
Pod
{
Items
:
[]
example
.
Carp
{
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"1"
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"1"
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"3"
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"3"
}},
...
@@ -86,7 +86,7 @@ func TestExtractList(t *testing.T) {
...
@@ -86,7 +86,7 @@ func TestExtractList(t *testing.T) {
equal
bool
equal
bool
}{
}{
{
{
in
:
&
api
.
List
{},
in
:
&
List
{},
out
:
[]
interface
{}{},
out
:
[]
interface
{}{},
},
},
{
{
...
@@ -98,7 +98,7 @@ func TestExtractList(t *testing.T) {
...
@@ -98,7 +98,7 @@ func TestExtractList(t *testing.T) {
out
:
[]
interface
{}{},
out
:
[]
interface
{}{},
},
},
{
{
in
:
&
api
.
List
{
Items
:
list1
},
in
:
&
List
{
Items
:
list1
},
out
:
[]
interface
{}{
list1
[
0
],
list1
[
1
]},
out
:
[]
interface
{}{
list1
[
0
],
list1
[
1
]},
},
},
{
{
...
@@ -142,8 +142,8 @@ func TestExtractList(t *testing.T) {
...
@@ -142,8 +142,8 @@ func TestExtractList(t *testing.T) {
func
TestEachListItem
(
t
*
testing
.
T
)
{
func
TestEachListItem
(
t
*
testing
.
T
)
{
list1
:=
[]
runtime
.
Object
{
list1
:=
[]
runtime
.
Object
{
&
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"1"
}},
&
example
.
Carp
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"1"
}},
&
api
.
Service
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
&
example
.
Carp
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
}
}
list2
:=
&
v1
.
List
{
list2
:=
&
v1
.
List
{
Items
:
[]
runtime
.
RawExtension
{
Items
:
[]
runtime
.
RawExtension
{
...
@@ -153,13 +153,13 @@ func TestEachListItem(t *testing.T) {
...
@@ -153,13 +153,13 @@ func TestEachListItem(t *testing.T) {
},
},
}
}
list3
:=
&
fakePtrValueList
{
list3
:=
&
fakePtrValueList
{
Items
:
[]
*
api
.
Pod
{
Items
:
[]
*
example
.
Carp
{
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"1"
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"1"
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
},
},
}
}
list4
:=
&
api
.
Pod
List
{
list4
:=
&
example
.
Carp
List
{
Items
:
[]
api
.
Pod
{
Items
:
[]
example
.
Carp
{
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"1"
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"1"
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"3"
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"3"
}},
...
@@ -178,7 +178,7 @@ func TestEachListItem(t *testing.T) {
...
@@ -178,7 +178,7 @@ func TestEachListItem(t *testing.T) {
out
[]
interface
{}
out
[]
interface
{}
}{
}{
{
{
in
:
&
api
.
List
{},
in
:
&
List
{},
out
:
[]
interface
{}{},
out
:
[]
interface
{}{},
},
},
{
{
...
@@ -190,7 +190,7 @@ func TestEachListItem(t *testing.T) {
...
@@ -190,7 +190,7 @@ func TestEachListItem(t *testing.T) {
out
:
[]
interface
{}{},
out
:
[]
interface
{}{},
},
},
{
{
in
:
&
api
.
List
{
Items
:
list1
},
in
:
&
List
{
Items
:
list1
},
out
:
[]
interface
{}{
list1
[
0
],
list1
[
1
]},
out
:
[]
interface
{}{
list1
[
0
],
list1
[
1
]},
},
},
{
{
...
@@ -252,7 +252,7 @@ func TestExtractListOfInterfacePtrs(t *testing.T) {
...
@@ -252,7 +252,7 @@ func TestExtractListOfInterfacePtrs(t *testing.T) {
}
}
type
fakePtrValueList
struct
{
type
fakePtrValueList
struct
{
Items
[]
*
api
.
Pod
Items
[]
*
example
.
Carp
}
}
func
(
obj
fakePtrValueList
)
GetObjectKind
()
schema
.
ObjectKind
{
func
(
obj
fakePtrValueList
)
GetObjectKind
()
schema
.
ObjectKind
{
...
@@ -260,11 +260,11 @@ func (obj fakePtrValueList) GetObjectKind() schema.ObjectKind {
...
@@ -260,11 +260,11 @@ func (obj fakePtrValueList) GetObjectKind() schema.ObjectKind {
}
}
func
TestSetList
(
t
*
testing
.
T
)
{
func
TestSetList
(
t
*
testing
.
T
)
{
pl
:=
&
api
.
Pod
List
{}
pl
:=
&
example
.
Carp
List
{}
list
:=
[]
runtime
.
Object
{
list
:=
[]
runtime
.
Object
{
&
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"1"
}},
&
example
.
Carp
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"1"
}},
&
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
&
example
.
Carp
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
&
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"3"
}},
&
example
.
Carp
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"3"
}},
}
}
err
:=
meta
.
SetList
(
pl
,
list
)
err
:=
meta
.
SetList
(
pl
,
list
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -274,18 +274,18 @@ func TestSetList(t *testing.T) {
...
@@ -274,18 +274,18 @@ func TestSetList(t *testing.T) {
t
.
Fatalf
(
"Expected %v, got %v"
,
e
,
a
)
t
.
Fatalf
(
"Expected %v, got %v"
,
e
,
a
)
}
}
for
i
:=
range
list
{
for
i
:=
range
list
{
if
e
,
a
:=
list
[
i
]
.
(
*
api
.
Pod
)
.
Name
,
pl
.
Items
[
i
]
.
Name
;
e
!=
a
{
if
e
,
a
:=
list
[
i
]
.
(
*
example
.
Carp
)
.
Name
,
pl
.
Items
[
i
]
.
Name
;
e
!=
a
{
t
.
Fatalf
(
"Expected %v, got %v"
,
e
,
a
)
t
.
Fatalf
(
"Expected %v, got %v"
,
e
,
a
)
}
}
}
}
}
}
func
TestSetListToRuntimeObjectArray
(
t
*
testing
.
T
)
{
func
TestSetListToRuntimeObjectArray
(
t
*
testing
.
T
)
{
pl
:=
&
api
.
List
{}
pl
:=
&
List
{}
list
:=
[]
runtime
.
Object
{
list
:=
[]
runtime
.
Object
{
&
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"1"
}},
&
example
.
Carp
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"1"
}},
&
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
&
example
.
Carp
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
&
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"3"
}},
&
example
.
Carp
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"3"
}},
}
}
err
:=
meta
.
SetList
(
pl
,
list
)
err
:=
meta
.
SetList
(
pl
,
list
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -325,7 +325,7 @@ func TestSetListToMatchingType(t *testing.T) {
...
@@ -325,7 +325,7 @@ func TestSetListToMatchingType(t *testing.T) {
func
TestSetExtractListRoundTrip
(
t
*
testing
.
T
)
{
func
TestSetExtractListRoundTrip
(
t
*
testing
.
T
)
{
fuzzer
:=
fuzz
.
New
()
.
NilChance
(
0
)
.
NumElements
(
1
,
5
)
fuzzer
:=
fuzz
.
New
()
.
NilChance
(
0
)
.
NumElements
(
1
,
5
)
for
i
:=
0
;
i
<
5
;
i
++
{
for
i
:=
0
;
i
<
5
;
i
++
{
start
:=
&
api
.
Pod
List
{}
start
:=
&
example
.
Carp
List
{}
fuzzer
.
Fuzz
(
&
start
.
Items
)
fuzzer
.
Fuzz
(
&
start
.
Items
)
list
,
err
:=
meta
.
ExtractList
(
start
)
list
,
err
:=
meta
.
ExtractList
(
start
)
...
@@ -333,7 +333,7 @@ func TestSetExtractListRoundTrip(t *testing.T) {
...
@@ -333,7 +333,7 @@ func TestSetExtractListRoundTrip(t *testing.T) {
t
.
Errorf
(
"Unexpected error %v"
,
err
)
t
.
Errorf
(
"Unexpected error %v"
,
err
)
continue
continue
}
}
got
:=
&
api
.
Pod
List
{}
got
:=
&
example
.
Carp
List
{}
err
=
meta
.
SetList
(
got
,
list
)
err
=
meta
.
SetList
(
got
,
list
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Unexpected error %v"
,
err
)
t
.
Errorf
(
"Unexpected error %v"
,
err
)
...
...
pkg/apimachinery/tests
/api_meta_meta_test.go
→
staging/src/k8s.io/apimachinery/pkg/test
/api_meta_meta_test.go
View file @
da4a875e
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
test
s
package
test
import
(
import
(
"reflect"
"reflect"
...
@@ -24,14 +24,14 @@ import (
...
@@ -24,14 +24,14 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
example
"k8s.io/apimachinery/pkg/apis/testapigroup"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/types"
"k8s.io/kubernetes/pkg/api"
)
)
func
TestAPIObjectMeta
(
t
*
testing
.
T
)
{
func
TestAPIObjectMeta
(
t
*
testing
.
T
)
{
j
:=
&
api
.
Pod
{
j
:=
&
example
.
Carp
{
TypeMeta
:
metav1
.
TypeMeta
{
APIVersion
:
"/a"
,
Kind
:
"b"
},
TypeMeta
:
metav1
.
TypeMeta
{
APIVersion
:
"/a"
,
Kind
:
"b"
},
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Namespace
:
"bar"
,
Namespace
:
"bar"
,
...
@@ -394,7 +394,7 @@ func TestAccessOwnerReferences(t *testing.T) {
...
@@ -394,7 +394,7 @@ func TestAccessOwnerReferences(t *testing.T) {
// BenchmarkAccessorSetFastPath shows the interface fast path
// BenchmarkAccessorSetFastPath shows the interface fast path
func
BenchmarkAccessorSetFastPath
(
b
*
testing
.
B
)
{
func
BenchmarkAccessorSetFastPath
(
b
*
testing
.
B
)
{
obj
:=
&
api
.
Pod
{
obj
:=
&
example
.
Carp
{
TypeMeta
:
metav1
.
TypeMeta
{
APIVersion
:
"/a"
,
Kind
:
"b"
},
TypeMeta
:
metav1
.
TypeMeta
{
APIVersion
:
"/a"
,
Kind
:
"b"
},
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Namespace
:
"bar"
,
Namespace
:
"bar"
,
...
...
pkg/apimachinery/tests
/apis_meta_v1_unstructed_unstructure_test.go
→
staging/src/k8s.io/apimachinery/pkg/test
/apis_meta_v1_unstructed_unstructure_test.go
View file @
da4a875e
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
test
s
package
test
import
(
import
(
"fmt"
"fmt"
...
@@ -24,21 +24,21 @@ import (
...
@@ -24,21 +24,21 @@ import (
"testing"
"testing"
"time"
"time"
apitesting
"k8s.io/apimachinery/pkg/api/testing"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
example
"k8s.io/apimachinery/pkg/apis/testapigroup"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/types"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/validation"
)
)
func
TestDecodeUnstructured
(
t
*
testing
.
T
)
{
func
TestDecodeUnstructured
(
t
*
testing
.
T
)
{
groupVersionString
:=
api
.
Registry
.
GroupOrDie
(
api
.
GroupName
)
.
GroupVersion
.
String
()
groupVersionString
:=
"v1"
rawJson
:=
fmt
.
Sprintf
(
`{"kind":"Pod","apiVersion":"%s","metadata":{"name":"test"}}`
,
groupVersionString
)
rawJson
:=
fmt
.
Sprintf
(
`{"kind":"Pod","apiVersion":"%s","metadata":{"name":"test"}}`
,
groupVersionString
)
pl
:=
&
api
.
List
{
pl
:=
&
List
{
Items
:
[]
runtime
.
Object
{
Items
:
[]
runtime
.
Object
{
&
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"1"
}},
&
example
.
Carp
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"1"
}},
&
runtime
.
Unknown
{
&
runtime
.
Unknown
{
TypeMeta
:
runtime
.
TypeMeta
{
Kind
:
"Pod"
,
APIVersion
:
groupVersionString
},
TypeMeta
:
runtime
.
TypeMeta
{
Kind
:
"Pod"
,
APIVersion
:
groupVersionString
},
Raw
:
[]
byte
(
rawJson
),
Raw
:
[]
byte
(
rawJson
),
...
@@ -449,7 +449,7 @@ func TestDecodeNumbers(t *testing.T) {
...
@@ -449,7 +449,7 @@ func TestDecodeNumbers(t *testing.T) {
// Start with a valid pod
// Start with a valid pod
originalJSON
:=
[]
byte
(
`{
originalJSON
:=
[]
byte
(
`{
"kind":"
Pod
",
"kind":"
Carp
",
"apiVersion":"v1",
"apiVersion":"v1",
"metadata":{"name":"pod","namespace":"foo"},
"metadata":{"name":"pod","namespace":"foo"},
"spec":{
"spec":{
...
@@ -458,21 +458,15 @@ func TestDecodeNumbers(t *testing.T) {
...
@@ -458,21 +458,15 @@ func TestDecodeNumbers(t *testing.T) {
}
}
}`
)
}`
)
pod
:=
&
api
.
Pod
{}
pod
:=
&
example
.
Carp
{}
// Decode with structured codec
_
,
codecs
:=
TestScheme
()
codec
,
err
:=
testapi
.
GetCodecForObject
(
pod
)
codec
:=
apitesting
.
TestCodec
(
codecs
,
schema
.
GroupVersion
{
Group
:
""
,
Version
:
runtime
.
APIVersionInternal
})
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
err
:=
runtime
.
DecodeInto
(
codec
,
originalJSON
,
pod
)
}
err
=
runtime
.
DecodeInto
(
codec
,
originalJSON
,
pod
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
// ensure pod is valid
if
errs
:=
validation
.
ValidatePod
(
pod
);
len
(
errs
)
>
0
{
t
.
Fatalf
(
"pod should be valid: %v"
,
errs
)
}
// Round-trip with unstructured codec
// Round-trip with unstructured codec
unstructuredObj
,
err
:=
runtime
.
Decode
(
unstructured
.
UnstructuredJSONScheme
,
originalJSON
)
unstructuredObj
,
err
:=
runtime
.
Decode
(
unstructured
.
UnstructuredJSONScheme
,
originalJSON
)
...
@@ -495,13 +489,11 @@ func TestDecodeNumbers(t *testing.T) {
...
@@ -495,13 +489,11 @@ func TestDecodeNumbers(t *testing.T) {
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
// ensure pod is still valid
// ensure pod is still valid
pod2
,
ok
:=
obj2
.
(
*
api
.
Pod
)
pod2
,
ok
:=
obj2
.
(
*
example
.
Carp
)
if
!
ok
{
if
!
ok
{
t
.
Fatalf
(
"expected an *api.Pod, got %#v"
,
obj2
)
t
.
Fatalf
(
"expected an *api.Pod, got %#v"
,
obj2
)
}
}
if
errs
:=
validation
.
ValidatePod
(
pod2
);
len
(
errs
)
>
0
{
t
.
Fatalf
(
"pod should be valid: %v"
,
errs
)
}
// ensure round-trip preserved large integers
// ensure round-trip preserved large integers
if
!
reflect
.
DeepEqual
(
pod
,
pod2
)
{
if
!
reflect
.
DeepEqual
(
pod
,
pod2
)
{
t
.
Fatalf
(
"Expected
\n\t
%#v, got
\n\t
%#v"
,
pod
,
pod2
)
t
.
Fatalf
(
"Expected
\n\t
%#v, got
\n\t
%#v"
,
pod
,
pod2
)
...
...
pkg/apimachinery/tests
/runtime_helper_test.go
→
staging/src/k8s.io/apimachinery/pkg/test
/runtime_helper_test.go
View file @
da4a875e
...
@@ -14,32 +14,36 @@ See the License for the specific language governing permissions and
...
@@ -14,32 +14,36 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
test
s
package
test
import
(
import
(
"testing"
"testing"
apitesting
"k8s.io/apimachinery/pkg/api/testing"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
example
"k8s.io/apimachinery/pkg/apis/testapigroup"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
)
)
func
TestDecodeList
(
t
*
testing
.
T
)
{
func
TestDecodeList
(
t
*
testing
.
T
)
{
pl
:=
&
api
.
List
{
pl
:=
List
{
Items
:
[]
runtime
.
Object
{
Items
:
[]
runtime
.
Object
{
&
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"1"
}},
&
example
.
Carp
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"1"
}},
&
runtime
.
Unknown
{
&
runtime
.
Unknown
{
TypeMeta
:
runtime
.
TypeMeta
{
Kind
:
"
Pod"
,
APIVersion
:
api
.
Registry
.
GroupOrDie
(
api
.
GroupName
)
.
GroupVersion
.
String
()
},
TypeMeta
:
runtime
.
TypeMeta
{
Kind
:
"
Carp"
,
APIVersion
:
"v1"
},
Raw
:
[]
byte
(
`{"kind":"
Pod","apiVersion":"`
+
api
.
Registry
.
GroupOrDie
(
api
.
GroupName
)
.
GroupVersion
.
String
()
+
`","metadata":{"name":"test"}}`
),
Raw
:
[]
byte
(
`{"kind":"
Carp","apiVersion":"`
+
"v1"
+
`","metadata":{"name":"test"}}`
),
ContentType
:
runtime
.
ContentTypeJSON
,
ContentType
:
runtime
.
ContentTypeJSON
,
},
},
},
},
}
}
if
errs
:=
runtime
.
DecodeList
(
pl
.
Items
,
testapi
.
Default
.
Codec
());
len
(
errs
)
!=
0
{
_
,
codecs
:=
TestScheme
()
Codec
:=
apitesting
.
TestCodec
(
codecs
,
example
.
SchemeGroupVersion
)
if
errs
:=
runtime
.
DecodeList
(
pl
.
Items
,
Codec
);
len
(
errs
)
!=
0
{
t
.
Fatalf
(
"unexpected error %v"
,
errs
)
t
.
Fatalf
(
"unexpected error %v"
,
errs
)
}
}
if
pod
,
ok
:=
pl
.
Items
[
1
]
.
(
*
api
.
Pod
);
!
ok
||
pod
.
Name
!=
"test"
{
if
pod
,
ok
:=
pl
.
Items
[
1
]
.
(
*
example
.
Carp
);
!
ok
||
pod
.
Name
!=
"test"
{
t
.
Errorf
(
"object not converted: %#v"
,
pl
.
Items
[
1
])
t
.
Errorf
(
"object not converted: %#v"
,
pl
.
Items
[
1
])
}
}
}
}
pkg/apimachinery/tests
/runtime_serializer_protobuf_protobuf_test.go
→
staging/src/k8s.io/apimachinery/pkg/test
/runtime_serializer_protobuf_protobuf_test.go
View file @
da4a875e
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
test
s
package
test
import
(
import
(
"bytes"
"bytes"
...
@@ -31,8 +31,6 @@ import (
...
@@ -31,8 +31,6 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer/protobuf"
"k8s.io/apimachinery/pkg/runtime/serializer/protobuf"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/kubernetes/pkg/api"
_
"k8s.io/kubernetes/pkg/api/install"
)
)
type
testObject
struct
{
type
testObject
struct
{
...
@@ -323,9 +321,11 @@ func TestDecodeObjects(t *testing.T) {
...
@@ -323,9 +321,11 @@ func TestDecodeObjects(t *testing.T) {
data
:
wire1
,
data
:
wire1
,
},
},
}
}
scheme
:=
runtime
.
NewScheme
()
for
i
,
test
:=
range
testCases
{
for
i
,
test
:=
range
testCases
{
s
:=
protobuf
.
NewSerializer
(
api
.
Scheme
,
api
.
Scheme
,
"application/protobuf"
)
scheme
.
AddKnownTypes
(
schema
.
GroupVersion
{
Version
:
"v1"
},
&
v1
.
Pod
{})
v1
.
AddToScheme
(
scheme
)
s
:=
protobuf
.
NewSerializer
(
scheme
,
scheme
,
"application/protobuf"
)
obj
,
err
:=
runtime
.
Decode
(
s
,
test
.
data
)
obj
,
err
:=
runtime
.
Decode
(
s
,
test
.
data
)
switch
{
switch
{
...
...
pkg/apimachinery/tests
/runtime_unversioned_test.go
→
staging/src/k8s.io/apimachinery/pkg/test
/runtime_unversioned_test.go
View file @
da4a875e
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
test
s
package
test
import
(
import
(
"encoding/json"
"encoding/json"
...
@@ -23,11 +23,10 @@ import (
...
@@ -23,11 +23,10 @@ import (
// TODO: Ideally we should create the necessary package structure in e.g.,
// TODO: Ideally we should create the necessary package structure in e.g.,
// pkg/conversion/test/... instead of importing pkg/api here.
// pkg/conversion/test/... instead of importing pkg/api here.
apitesting
"k8s.io/apimachinery/pkg/api/testing"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/kubernetes/pkg/api"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/apis/extensions"
)
)
func
TestV1EncodeDecodeStatus
(
t
*
testing
.
T
)
{
func
TestV1EncodeDecodeStatus
(
t
*
testing
.
T
)
{
...
@@ -38,9 +37,10 @@ func TestV1EncodeDecodeStatus(t *testing.T) {
...
@@ -38,9 +37,10 @@ func TestV1EncodeDecodeStatus(t *testing.T) {
Message
:
""
,
Message
:
""
,
}
}
v1Codec
:=
testapi
.
Default
.
Codec
()
_
,
codecs
:=
TestScheme
()
codec
:=
apitesting
.
TestCodec
(
codecs
,
schema
.
GroupVersion
{
Group
:
""
,
Version
:
runtime
.
APIVersionInternal
})
encoded
,
err
:=
runtime
.
Encode
(
v1C
odec
,
status
)
encoded
,
err
:=
runtime
.
Encode
(
c
odec
,
status
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
...
@@ -54,7 +54,7 @@ func TestV1EncodeDecodeStatus(t *testing.T) {
...
@@ -54,7 +54,7 @@ func TestV1EncodeDecodeStatus(t *testing.T) {
if
typeMeta
.
APIVersion
!=
"v1"
{
if
typeMeta
.
APIVersion
!=
"v1"
{
t
.
Errorf
(
"APIVersion is not set to
\"
v1
\"
. Got %v"
,
string
(
encoded
))
t
.
Errorf
(
"APIVersion is not set to
\"
v1
\"
. Got %v"
,
string
(
encoded
))
}
}
decoded
,
err
:=
runtime
.
Decode
(
v1C
odec
,
encoded
)
decoded
,
err
:=
runtime
.
Decode
(
c
odec
,
encoded
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
...
@@ -72,7 +72,9 @@ func TestExperimentalEncodeDecodeStatus(t *testing.T) {
...
@@ -72,7 +72,9 @@ func TestExperimentalEncodeDecodeStatus(t *testing.T) {
}
}
// TODO: caesarxuchao: use the testapi.Extensions.Codec() once the PR that
// TODO: caesarxuchao: use the testapi.Extensions.Codec() once the PR that
// moves experimental from v1 to v1beta1 got merged.
// moves experimental from v1 to v1beta1 got merged.
expCodec
:=
api
.
Codecs
.
LegacyCodec
(
extensions
.
SchemeGroupVersion
)
_
,
codecs
:=
TestScheme
()
expCodec
:=
apitesting
.
TestCodec
(
codecs
,
schema
.
GroupVersion
{
Group
:
""
,
Version
:
runtime
.
APIVersionInternal
})
encoded
,
err
:=
runtime
.
Encode
(
expCodec
,
status
)
encoded
,
err
:=
runtime
.
Encode
(
expCodec
,
status
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
...
...
staging/src/k8s.io/apimachinery/pkg/test/util.go
0 → 100644
View file @
da4a875e
/*
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
test
import
(
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
example
"k8s.io/apimachinery/pkg/apis/testapigroup"
examplev1
"k8s.io/apimachinery/pkg/apis/testapigroup/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
apiserializer
"k8s.io/apimachinery/pkg/runtime/serializer"
)
// List holds a list of objects, which may not be known by the server.
type
List
struct
{
metav1
.
TypeMeta
// +optional
metav1
.
ListMeta
Items
[]
runtime
.
Object
}
func
TestScheme
()
(
*
runtime
.
Scheme
,
apiserializer
.
CodecFactory
)
{
internalGV
:=
schema
.
GroupVersion
{
Group
:
""
,
Version
:
runtime
.
APIVersionInternal
}
externalGV
:=
schema
.
GroupVersion
{
Group
:
""
,
Version
:
"v1"
}
scheme
:=
runtime
.
NewScheme
()
scheme
.
AddKnownTypes
(
internalGV
,
&
example
.
Carp
{},
&
example
.
CarpList
{},
&
List
{},
)
scheme
.
AddKnownTypes
(
externalGV
,
&
examplev1
.
Carp
{},
&
examplev1
.
CarpList
{},
&
List
{},
)
example
.
AddToScheme
(
scheme
)
examplev1
.
AddToScheme
(
scheme
)
codecs
:=
apiserializer
.
NewCodecFactory
(
scheme
)
return
scheme
,
codecs
}
staging/src/k8s.io/apimachinery/pkg/watch/BUILD
View file @
da4a875e
...
@@ -45,3 +45,14 @@ go_test(
...
@@ -45,3 +45,14 @@ go_test(
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
],
],
)
)
go_test(
name = "go_default_test",
srcs = ["until_test.go"],
library = ":go_default_library",
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
],
)
pkg/apimachinery/tests/watch_
until_test.go
→
staging/src/k8s.io/apimachinery/pkg/watch/
until_test.go
View file @
da4a875e
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
tests
package
watch
import
(
import
(
"errors"
"errors"
...
@@ -22,15 +22,20 @@ import (
...
@@ -22,15 +22,20 @@ import (
"testing"
"testing"
"time"
"time"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/util/wait"
.
"k8s.io/apimachinery/pkg/watch"
"k8s.io/kubernetes/pkg/api"
)
)
type
fakePod
struct
{
name
string
}
func
(
obj
*
fakePod
)
GetObjectKind
()
schema
.
ObjectKind
{
return
schema
.
EmptyObjectKind
}
func
TestUntil
(
t
*
testing
.
T
)
{
func
TestUntil
(
t
*
testing
.
T
)
{
fw
:=
NewFake
()
fw
:=
NewFake
()
go
func
()
{
go
func
()
{
var
obj
*
api
.
Pod
var
obj
*
fake
Pod
fw
.
Add
(
obj
)
fw
.
Add
(
obj
)
fw
.
Modify
(
obj
)
fw
.
Modify
(
obj
)
}()
}()
...
@@ -50,7 +55,7 @@ func TestUntil(t *testing.T) {
...
@@ -50,7 +55,7 @@ func TestUntil(t *testing.T) {
if
lastEvent
.
Type
!=
Modified
{
if
lastEvent
.
Type
!=
Modified
{
t
.
Fatalf
(
"expected MODIFIED event type, got %v"
,
lastEvent
.
Type
)
t
.
Fatalf
(
"expected MODIFIED event type, got %v"
,
lastEvent
.
Type
)
}
}
if
got
,
isPod
:=
lastEvent
.
Object
.
(
*
api
.
Pod
);
!
isPod
{
if
got
,
isPod
:=
lastEvent
.
Object
.
(
*
fake
Pod
);
!
isPod
{
t
.
Fatalf
(
"expected a pod event, got %#v"
,
got
)
t
.
Fatalf
(
"expected a pod event, got %#v"
,
got
)
}
}
}
}
...
@@ -58,7 +63,7 @@ func TestUntil(t *testing.T) {
...
@@ -58,7 +63,7 @@ func TestUntil(t *testing.T) {
func
TestUntilMultipleConditions
(
t
*
testing
.
T
)
{
func
TestUntilMultipleConditions
(
t
*
testing
.
T
)
{
fw
:=
NewFake
()
fw
:=
NewFake
()
go
func
()
{
go
func
()
{
var
obj
*
api
.
Pod
var
obj
*
fake
Pod
fw
.
Add
(
obj
)
fw
.
Add
(
obj
)
}()
}()
conditions
:=
[]
ConditionFunc
{
conditions
:=
[]
ConditionFunc
{
...
@@ -77,7 +82,7 @@ func TestUntilMultipleConditions(t *testing.T) {
...
@@ -77,7 +82,7 @@ func TestUntilMultipleConditions(t *testing.T) {
if
lastEvent
.
Type
!=
Added
{
if
lastEvent
.
Type
!=
Added
{
t
.
Fatalf
(
"expected MODIFIED event type, got %v"
,
lastEvent
.
Type
)
t
.
Fatalf
(
"expected MODIFIED event type, got %v"
,
lastEvent
.
Type
)
}
}
if
got
,
isPod
:=
lastEvent
.
Object
.
(
*
api
.
Pod
);
!
isPod
{
if
got
,
isPod
:=
lastEvent
.
Object
.
(
*
fake
Pod
);
!
isPod
{
t
.
Fatalf
(
"expected a pod event, got %#v"
,
got
)
t
.
Fatalf
(
"expected a pod event, got %#v"
,
got
)
}
}
}
}
...
@@ -85,7 +90,7 @@ func TestUntilMultipleConditions(t *testing.T) {
...
@@ -85,7 +90,7 @@ func TestUntilMultipleConditions(t *testing.T) {
func
TestUntilMultipleConditionsFail
(
t
*
testing
.
T
)
{
func
TestUntilMultipleConditionsFail
(
t
*
testing
.
T
)
{
fw
:=
NewFake
()
fw
:=
NewFake
()
go
func
()
{
go
func
()
{
var
obj
*
api
.
Pod
var
obj
*
fake
Pod
fw
.
Add
(
obj
)
fw
.
Add
(
obj
)
}()
}()
conditions
:=
[]
ConditionFunc
{
conditions
:=
[]
ConditionFunc
{
...
@@ -105,7 +110,7 @@ func TestUntilMultipleConditionsFail(t *testing.T) {
...
@@ -105,7 +110,7 @@ func TestUntilMultipleConditionsFail(t *testing.T) {
if
lastEvent
.
Type
!=
Added
{
if
lastEvent
.
Type
!=
Added
{
t
.
Fatalf
(
"expected ADDED event type, got %v"
,
lastEvent
.
Type
)
t
.
Fatalf
(
"expected ADDED event type, got %v"
,
lastEvent
.
Type
)
}
}
if
got
,
isPod
:=
lastEvent
.
Object
.
(
*
api
.
Pod
);
!
isPod
{
if
got
,
isPod
:=
lastEvent
.
Object
.
(
*
fake
Pod
);
!
isPod
{
t
.
Fatalf
(
"expected a pod event, got %#v"
,
got
)
t
.
Fatalf
(
"expected a pod event, got %#v"
,
got
)
}
}
}
}
...
@@ -113,7 +118,7 @@ func TestUntilMultipleConditionsFail(t *testing.T) {
...
@@ -113,7 +118,7 @@ func TestUntilMultipleConditionsFail(t *testing.T) {
func
TestUntilTimeout
(
t
*
testing
.
T
)
{
func
TestUntilTimeout
(
t
*
testing
.
T
)
{
fw
:=
NewFake
()
fw
:=
NewFake
()
go
func
()
{
go
func
()
{
var
obj
*
api
.
Pod
var
obj
*
fake
Pod
fw
.
Add
(
obj
)
fw
.
Add
(
obj
)
fw
.
Modify
(
obj
)
fw
.
Modify
(
obj
)
}()
}()
...
@@ -137,7 +142,7 @@ func TestUntilTimeout(t *testing.T) {
...
@@ -137,7 +142,7 @@ func TestUntilTimeout(t *testing.T) {
if
lastEvent
.
Type
!=
Modified
{
if
lastEvent
.
Type
!=
Modified
{
t
.
Fatalf
(
"expected MODIFIED event type, got %v"
,
lastEvent
.
Type
)
t
.
Fatalf
(
"expected MODIFIED event type, got %v"
,
lastEvent
.
Type
)
}
}
if
got
,
isPod
:=
lastEvent
.
Object
.
(
*
api
.
Pod
);
!
isPod
{
if
got
,
isPod
:=
lastEvent
.
Object
.
(
*
fake
Pod
);
!
isPod
{
t
.
Fatalf
(
"expected a pod event, got %#v"
,
got
)
t
.
Fatalf
(
"expected a pod event, got %#v"
,
got
)
}
}
}
}
...
@@ -145,7 +150,7 @@ func TestUntilTimeout(t *testing.T) {
...
@@ -145,7 +150,7 @@ func TestUntilTimeout(t *testing.T) {
func
TestUntilErrorCondition
(
t
*
testing
.
T
)
{
func
TestUntilErrorCondition
(
t
*
testing
.
T
)
{
fw
:=
NewFake
()
fw
:=
NewFake
()
go
func
()
{
go
func
()
{
var
obj
*
api
.
Pod
var
obj
*
fake
Pod
fw
.
Add
(
obj
)
fw
.
Add
(
obj
)
}()
}()
expected
:=
"something bad"
expected
:=
"something bad"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment