mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-13 13:55:41 +00:00
add test resource carp and change name
This commit is contained in:
parent
da4a875ef8
commit
9ac39849b9
@ -15,8 +15,8 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// +k8s:deepcopy-gen=package,register
|
// +k8s:deepcopy-gen=package,register
|
||||||
// +groupName=example.k8s.io
|
// +groupName=testapigroup.apimachinery.k8s.io
|
||||||
//
|
//
|
||||||
// package example contains an example API used to demonstrate how to create api groups. Moreover, this is
|
// package testapigroup contains an testapigroup API used to demonstrate how to create api groups. Moreover, this is
|
||||||
// used within tests.
|
// used within tests.
|
||||||
package testapigroup // import "k8s.io/apiserver/pkg/apis/example"
|
package testapigroup // import "k8s.io/apimachinery/pkg/apis/testapigroup"
|
||||||
|
@ -20,13 +20,13 @@ import (
|
|||||||
"github.com/google/gofuzz"
|
"github.com/google/gofuzz"
|
||||||
|
|
||||||
apitesting "k8s.io/apimachinery/pkg/api/testing"
|
apitesting "k8s.io/apimachinery/pkg/api/testing"
|
||||||
example "k8s.io/apimachinery/pkg/apis/testapigroup"
|
"k8s.io/apimachinery/pkg/apis/testapigroup"
|
||||||
examplev1 "k8s.io/apimachinery/pkg/apis/testapigroup/v1"
|
"k8s.io/apimachinery/pkg/apis/testapigroup/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
||||||
)
|
)
|
||||||
|
|
||||||
// overrideGenericFuncs override some generic fuzzer funcs from k8s.io/apiserver in order to have more realistic
|
// overrideGenericFuncs override some generic fuzzer funcs from k8s.io/apimachinery in order to have more realistic
|
||||||
// values in a Kubernetes context.
|
// values in a Kubernetes context.
|
||||||
func overrideGenericFuncs(t apitesting.TestingCommon, codecs runtimeserializer.CodecFactory) []interface{} {
|
func overrideGenericFuncs(t apitesting.TestingCommon, codecs runtimeserializer.CodecFactory) []interface{} {
|
||||||
return []interface{}{
|
return []interface{}{
|
||||||
@ -39,7 +39,7 @@ func overrideGenericFuncs(t apitesting.TestingCommon, codecs runtimeserializer.C
|
|||||||
ContentType: runtime.ContentTypeJSON,
|
ContentType: runtime.ContentTypeJSON,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
types := []runtime.Object{&example.Carp{}}
|
types := []runtime.Object{&testapigroup.Carp{}}
|
||||||
t := types[c.Rand.Intn(len(types))]
|
t := types[c.Rand.Intn(len(types))]
|
||||||
c.Fuzz(t)
|
c.Fuzz(t)
|
||||||
*j = t
|
*j = t
|
||||||
@ -47,12 +47,12 @@ func overrideGenericFuncs(t apitesting.TestingCommon, codecs runtimeserializer.C
|
|||||||
},
|
},
|
||||||
func(r *runtime.RawExtension, c fuzz.Continue) {
|
func(r *runtime.RawExtension, c fuzz.Continue) {
|
||||||
// Pick an arbitrary type and fuzz it
|
// Pick an arbitrary type and fuzz it
|
||||||
types := []runtime.Object{&example.Carp{}}
|
types := []runtime.Object{&testapigroup.Carp{}}
|
||||||
obj := types[c.Rand.Intn(len(types))]
|
obj := types[c.Rand.Intn(len(types))]
|
||||||
c.Fuzz(obj)
|
c.Fuzz(obj)
|
||||||
|
|
||||||
// Convert the object to raw bytes
|
// Convert the object to raw bytes
|
||||||
bytes, err := runtime.Encode(apitesting.TestCodec(codecs, examplev1.SchemeGroupVersion), obj)
|
bytes, err := runtime.Encode(apitesting.TestCodec(codecs, v1.SchemeGroupVersion), obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failed to encode object: %v", err)
|
t.Errorf("Failed to encode object: %v", err)
|
||||||
return
|
return
|
||||||
@ -64,9 +64,9 @@ func overrideGenericFuncs(t apitesting.TestingCommon, codecs runtimeserializer.C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func exampleFuncs(t apitesting.TestingCommon) []interface{} {
|
func testapigroupFuncs(t apitesting.TestingCommon) []interface{} {
|
||||||
return []interface{}{
|
return []interface{}{
|
||||||
func(s *example.CarpSpec, c fuzz.Continue) {
|
func(s *testapigroup.CarpSpec, c fuzz.Continue) {
|
||||||
c.FuzzNoCustom(s)
|
c.FuzzNoCustom(s)
|
||||||
// has a default value
|
// has a default value
|
||||||
ttl := int64(30)
|
ttl := int64(30)
|
||||||
@ -79,12 +79,12 @@ func exampleFuncs(t apitesting.TestingCommon) []interface{} {
|
|||||||
s.SchedulerName = "default-scheduler"
|
s.SchedulerName = "default-scheduler"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
func(j *example.CarpPhase, c fuzz.Continue) {
|
func(j *testapigroup.CarpPhase, c fuzz.Continue) {
|
||||||
statuses := []example.CarpPhase{"Pending", "Running", "Succeeded", "Failed", "Unknown"}
|
statuses := []testapigroup.CarpPhase{"Pending", "Running", "Succeeded", "Failed", "Unknown"}
|
||||||
*j = statuses[c.Rand.Intn(len(statuses))]
|
*j = statuses[c.Rand.Intn(len(statuses))]
|
||||||
},
|
},
|
||||||
func(rp *example.RestartPolicy, c fuzz.Continue) {
|
func(rp *testapigroup.RestartPolicy, c fuzz.Continue) {
|
||||||
policies := []example.RestartPolicy{"Always", "Never", "OnFailure"}
|
policies := []testapigroup.RestartPolicy{"Always", "Never", "OnFailure"}
|
||||||
*rp = policies[c.Rand.Intn(len(policies))]
|
*rp = policies[c.Rand.Intn(len(policies))]
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -94,6 +94,6 @@ func Funcs(t apitesting.TestingCommon, codecs runtimeserializer.CodecFactory) []
|
|||||||
return apitesting.MergeFuzzerFuncs(t,
|
return apitesting.MergeFuzzerFuncs(t,
|
||||||
apitesting.GenericFuzzerFuncs(t, codecs),
|
apitesting.GenericFuzzerFuncs(t, codecs),
|
||||||
overrideGenericFuncs(t, codecs),
|
overrideGenericFuncs(t, codecs),
|
||||||
exampleFuncs(t),
|
testapigroupFuncs(t),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,8 @@ package install
|
|||||||
import (
|
import (
|
||||||
"k8s.io/apimachinery/pkg/apimachinery/announced"
|
"k8s.io/apimachinery/pkg/apimachinery/announced"
|
||||||
"k8s.io/apimachinery/pkg/apimachinery/registered"
|
"k8s.io/apimachinery/pkg/apimachinery/registered"
|
||||||
example "k8s.io/apimachinery/pkg/apis/testapigroup"
|
"k8s.io/apimachinery/pkg/apis/testapigroup"
|
||||||
examplev1 "k8s.io/apimachinery/pkg/apis/testapigroup/v1"
|
"k8s.io/apimachinery/pkg/apis/testapigroup/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -30,13 +30,13 @@ import (
|
|||||||
func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) {
|
func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) {
|
||||||
if err := announced.NewGroupMetaFactory(
|
if err := announced.NewGroupMetaFactory(
|
||||||
&announced.GroupMetaFactoryArgs{
|
&announced.GroupMetaFactoryArgs{
|
||||||
GroupName: example.GroupName,
|
GroupName: testapigroup.GroupName,
|
||||||
VersionPreferenceOrder: []string{examplev1.SchemeGroupVersion.Version},
|
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version},
|
||||||
ImportPrefix: "k8s.io/apiserver/pkg/apis/example",
|
ImportPrefix: "k8s.io/apimachinery/pkg/apis/testapigroup",
|
||||||
AddInternalObjectsToScheme: example.AddToScheme,
|
AddInternalObjectsToScheme: testapigroup.AddToScheme,
|
||||||
},
|
},
|
||||||
announced.VersionToSchemeFunc{
|
announced.VersionToSchemeFunc{
|
||||||
examplev1.SchemeGroupVersion.Version: examplev1.AddToScheme,
|
v1.SchemeGroupVersion.Version: v1.AddToScheme,
|
||||||
},
|
},
|
||||||
).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil {
|
).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -27,7 +27,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// GroupName is the group name use in this package
|
// GroupName is the group name use in this package
|
||||||
const GroupName = "example.apiserver.k8s.io"
|
const GroupName = "testapigroup.apimachinery.k8s.io"
|
||||||
|
|
||||||
// SchemeGroupVersion is group version used to register these objects
|
// SchemeGroupVersion is group version used to register these objects
|
||||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}
|
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}
|
||||||
|
@ -33,27 +33,27 @@ type Carp struct {
|
|||||||
// +optional
|
// +optional
|
||||||
metav1.ObjectMeta
|
metav1.ObjectMeta
|
||||||
|
|
||||||
// Spec defines the behavior of a pod.
|
// Spec defines the behavior of a carp.
|
||||||
// +optional
|
// +optional
|
||||||
Spec CarpSpec
|
Spec CarpSpec
|
||||||
|
|
||||||
// Status represents the current information about a pod. This data may not be up
|
// Status represents the current information about a carp. This data may not be up
|
||||||
// to date.
|
// to date.
|
||||||
// +optional
|
// +optional
|
||||||
Status CarpStatus
|
Status CarpStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
// CarpStatus represents information about the status of a pod. Status may trail the actual
|
// CarpStatus represents information about the status of a carp. Status may trail the actual
|
||||||
// state of a system.
|
// state of a system.
|
||||||
type CarpStatus struct {
|
type CarpStatus struct {
|
||||||
// +optional
|
// +optional
|
||||||
Phase CarpPhase
|
Phase CarpPhase
|
||||||
// +optional
|
// +optional
|
||||||
Conditions []CarpCondition
|
Conditions []CarpCondition
|
||||||
// A human readable message indicating details about why the pod is in this state.
|
// A human readable message indicating details about why the carp is in this state.
|
||||||
// +optional
|
// +optional
|
||||||
Message string
|
Message string
|
||||||
// A brief CamelCase message indicating details about why the pod is in this state. e.g. 'OutOfDisk'
|
// A brief CamelCase message indicating details about why the carp is in this state. e.g. 'OutOfDisk'
|
||||||
// +optional
|
// +optional
|
||||||
Reason string
|
Reason string
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ type CarpStatus struct {
|
|||||||
CarpIP string
|
CarpIP string
|
||||||
|
|
||||||
// Date and time at which the object was acknowledged by the Kubelet.
|
// 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.
|
// This is before the Kubelet pulled the container image(s) for the carp.
|
||||||
// +optional
|
// +optional
|
||||||
StartTime *metav1.Time
|
StartTime *metav1.Time
|
||||||
}
|
}
|
||||||
@ -81,45 +81,45 @@ type CarpCondition struct {
|
|||||||
Message string
|
Message string
|
||||||
}
|
}
|
||||||
|
|
||||||
// CarpSpec is a description of a pod
|
// CarpSpec is a description of a carp
|
||||||
type CarpSpec struct {
|
type CarpSpec struct {
|
||||||
// +optional
|
// +optional
|
||||||
RestartPolicy RestartPolicy
|
RestartPolicy RestartPolicy
|
||||||
// Optional duration in seconds the pod needs to terminate gracefully. May be decreased in delete request.
|
// Optional duration in seconds the carp needs to terminate gracefully. May be decreased in delete request.
|
||||||
// Value must be non-negative integer. The value zero indicates delete immediately.
|
// 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.
|
// 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
|
// The grace period is the duration in seconds after the processes running in the carp are sent
|
||||||
// a termination signal and the time when the processes are forcibly halted with a kill signal.
|
// 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.
|
// Set this value longer than the expected cleanup time for your process.
|
||||||
// +optional
|
// +optional
|
||||||
TerminationGracePeriodSeconds *int64
|
TerminationGracePeriodSeconds *int64
|
||||||
// Optional duration in seconds relative to the StartTime that the pod may be active on a node
|
// Optional duration in seconds relative to the StartTime that the carp may be active on a node
|
||||||
// before the system actively tries to terminate the pod; value must be positive integer
|
// before the system actively tries to terminate the carp; value must be positive integer
|
||||||
// +optional
|
// +optional
|
||||||
ActiveDeadlineSeconds *int64
|
ActiveDeadlineSeconds *int64
|
||||||
// NodeSelector is a selector which must be true for the pod to fit on a node
|
// NodeSelector is a selector which must be true for the carp to fit on a node
|
||||||
// +optional
|
// +optional
|
||||||
NodeSelector map[string]string
|
NodeSelector map[string]string
|
||||||
|
|
||||||
// ServiceAccountName is the name of the ServiceAccount to use to run this pod
|
// ServiceAccountName is the name of the ServiceAccount to use to run this carp
|
||||||
// The pod will be allowed to use secrets referenced by the ServiceAccount
|
// The carp will be allowed to use secrets referenced by the ServiceAccount
|
||||||
ServiceAccountName string
|
ServiceAccountName string
|
||||||
|
|
||||||
// NodeName is a request to schedule this pod onto a specific node. If it is non-empty,
|
// NodeName is a request to schedule this carp onto a specific node. If it is non-empty,
|
||||||
// the scheduler simply schedules this pod onto that node, assuming that it fits resource
|
// the scheduler simply schedules this carp onto that node, assuming that it fits resource
|
||||||
// requirements.
|
// requirements.
|
||||||
// +optional
|
// +optional
|
||||||
NodeName string
|
NodeName string
|
||||||
// Specifies the hostname of the Carp.
|
// Specifies the hostname of the Carp.
|
||||||
// If not specified, the pod's hostname will be set to a system-defined value.
|
// If not specified, the carp's hostname will be set to a system-defined value.
|
||||||
// +optional
|
// +optional
|
||||||
Hostname string
|
Hostname string
|
||||||
// If specified, the fully qualified Carp hostname will be "<hostname>.<subdomain>.<pod namespace>.svc.<cluster domain>".
|
// If specified, the fully qualified Carp hostname will be "<hostname>.<subdomain>.<carp namespace>.svc.<cluster domain>".
|
||||||
// If not specified, the pod will not have a domainname at all.
|
// If not specified, the carp will not have a domainname at all.
|
||||||
// +optional
|
// +optional
|
||||||
Subdomain string
|
Subdomain string
|
||||||
// If specified, the pod will be dispatched by specified scheduler.
|
// If specified, the carp will be dispatched by specified scheduler.
|
||||||
// If not specified, the pod will be dispatched by default scheduler.
|
// If not specified, the carp will be dispatched by default scheduler.
|
||||||
// +optional
|
// +optional
|
||||||
SchedulerName string
|
SchedulerName string
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ go_library(
|
|||||||
"//vendor/github.com/gogo/protobuf/sortkeys:go_default_library",
|
"//vendor/github.com/gogo/protobuf/sortkeys:go_default_library",
|
||||||
"//vendor/github.com/ugorji/go/codec: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/apis/meta/v1:go_default_library",
|
||||||
|
"//vendor/k8s.io/apimachinery/pkg/apis/testapigroup:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/conversion: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:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||||
|
@ -15,9 +15,9 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// +k8s:deepcopy-gen=package,register
|
// +k8s:deepcopy-gen=package,register
|
||||||
// +k8s:conversion-gen=k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/apis/example
|
// +k8s:conversion-gen=k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/testapigroup
|
||||||
// +k8s:openapi-gen=false
|
// +k8s:openapi-gen=false
|
||||||
// +k8s:defaulter-gen=TypeMeta
|
// +k8s:defaulter-gen=TypeMeta
|
||||||
|
|
||||||
// +groupName=example.apiserver.k8s.io
|
// +groupName=testapigroup.apimachinery.k8s.io
|
||||||
package v1 // import "k8s.io/apiserver/pkg/apis/example/v1"
|
package v1 // import "k8s.io/apimachinery/pkg/apis/testapigroup/v1"
|
||||||
|
@ -15,14 +15,14 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Code generated by protoc-gen-gogo.
|
// Code generated by protoc-gen-gogo.
|
||||||
// source: k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/apis/example/v1/generated.proto
|
// source: k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/testapigroup/v1/generated.proto
|
||||||
// DO NOT EDIT!
|
// DO NOT EDIT!
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Package v1 is a generated protocol buffer package.
|
Package v1 is a generated protocol buffer package.
|
||||||
|
|
||||||
It is generated from these files:
|
It is generated from these files:
|
||||||
k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/apis/example/v1/generated.proto
|
k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/testapigroup/v1/generated.proto
|
||||||
|
|
||||||
It has these top-level messages:
|
It has these top-level messages:
|
||||||
Carp
|
Carp
|
||||||
@ -78,11 +78,11 @@ func (*CarpStatus) ProtoMessage() {}
|
|||||||
func (*CarpStatus) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{4} }
|
func (*CarpStatus) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{4} }
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
proto.RegisterType((*Carp)(nil), "k8s.io.apiserver.pkg.apis.example.v1.Carp")
|
proto.RegisterType((*Carp)(nil), "k8s.io.apimachinery.pkg.apis.testapigroup.v1.Carp")
|
||||||
proto.RegisterType((*CarpCondition)(nil), "k8s.io.apiserver.pkg.apis.example.v1.CarpCondition")
|
proto.RegisterType((*CarpCondition)(nil), "k8s.io.apimachinery.pkg.apis.testapigroup.v1.CarpCondition")
|
||||||
proto.RegisterType((*CarpList)(nil), "k8s.io.apiserver.pkg.apis.example.v1.CarpList")
|
proto.RegisterType((*CarpList)(nil), "k8s.io.apimachinery.pkg.apis.testapigroup.v1.CarpList")
|
||||||
proto.RegisterType((*CarpSpec)(nil), "k8s.io.apiserver.pkg.apis.example.v1.CarpSpec")
|
proto.RegisterType((*CarpSpec)(nil), "k8s.io.apimachinery.pkg.apis.testapigroup.v1.CarpSpec")
|
||||||
proto.RegisterType((*CarpStatus)(nil), "k8s.io.apiserver.pkg.apis.example.v1.CarpStatus")
|
proto.RegisterType((*CarpStatus)(nil), "k8s.io.apimachinery.pkg.apis.testapigroup.v1.CarpStatus")
|
||||||
}
|
}
|
||||||
func (m *Carp) Marshal() (dAtA []byte, err error) {
|
func (m *Carp) Marshal() (dAtA []byte, err error) {
|
||||||
size := m.Size()
|
size := m.Size()
|
||||||
@ -1934,7 +1934,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
proto.RegisterFile("k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/apis/example/v1/generated.proto", fileDescriptorGenerated)
|
proto.RegisterFile("k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/testapigroup/v1/generated.proto", fileDescriptorGenerated)
|
||||||
}
|
}
|
||||||
|
|
||||||
var fileDescriptorGenerated = []byte{
|
var fileDescriptorGenerated = []byte{
|
||||||
|
@ -19,7 +19,7 @@ limitations under the License.
|
|||||||
|
|
||||||
syntax = 'proto2';
|
syntax = 'proto2';
|
||||||
|
|
||||||
package k8s.io.apiserver.pkg.apis.example.v1;
|
package k8s.io.apimachinery.pkg.apis.testapigroup.v1;
|
||||||
|
|
||||||
import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto";
|
import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto";
|
||||||
import "k8s.io/apimachinery/pkg/runtime/generated.proto";
|
import "k8s.io/apimachinery/pkg/runtime/generated.proto";
|
||||||
@ -36,12 +36,12 @@ message Carp {
|
|||||||
// +optional
|
// +optional
|
||||||
optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
|
optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
|
||||||
|
|
||||||
// Specification of the desired behavior of the pod.
|
// Specification of the desired behavior of the carp.
|
||||||
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
|
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
|
||||||
// +optional
|
// +optional
|
||||||
optional CarpSpec spec = 2;
|
optional CarpSpec spec = 2;
|
||||||
|
|
||||||
// Most recently observed status of the pod.
|
// Most recently observed status of the carp.
|
||||||
// This data may not be up to date.
|
// This data may not be up to date.
|
||||||
// Populated by the system.
|
// Populated by the system.
|
||||||
// Read-only.
|
// Read-only.
|
||||||
@ -53,12 +53,12 @@ message Carp {
|
|||||||
message CarpCondition {
|
message CarpCondition {
|
||||||
// Type is the type of the condition.
|
// Type is the type of the condition.
|
||||||
// Currently only Ready.
|
// Currently only Ready.
|
||||||
// More info: http://kubernetes.io/docs/user-guide/pod-states#pod-conditions
|
// More info: http://kubernetes.io/docs/user-guide/carp-states#carp-conditions
|
||||||
optional string type = 1;
|
optional string type = 1;
|
||||||
|
|
||||||
// Status is the status of the condition.
|
// Status is the status of the condition.
|
||||||
// Can be True, False, Unknown.
|
// Can be True, False, Unknown.
|
||||||
// More info: http://kubernetes.io/docs/user-guide/pod-states#pod-conditions
|
// More info: http://kubernetes.io/docs/user-guide/carp-states#carp-conditions
|
||||||
optional string status = 2;
|
optional string status = 2;
|
||||||
|
|
||||||
// Last time we probed the condition.
|
// Last time we probed the condition.
|
||||||
@ -85,43 +85,43 @@ message CarpList {
|
|||||||
// +optional
|
// +optional
|
||||||
optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;
|
optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;
|
||||||
|
|
||||||
// List of pods.
|
// List of carps.
|
||||||
// More info: http://kubernetes.io/docs/user-guide/pods
|
// More info: http://kubernetes.io/docs/user-guide/carps
|
||||||
repeated Carp items = 2;
|
repeated Carp items = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// CarpSpec is a description of a pod
|
// CarpSpec is a description of a carp
|
||||||
message CarpSpec {
|
message CarpSpec {
|
||||||
// Restart policy for all containers within the pod.
|
// Restart policy for all containers within the carp.
|
||||||
// One of Always, OnFailure, Never.
|
// One of Always, OnFailure, Never.
|
||||||
// Default to Always.
|
// Default to Always.
|
||||||
// More info: http://kubernetes.io/docs/user-guide/pod-states#restartpolicy
|
// More info: http://kubernetes.io/docs/user-guide/carp-states#restartpolicy
|
||||||
// +optional
|
// +optional
|
||||||
optional string restartPolicy = 3;
|
optional string restartPolicy = 3;
|
||||||
|
|
||||||
// Optional duration in seconds the pod needs to terminate gracefully. May be decreased in delete request.
|
// Optional duration in seconds the carp needs to terminate gracefully. May be decreased in delete request.
|
||||||
// Value must be non-negative integer. The value zero indicates delete immediately.
|
// 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.
|
// 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
|
// The grace period is the duration in seconds after the processes running in the carp are sent
|
||||||
// a termination signal and the time when the processes are forcibly halted with a kill signal.
|
// 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.
|
// Set this value longer than the expected cleanup time for your process.
|
||||||
// Defaults to 30 seconds.
|
// Defaults to 30 seconds.
|
||||||
// +optional
|
// +optional
|
||||||
optional int64 terminationGracePeriodSeconds = 4;
|
optional int64 terminationGracePeriodSeconds = 4;
|
||||||
|
|
||||||
// Optional duration in seconds the pod may be active on the node relative to
|
// Optional duration in seconds the carp may be active on the node relative to
|
||||||
// StartTime before the system will actively try to mark it failed and kill associated containers.
|
// StartTime before the system will actively try to mark it failed and kill associated containers.
|
||||||
// Value must be a positive integer.
|
// Value must be a positive integer.
|
||||||
// +optional
|
// +optional
|
||||||
optional int64 activeDeadlineSeconds = 5;
|
optional int64 activeDeadlineSeconds = 5;
|
||||||
|
|
||||||
// NodeSelector is a selector which must be true for the pod to fit on a node.
|
// NodeSelector is a selector which must be true for the carp to fit on a node.
|
||||||
// Selector which must match a node's labels for the pod to be scheduled on that node.
|
// Selector which must match a node's labels for the carp to be scheduled on that node.
|
||||||
// More info: http://kubernetes.io/docs/user-guide/node-selection/README
|
// More info: http://kubernetes.io/docs/user-guide/node-selection/README
|
||||||
// +optional
|
// +optional
|
||||||
map<string, string> nodeSelector = 7;
|
map<string, string> nodeSelector = 7;
|
||||||
|
|
||||||
// ServiceAccountName is the name of the ServiceAccount to use to run this pod.
|
// ServiceAccountName is the name of the ServiceAccount to use to run this carp.
|
||||||
// More info: http://releases.k8s.io/HEAD/docs/design/service_accounts.md
|
// More info: http://releases.k8s.io/HEAD/docs/design/service_accounts.md
|
||||||
// +optional
|
// +optional
|
||||||
optional string serviceAccountName = 8;
|
optional string serviceAccountName = 8;
|
||||||
@ -132,13 +132,13 @@ message CarpSpec {
|
|||||||
// +optional
|
// +optional
|
||||||
optional string serviceAccount = 9;
|
optional string serviceAccount = 9;
|
||||||
|
|
||||||
// NodeName is a request to schedule this pod onto a specific node. If it is non-empty,
|
// NodeName is a request to schedule this carp onto a specific node. If it is non-empty,
|
||||||
// the scheduler simply schedules this pod onto that node, assuming that it fits resource
|
// the scheduler simply schedules this carp onto that node, assuming that it fits resource
|
||||||
// requirements.
|
// requirements.
|
||||||
// +optional
|
// +optional
|
||||||
optional string nodeName = 10;
|
optional string nodeName = 10;
|
||||||
|
|
||||||
// Host networking requested for this pod. Use the host's network namespace.
|
// Host networking requested for this carp. Use the host's network namespace.
|
||||||
// If this option is set, the ports that will be used must be specified.
|
// If this option is set, the ports that will be used must be specified.
|
||||||
// Default to false.
|
// Default to false.
|
||||||
// +k8s:conversion-gen=false
|
// +k8s:conversion-gen=false
|
||||||
@ -158,54 +158,54 @@ message CarpSpec {
|
|||||||
optional bool hostIPC = 13;
|
optional bool hostIPC = 13;
|
||||||
|
|
||||||
// Specifies the hostname of the Carp
|
// Specifies the hostname of the Carp
|
||||||
// If not specified, the pod's hostname will be set to a system-defined value.
|
// If not specified, the carp's hostname will be set to a system-defined value.
|
||||||
// +optional
|
// +optional
|
||||||
optional string hostname = 16;
|
optional string hostname = 16;
|
||||||
|
|
||||||
// If specified, the fully qualified Carp hostname will be "<hostname>.<subdomain>.<pod namespace>.svc.<cluster domain>".
|
// If specified, the fully qualified Carp hostname will be "<hostname>.<subdomain>.<carp namespace>.svc.<cluster domain>".
|
||||||
// If not specified, the pod will not have a domainname at all.
|
// If not specified, the carp will not have a domainname at all.
|
||||||
// +optional
|
// +optional
|
||||||
optional string subdomain = 17;
|
optional string subdomain = 17;
|
||||||
|
|
||||||
// If specified, the pod will be dispatched by specified scheduler.
|
// If specified, the carp will be dispatched by specified scheduler.
|
||||||
// If not specified, the pod will be dispatched by default scheduler.
|
// If not specified, the carp will be dispatched by default scheduler.
|
||||||
// +optional
|
// +optional
|
||||||
optional string schedulername = 19;
|
optional string schedulername = 19;
|
||||||
}
|
}
|
||||||
|
|
||||||
// CarpStatus represents information about the status of a pod. Status may trail the actual
|
// CarpStatus represents information about the status of a carp. Status may trail the actual
|
||||||
// state of a system.
|
// state of a system.
|
||||||
message CarpStatus {
|
message CarpStatus {
|
||||||
// Current condition of the pod.
|
// Current condition of the carp.
|
||||||
// More info: http://kubernetes.io/docs/user-guide/pod-states#pod-phase
|
// More info: http://kubernetes.io/docs/user-guide/carp-states#carp-phase
|
||||||
// +optional
|
// +optional
|
||||||
optional string phase = 1;
|
optional string phase = 1;
|
||||||
|
|
||||||
// Current service state of pod.
|
// Current service state of carp.
|
||||||
// More info: http://kubernetes.io/docs/user-guide/pod-states#pod-conditions
|
// More info: http://kubernetes.io/docs/user-guide/carp-states#carp-conditions
|
||||||
// +optional
|
// +optional
|
||||||
repeated CarpCondition conditions = 2;
|
repeated CarpCondition conditions = 2;
|
||||||
|
|
||||||
// A human readable message indicating details about why the pod is in this condition.
|
// A human readable message indicating details about why the carp is in this condition.
|
||||||
// +optional
|
// +optional
|
||||||
optional string message = 3;
|
optional string message = 3;
|
||||||
|
|
||||||
// A brief CamelCase message indicating details about why the pod is in this state.
|
// A brief CamelCase message indicating details about why the carp is in this state.
|
||||||
// e.g. 'OutOfDisk'
|
// e.g. 'OutOfDisk'
|
||||||
// +optional
|
// +optional
|
||||||
optional string reason = 4;
|
optional string reason = 4;
|
||||||
|
|
||||||
// IP address of the host to which the pod is assigned. Empty if not yet scheduled.
|
// IP address of the host to which the carp is assigned. Empty if not yet scheduled.
|
||||||
// +optional
|
// +optional
|
||||||
optional string hostIP = 5;
|
optional string hostIP = 5;
|
||||||
|
|
||||||
// IP address allocated to the pod. Routable at least within the cluster.
|
// IP address allocated to the carp. Routable at least within the cluster.
|
||||||
// Empty if not yet allocated.
|
// Empty if not yet allocated.
|
||||||
// +optional
|
// +optional
|
||||||
optional string podIP = 6;
|
optional string carpIP = 6;
|
||||||
|
|
||||||
// RFC 3339 date and time at which the object was acknowledged by the Kubelet.
|
// 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.
|
// This is before the Kubelet pulled the container image(s) for the carp.
|
||||||
// +optional
|
// +optional
|
||||||
optional k8s.io.apimachinery.pkg.apis.meta.v1.Time startTime = 7;
|
optional k8s.io.apimachinery.pkg.apis.meta.v1.Time startTime = 7;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// GroupName is the group name use in this package
|
// GroupName is the group name use in this package
|
||||||
const GroupName = "example.apiserver.k8s.io"
|
const GroupName = "testapigroup.apimachinery.k8s.io"
|
||||||
|
|
||||||
// SchemeGroupVersion is group version used to register these objects
|
// SchemeGroupVersion is group version used to register these objects
|
||||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"}
|
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"}
|
||||||
|
@ -739,7 +739,7 @@ func (x *CarpStatus) CodecEncodeSelf(e *codec1978.Encoder) {
|
|||||||
} else {
|
} else {
|
||||||
if yyq2[5] {
|
if yyq2[5] {
|
||||||
z.EncSendContainerState(codecSelfer_containerMapKey1234)
|
z.EncSendContainerState(codecSelfer_containerMapKey1234)
|
||||||
r.EncodeString(codecSelferC_UTF81234, string("podIP"))
|
r.EncodeString(codecSelferC_UTF81234, string("carpIP"))
|
||||||
z.EncSendContainerState(codecSelfer_containerMapValue1234)
|
z.EncSendContainerState(codecSelfer_containerMapValue1234)
|
||||||
yym20 := z.EncBinary()
|
yym20 := z.EncBinary()
|
||||||
_ = yym20
|
_ = yym20
|
||||||
@ -908,7 +908,7 @@ func (x *CarpStatus) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
|
|||||||
*((*string)(yyv11)) = r.DecodeString()
|
*((*string)(yyv11)) = r.DecodeString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "podIP":
|
case "carpIP":
|
||||||
if r.TryDecodeAsNil() {
|
if r.TryDecodeAsNil() {
|
||||||
x.CarpIP = ""
|
x.CarpIP = ""
|
||||||
} else {
|
} else {
|
||||||
|
@ -35,12 +35,12 @@ type Carp struct {
|
|||||||
// +optional
|
// +optional
|
||||||
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
||||||
|
|
||||||
// Specification of the desired behavior of the pod.
|
// Specification of the desired behavior of the carp.
|
||||||
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
|
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
|
||||||
// +optional
|
// +optional
|
||||||
Spec CarpSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
|
Spec CarpSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
|
||||||
|
|
||||||
// Most recently observed status of the pod.
|
// Most recently observed status of the carp.
|
||||||
// This data may not be up to date.
|
// This data may not be up to date.
|
||||||
// Populated by the system.
|
// Populated by the system.
|
||||||
// Read-only.
|
// Read-only.
|
||||||
@ -49,35 +49,35 @@ type Carp struct {
|
|||||||
Status CarpStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
|
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
|
// CarpStatus represents information about the status of a carp. Status may trail the actual
|
||||||
// state of a system.
|
// state of a system.
|
||||||
type CarpStatus struct {
|
type CarpStatus struct {
|
||||||
// Current condition of the pod.
|
// Current condition of the carp.
|
||||||
// More info: http://kubernetes.io/docs/user-guide/pod-states#pod-phase
|
// More info: http://kubernetes.io/docs/user-guide/carp-states#carp-phase
|
||||||
// +optional
|
// +optional
|
||||||
Phase CarpPhase `json:"phase,omitempty" protobuf:"bytes,1,opt,name=phase,casttype=CarpPhase"`
|
Phase CarpPhase `json:"phase,omitempty" protobuf:"bytes,1,opt,name=phase,casttype=CarpPhase"`
|
||||||
// Current service state of pod.
|
// Current service state of carp.
|
||||||
// More info: http://kubernetes.io/docs/user-guide/pod-states#pod-conditions
|
// More info: http://kubernetes.io/docs/user-guide/carp-states#carp-conditions
|
||||||
// +optional
|
// +optional
|
||||||
Conditions []CarpCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,2,rep,name=conditions"`
|
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.
|
// A human readable message indicating details about why the carp is in this condition.
|
||||||
// +optional
|
// +optional
|
||||||
Message string `json:"message,omitempty" protobuf:"bytes,3,opt,name=message"`
|
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.
|
// A brief CamelCase message indicating details about why the carp is in this state.
|
||||||
// e.g. 'OutOfDisk'
|
// e.g. 'OutOfDisk'
|
||||||
// +optional
|
// +optional
|
||||||
Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"`
|
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.
|
// IP address of the host to which the carp is assigned. Empty if not yet scheduled.
|
||||||
// +optional
|
// +optional
|
||||||
HostIP string `json:"hostIP,omitempty" protobuf:"bytes,5,opt,name=hostIP"`
|
HostIP string `json:"hostIP,omitempty" protobuf:"bytes,5,opt,name=hostIP"`
|
||||||
// IP address allocated to the pod. Routable at least within the cluster.
|
// IP address allocated to the carp. Routable at least within the cluster.
|
||||||
// Empty if not yet allocated.
|
// Empty if not yet allocated.
|
||||||
// +optional
|
// +optional
|
||||||
CarpIP string `json:"podIP,omitempty" protobuf:"bytes,6,opt,name=podIP"`
|
CarpIP string `json:"carpIP,omitempty" protobuf:"bytes,6,opt,name=carpIP"`
|
||||||
|
|
||||||
// RFC 3339 date and time at which the object was acknowledged by the Kubelet.
|
// 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.
|
// This is before the Kubelet pulled the container image(s) for the carp.
|
||||||
// +optional
|
// +optional
|
||||||
StartTime *metav1.Time `json:"startTime,omitempty" protobuf:"bytes,7,opt,name=startTime"`
|
StartTime *metav1.Time `json:"startTime,omitempty" protobuf:"bytes,7,opt,name=startTime"`
|
||||||
}
|
}
|
||||||
@ -85,11 +85,11 @@ type CarpStatus struct {
|
|||||||
type CarpCondition struct {
|
type CarpCondition struct {
|
||||||
// Type is the type of the condition.
|
// Type is the type of the condition.
|
||||||
// Currently only Ready.
|
// Currently only Ready.
|
||||||
// More info: http://kubernetes.io/docs/user-guide/pod-states#pod-conditions
|
// More info: http://kubernetes.io/docs/user-guide/carp-states#carp-conditions
|
||||||
Type CarpConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=CarpConditionType"`
|
Type CarpConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=CarpConditionType"`
|
||||||
// Status is the status of the condition.
|
// Status is the status of the condition.
|
||||||
// Can be True, False, Unknown.
|
// Can be True, False, Unknown.
|
||||||
// More info: http://kubernetes.io/docs/user-guide/pod-states#pod-conditions
|
// More info: http://kubernetes.io/docs/user-guide/carp-states#carp-conditions
|
||||||
Status ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=ConditionStatus"`
|
Status ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=ConditionStatus"`
|
||||||
// Last time we probed the condition.
|
// Last time we probed the condition.
|
||||||
// +optional
|
// +optional
|
||||||
@ -105,35 +105,35 @@ type CarpCondition struct {
|
|||||||
Message string `json:"message,omitempty" protobuf:"bytes,6,opt,name=message"`
|
Message string `json:"message,omitempty" protobuf:"bytes,6,opt,name=message"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CarpSpec is a description of a pod
|
// CarpSpec is a description of a carp
|
||||||
type CarpSpec struct {
|
type CarpSpec struct {
|
||||||
// Restart policy for all containers within the pod.
|
// Restart policy for all containers within the carp.
|
||||||
// One of Always, OnFailure, Never.
|
// One of Always, OnFailure, Never.
|
||||||
// Default to Always.
|
// Default to Always.
|
||||||
// More info: http://kubernetes.io/docs/user-guide/pod-states#restartpolicy
|
// More info: http://kubernetes.io/docs/user-guide/carp-states#restartpolicy
|
||||||
// +optional
|
// +optional
|
||||||
RestartPolicy RestartPolicy `json:"restartPolicy,omitempty" protobuf:"bytes,3,opt,name=restartPolicy,casttype=RestartPolicy"`
|
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.
|
// Optional duration in seconds the carp needs to terminate gracefully. May be decreased in delete request.
|
||||||
// Value must be non-negative integer. The value zero indicates delete immediately.
|
// 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.
|
// 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
|
// The grace period is the duration in seconds after the processes running in the carp are sent
|
||||||
// a termination signal and the time when the processes are forcibly halted with a kill signal.
|
// 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.
|
// Set this value longer than the expected cleanup time for your process.
|
||||||
// Defaults to 30 seconds.
|
// Defaults to 30 seconds.
|
||||||
// +optional
|
// +optional
|
||||||
TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty" protobuf:"varint,4,opt,name=terminationGracePeriodSeconds"`
|
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
|
// Optional duration in seconds the carp may be active on the node relative to
|
||||||
// StartTime before the system will actively try to mark it failed and kill associated containers.
|
// StartTime before the system will actively try to mark it failed and kill associated containers.
|
||||||
// Value must be a positive integer.
|
// Value must be a positive integer.
|
||||||
// +optional
|
// +optional
|
||||||
ActiveDeadlineSeconds *int64 `json:"activeDeadlineSeconds,omitempty" protobuf:"varint,5,opt,name=activeDeadlineSeconds"`
|
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.
|
// NodeSelector is a selector which must be true for the carp to fit on a node.
|
||||||
// Selector which must match a node's labels for the pod to be scheduled on that node.
|
// Selector which must match a node's labels for the carp to be scheduled on that node.
|
||||||
// More info: http://kubernetes.io/docs/user-guide/node-selection/README
|
// More info: http://kubernetes.io/docs/user-guide/node-selection/README
|
||||||
// +optional
|
// +optional
|
||||||
NodeSelector map[string]string `json:"nodeSelector,omitempty" protobuf:"bytes,7,rep,name=nodeSelector"`
|
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.
|
// ServiceAccountName is the name of the ServiceAccount to use to run this carp.
|
||||||
// More info: http://releases.k8s.io/HEAD/docs/design/service_accounts.md
|
// More info: http://releases.k8s.io/HEAD/docs/design/service_accounts.md
|
||||||
// +optional
|
// +optional
|
||||||
ServiceAccountName string `json:"serviceAccountName,omitempty" protobuf:"bytes,8,opt,name=serviceAccountName"`
|
ServiceAccountName string `json:"serviceAccountName,omitempty" protobuf:"bytes,8,opt,name=serviceAccountName"`
|
||||||
@ -143,12 +143,12 @@ type CarpSpec struct {
|
|||||||
// +optional
|
// +optional
|
||||||
DeprecatedServiceAccount string `json:"serviceAccount,omitempty" protobuf:"bytes,9,opt,name=serviceAccount"`
|
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,
|
// NodeName is a request to schedule this carp onto a specific node. If it is non-empty,
|
||||||
// the scheduler simply schedules this pod onto that node, assuming that it fits resource
|
// the scheduler simply schedules this carp onto that node, assuming that it fits resource
|
||||||
// requirements.
|
// requirements.
|
||||||
// +optional
|
// +optional
|
||||||
NodeName string `json:"nodeName,omitempty" protobuf:"bytes,10,opt,name=nodeName"`
|
NodeName string `json:"nodeName,omitempty" protobuf:"bytes,10,opt,name=nodeName"`
|
||||||
// Host networking requested for this pod. Use the host's network namespace.
|
// Host networking requested for this carp. Use the host's network namespace.
|
||||||
// If this option is set, the ports that will be used must be specified.
|
// If this option is set, the ports that will be used must be specified.
|
||||||
// Default to false.
|
// Default to false.
|
||||||
// +k8s:conversion-gen=false
|
// +k8s:conversion-gen=false
|
||||||
@ -165,15 +165,15 @@ type CarpSpec struct {
|
|||||||
// +optional
|
// +optional
|
||||||
HostIPC bool `json:"hostIPC,omitempty" protobuf:"varint,13,opt,name=hostIPC"`
|
HostIPC bool `json:"hostIPC,omitempty" protobuf:"varint,13,opt,name=hostIPC"`
|
||||||
// Specifies the hostname of the Carp
|
// Specifies the hostname of the Carp
|
||||||
// If not specified, the pod's hostname will be set to a system-defined value.
|
// If not specified, the carp's hostname will be set to a system-defined value.
|
||||||
// +optional
|
// +optional
|
||||||
Hostname string `json:"hostname,omitempty" protobuf:"bytes,16,opt,name=hostname"`
|
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 specified, the fully qualified Carp hostname will be "<hostname>.<subdomain>.<carp namespace>.svc.<cluster domain>".
|
||||||
// If not specified, the pod will not have a domainname at all.
|
// If not specified, the carp will not have a domainname at all.
|
||||||
// +optional
|
// +optional
|
||||||
Subdomain string `json:"subdomain,omitempty" protobuf:"bytes,17,opt,name=subdomain"`
|
Subdomain string `json:"subdomain,omitempty" protobuf:"bytes,17,opt,name=subdomain"`
|
||||||
// If specified, the pod will be dispatched by specified scheduler.
|
// If specified, the carp will be dispatched by specified scheduler.
|
||||||
// If not specified, the pod will be dispatched by default scheduler.
|
// If not specified, the carp will be dispatched by default scheduler.
|
||||||
// +optional
|
// +optional
|
||||||
SchedulerName string `json:"schedulername,omitempty" protobuf:"bytes,19,opt,name=schedulername"`
|
SchedulerName string `json:"schedulername,omitempty" protobuf:"bytes,19,opt,name=schedulername"`
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ type CarpList struct {
|
|||||||
// +optional
|
// +optional
|
||||||
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
||||||
|
|
||||||
// List of pods.
|
// List of carps.
|
||||||
// More info: http://kubernetes.io/docs/user-guide/pods
|
// More info: http://kubernetes.io/docs/user-guide/carps
|
||||||
Items []Carp `json:"items" protobuf:"bytes,2,rep,name=items"`
|
Items []Carp `json:"items" protobuf:"bytes,2,rep,name=items"`
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,11 @@ limitations under the License.
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
testapigroup "k8s.io/apimachinery/pkg/apis/testapigroup"
|
||||||
|
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||||
|
unsafe "unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -31,5 +35,192 @@ func init() {
|
|||||||
// RegisterConversions adds conversion functions to the given scheme.
|
// RegisterConversions adds conversion functions to the given scheme.
|
||||||
// Public to allow building arbitrary schemes.
|
// Public to allow building arbitrary schemes.
|
||||||
func RegisterConversions(scheme *runtime.Scheme) error {
|
func RegisterConversions(scheme *runtime.Scheme) error {
|
||||||
return scheme.AddGeneratedConversionFuncs()
|
return scheme.AddGeneratedConversionFuncs(
|
||||||
|
Convert_v1_Carp_To_testapigroup_Carp,
|
||||||
|
Convert_testapigroup_Carp_To_v1_Carp,
|
||||||
|
Convert_v1_CarpCondition_To_testapigroup_CarpCondition,
|
||||||
|
Convert_testapigroup_CarpCondition_To_v1_CarpCondition,
|
||||||
|
Convert_v1_CarpList_To_testapigroup_CarpList,
|
||||||
|
Convert_testapigroup_CarpList_To_v1_CarpList,
|
||||||
|
Convert_v1_CarpSpec_To_testapigroup_CarpSpec,
|
||||||
|
Convert_testapigroup_CarpSpec_To_v1_CarpSpec,
|
||||||
|
Convert_v1_CarpStatus_To_testapigroup_CarpStatus,
|
||||||
|
Convert_testapigroup_CarpStatus_To_v1_CarpStatus,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func autoConvert_v1_Carp_To_testapigroup_Carp(in *Carp, out *testapigroup.Carp, s conversion.Scope) error {
|
||||||
|
out.ObjectMeta = in.ObjectMeta
|
||||||
|
if err := Convert_v1_CarpSpec_To_testapigroup_CarpSpec(&in.Spec, &out.Spec, s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := Convert_v1_CarpStatus_To_testapigroup_CarpStatus(&in.Status, &out.Status, s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert_v1_Carp_To_testapigroup_Carp is an autogenerated conversion function.
|
||||||
|
func Convert_v1_Carp_To_testapigroup_Carp(in *Carp, out *testapigroup.Carp, s conversion.Scope) error {
|
||||||
|
return autoConvert_v1_Carp_To_testapigroup_Carp(in, out, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
func autoConvert_testapigroup_Carp_To_v1_Carp(in *testapigroup.Carp, out *Carp, s conversion.Scope) error {
|
||||||
|
out.ObjectMeta = in.ObjectMeta
|
||||||
|
if err := Convert_testapigroup_CarpSpec_To_v1_CarpSpec(&in.Spec, &out.Spec, s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := Convert_testapigroup_CarpStatus_To_v1_CarpStatus(&in.Status, &out.Status, s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert_testapigroup_Carp_To_v1_Carp is an autogenerated conversion function.
|
||||||
|
func Convert_testapigroup_Carp_To_v1_Carp(in *testapigroup.Carp, out *Carp, s conversion.Scope) error {
|
||||||
|
return autoConvert_testapigroup_Carp_To_v1_Carp(in, out, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
func autoConvert_v1_CarpCondition_To_testapigroup_CarpCondition(in *CarpCondition, out *testapigroup.CarpCondition, s conversion.Scope) error {
|
||||||
|
out.Type = testapigroup.CarpConditionType(in.Type)
|
||||||
|
out.Status = testapigroup.ConditionStatus(in.Status)
|
||||||
|
out.LastProbeTime = in.LastProbeTime
|
||||||
|
out.LastTransitionTime = in.LastTransitionTime
|
||||||
|
out.Reason = in.Reason
|
||||||
|
out.Message = in.Message
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert_v1_CarpCondition_To_testapigroup_CarpCondition is an autogenerated conversion function.
|
||||||
|
func Convert_v1_CarpCondition_To_testapigroup_CarpCondition(in *CarpCondition, out *testapigroup.CarpCondition, s conversion.Scope) error {
|
||||||
|
return autoConvert_v1_CarpCondition_To_testapigroup_CarpCondition(in, out, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
func autoConvert_testapigroup_CarpCondition_To_v1_CarpCondition(in *testapigroup.CarpCondition, out *CarpCondition, s conversion.Scope) error {
|
||||||
|
out.Type = CarpConditionType(in.Type)
|
||||||
|
out.Status = ConditionStatus(in.Status)
|
||||||
|
out.LastProbeTime = in.LastProbeTime
|
||||||
|
out.LastTransitionTime = in.LastTransitionTime
|
||||||
|
out.Reason = in.Reason
|
||||||
|
out.Message = in.Message
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert_testapigroup_CarpCondition_To_v1_CarpCondition is an autogenerated conversion function.
|
||||||
|
func Convert_testapigroup_CarpCondition_To_v1_CarpCondition(in *testapigroup.CarpCondition, out *CarpCondition, s conversion.Scope) error {
|
||||||
|
return autoConvert_testapigroup_CarpCondition_To_v1_CarpCondition(in, out, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
func autoConvert_v1_CarpList_To_testapigroup_CarpList(in *CarpList, out *testapigroup.CarpList, s conversion.Scope) error {
|
||||||
|
out.ListMeta = in.ListMeta
|
||||||
|
if in.Items != nil {
|
||||||
|
in, out := &in.Items, &out.Items
|
||||||
|
*out = make([]testapigroup.Carp, len(*in))
|
||||||
|
for i := range *in {
|
||||||
|
if err := Convert_v1_Carp_To_testapigroup_Carp(&(*in)[i], &(*out)[i], s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
out.Items = nil
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert_v1_CarpList_To_testapigroup_CarpList is an autogenerated conversion function.
|
||||||
|
func Convert_v1_CarpList_To_testapigroup_CarpList(in *CarpList, out *testapigroup.CarpList, s conversion.Scope) error {
|
||||||
|
return autoConvert_v1_CarpList_To_testapigroup_CarpList(in, out, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
func autoConvert_testapigroup_CarpList_To_v1_CarpList(in *testapigroup.CarpList, out *CarpList, s conversion.Scope) error {
|
||||||
|
out.ListMeta = in.ListMeta
|
||||||
|
if in.Items != nil {
|
||||||
|
in, out := &in.Items, &out.Items
|
||||||
|
*out = make([]Carp, len(*in))
|
||||||
|
for i := range *in {
|
||||||
|
if err := Convert_testapigroup_Carp_To_v1_Carp(&(*in)[i], &(*out)[i], s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
out.Items = make([]Carp, 0)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert_testapigroup_CarpList_To_v1_CarpList is an autogenerated conversion function.
|
||||||
|
func Convert_testapigroup_CarpList_To_v1_CarpList(in *testapigroup.CarpList, out *CarpList, s conversion.Scope) error {
|
||||||
|
return autoConvert_testapigroup_CarpList_To_v1_CarpList(in, out, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
func autoConvert_v1_CarpSpec_To_testapigroup_CarpSpec(in *CarpSpec, out *testapigroup.CarpSpec, s conversion.Scope) error {
|
||||||
|
out.RestartPolicy = testapigroup.RestartPolicy(in.RestartPolicy)
|
||||||
|
out.TerminationGracePeriodSeconds = (*int64)(unsafe.Pointer(in.TerminationGracePeriodSeconds))
|
||||||
|
out.ActiveDeadlineSeconds = (*int64)(unsafe.Pointer(in.ActiveDeadlineSeconds))
|
||||||
|
out.NodeSelector = *(*map[string]string)(unsafe.Pointer(&in.NodeSelector))
|
||||||
|
out.ServiceAccountName = in.ServiceAccountName
|
||||||
|
// INFO: in.DeprecatedServiceAccount opted out of conversion generation
|
||||||
|
out.NodeName = in.NodeName
|
||||||
|
// INFO: in.HostNetwork opted out of conversion generation
|
||||||
|
// INFO: in.HostPID opted out of conversion generation
|
||||||
|
// INFO: in.HostIPC opted out of conversion generation
|
||||||
|
out.Hostname = in.Hostname
|
||||||
|
out.Subdomain = in.Subdomain
|
||||||
|
out.SchedulerName = in.SchedulerName
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert_v1_CarpSpec_To_testapigroup_CarpSpec is an autogenerated conversion function.
|
||||||
|
func Convert_v1_CarpSpec_To_testapigroup_CarpSpec(in *CarpSpec, out *testapigroup.CarpSpec, s conversion.Scope) error {
|
||||||
|
return autoConvert_v1_CarpSpec_To_testapigroup_CarpSpec(in, out, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
func autoConvert_testapigroup_CarpSpec_To_v1_CarpSpec(in *testapigroup.CarpSpec, out *CarpSpec, s conversion.Scope) error {
|
||||||
|
out.RestartPolicy = RestartPolicy(in.RestartPolicy)
|
||||||
|
out.TerminationGracePeriodSeconds = (*int64)(unsafe.Pointer(in.TerminationGracePeriodSeconds))
|
||||||
|
out.ActiveDeadlineSeconds = (*int64)(unsafe.Pointer(in.ActiveDeadlineSeconds))
|
||||||
|
out.NodeSelector = *(*map[string]string)(unsafe.Pointer(&in.NodeSelector))
|
||||||
|
out.ServiceAccountName = in.ServiceAccountName
|
||||||
|
out.NodeName = in.NodeName
|
||||||
|
out.Hostname = in.Hostname
|
||||||
|
out.Subdomain = in.Subdomain
|
||||||
|
out.SchedulerName = in.SchedulerName
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert_testapigroup_CarpSpec_To_v1_CarpSpec is an autogenerated conversion function.
|
||||||
|
func Convert_testapigroup_CarpSpec_To_v1_CarpSpec(in *testapigroup.CarpSpec, out *CarpSpec, s conversion.Scope) error {
|
||||||
|
return autoConvert_testapigroup_CarpSpec_To_v1_CarpSpec(in, out, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
func autoConvert_v1_CarpStatus_To_testapigroup_CarpStatus(in *CarpStatus, out *testapigroup.CarpStatus, s conversion.Scope) error {
|
||||||
|
out.Phase = testapigroup.CarpPhase(in.Phase)
|
||||||
|
out.Conditions = *(*[]testapigroup.CarpCondition)(unsafe.Pointer(&in.Conditions))
|
||||||
|
out.Message = in.Message
|
||||||
|
out.Reason = in.Reason
|
||||||
|
out.HostIP = in.HostIP
|
||||||
|
out.CarpIP = in.CarpIP
|
||||||
|
out.StartTime = (*meta_v1.Time)(unsafe.Pointer(in.StartTime))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert_v1_CarpStatus_To_testapigroup_CarpStatus is an autogenerated conversion function.
|
||||||
|
func Convert_v1_CarpStatus_To_testapigroup_CarpStatus(in *CarpStatus, out *testapigroup.CarpStatus, s conversion.Scope) error {
|
||||||
|
return autoConvert_v1_CarpStatus_To_testapigroup_CarpStatus(in, out, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
func autoConvert_testapigroup_CarpStatus_To_v1_CarpStatus(in *testapigroup.CarpStatus, out *CarpStatus, s conversion.Scope) error {
|
||||||
|
out.Phase = CarpPhase(in.Phase)
|
||||||
|
out.Conditions = *(*[]CarpCondition)(unsafe.Pointer(&in.Conditions))
|
||||||
|
out.Message = in.Message
|
||||||
|
out.Reason = in.Reason
|
||||||
|
out.HostIP = in.HostIP
|
||||||
|
out.CarpIP = in.CarpIP
|
||||||
|
out.StartTime = (*meta_v1.Time)(unsafe.Pointer(in.StartTime))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert_testapigroup_CarpStatus_To_v1_CarpStatus is an autogenerated conversion function.
|
||||||
|
func Convert_testapigroup_CarpStatus_To_v1_CarpStatus(in *testapigroup.CarpStatus, out *CarpStatus, s conversion.Scope) error {
|
||||||
|
return autoConvert_testapigroup_CarpStatus_To_v1_CarpStatus(in, out, s)
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ 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"
|
||||||
"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/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"
|
||||||
@ -37,8 +37,8 @@ func TestIsList(t *testing.T) {
|
|||||||
obj runtime.Object
|
obj runtime.Object
|
||||||
isList bool
|
isList bool
|
||||||
}{
|
}{
|
||||||
{&example.CarpList{}, true},
|
{&testapigroup.CarpList{}, true},
|
||||||
{&example.Carp{}, false},
|
{&testapigroup.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) {
|
|||||||
|
|
||||||
func TestExtractList(t *testing.T) {
|
func TestExtractList(t *testing.T) {
|
||||||
list1 := []runtime.Object{
|
list1 := []runtime.Object{
|
||||||
&example.Carp{ObjectMeta: metav1.ObjectMeta{Name: "1"}},
|
&testapigroup.Carp{ObjectMeta: metav1.ObjectMeta{Name: "1"}},
|
||||||
&example.Carp{ObjectMeta: metav1.ObjectMeta{Name: "2"}},
|
&testapigroup.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) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
list3 := &fakePtrValueList{
|
list3 := &fakePtrValueList{
|
||||||
Items: []*example.Carp{
|
Items: []*testapigroup.Carp{
|
||||||
{ObjectMeta: metav1.ObjectMeta{Name: "1"}},
|
{ObjectMeta: metav1.ObjectMeta{Name: "1"}},
|
||||||
{ObjectMeta: metav1.ObjectMeta{Name: "2"}},
|
{ObjectMeta: metav1.ObjectMeta{Name: "2"}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
list4 := &example.CarpList{
|
list4 := &testapigroup.CarpList{
|
||||||
Items: []example.Carp{
|
Items: []testapigroup.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"}},
|
||||||
@ -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{
|
||||||
&example.Carp{ObjectMeta: metav1.ObjectMeta{Name: "1"}},
|
&testapigroup.Carp{ObjectMeta: metav1.ObjectMeta{Name: "1"}},
|
||||||
&example.Carp{ObjectMeta: metav1.ObjectMeta{Name: "2"}},
|
&testapigroup.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) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
list3 := &fakePtrValueList{
|
list3 := &fakePtrValueList{
|
||||||
Items: []*example.Carp{
|
Items: []*testapigroup.Carp{
|
||||||
{ObjectMeta: metav1.ObjectMeta{Name: "1"}},
|
{ObjectMeta: metav1.ObjectMeta{Name: "1"}},
|
||||||
{ObjectMeta: metav1.ObjectMeta{Name: "2"}},
|
{ObjectMeta: metav1.ObjectMeta{Name: "2"}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
list4 := &example.CarpList{
|
list4 := &testapigroup.CarpList{
|
||||||
Items: []example.Carp{
|
Items: []testapigroup.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"}},
|
||||||
@ -252,7 +252,7 @@ func TestExtractListOfInterfacePtrs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type fakePtrValueList struct {
|
type fakePtrValueList struct {
|
||||||
Items []*example.Carp
|
Items []*testapigroup.Carp
|
||||||
}
|
}
|
||||||
|
|
||||||
func (obj fakePtrValueList) GetObjectKind() schema.ObjectKind {
|
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 := &example.CarpList{}
|
pl := &testapigroup.CarpList{}
|
||||||
list := []runtime.Object{
|
list := []runtime.Object{
|
||||||
&example.Carp{ObjectMeta: metav1.ObjectMeta{Name: "1"}},
|
&testapigroup.Carp{ObjectMeta: metav1.ObjectMeta{Name: "1"}},
|
||||||
&example.Carp{ObjectMeta: metav1.ObjectMeta{Name: "2"}},
|
&testapigroup.Carp{ObjectMeta: metav1.ObjectMeta{Name: "2"}},
|
||||||
&example.Carp{ObjectMeta: metav1.ObjectMeta{Name: "3"}},
|
&testapigroup.Carp{ObjectMeta: metav1.ObjectMeta{Name: "3"}},
|
||||||
}
|
}
|
||||||
err := meta.SetList(pl, list)
|
err := meta.SetList(pl, list)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -274,7 +274,7 @@ 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].(*example.Carp).Name, pl.Items[i].Name; e != a {
|
if e, a := list[i].(*testapigroup.Carp).Name, pl.Items[i].Name; e != a {
|
||||||
t.Fatalf("Expected %v, got %v", e, a)
|
t.Fatalf("Expected %v, got %v", e, a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -283,9 +283,9 @@ func TestSetList(t *testing.T) {
|
|||||||
func TestSetListToRuntimeObjectArray(t *testing.T) {
|
func TestSetListToRuntimeObjectArray(t *testing.T) {
|
||||||
pl := &List{}
|
pl := &List{}
|
||||||
list := []runtime.Object{
|
list := []runtime.Object{
|
||||||
&example.Carp{ObjectMeta: metav1.ObjectMeta{Name: "1"}},
|
&testapigroup.Carp{ObjectMeta: metav1.ObjectMeta{Name: "1"}},
|
||||||
&example.Carp{ObjectMeta: metav1.ObjectMeta{Name: "2"}},
|
&testapigroup.Carp{ObjectMeta: metav1.ObjectMeta{Name: "2"}},
|
||||||
&example.Carp{ObjectMeta: metav1.ObjectMeta{Name: "3"}},
|
&testapigroup.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) {
|
|||||||
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 := &example.CarpList{}
|
start := &testapigroup.CarpList{}
|
||||||
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) {
|
|||||||
t.Errorf("Unexpected error %v", err)
|
t.Errorf("Unexpected error %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
got := &example.CarpList{}
|
got := &testapigroup.CarpList{}
|
||||||
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)
|
||||||
|
@ -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/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"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAPIObjectMeta(t *testing.T) {
|
func TestAPIObjectMeta(t *testing.T) {
|
||||||
j := &example.Carp{
|
j := &testapigroup.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) {
|
|||||||
|
|
||||||
// BenchmarkAccessorSetFastPath shows the interface fast path
|
// BenchmarkAccessorSetFastPath shows the interface fast path
|
||||||
func BenchmarkAccessorSetFastPath(b *testing.B) {
|
func BenchmarkAccessorSetFastPath(b *testing.B) {
|
||||||
obj := &example.Carp{
|
obj := &testapigroup.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",
|
||||||
|
@ -27,7 +27,7 @@ import (
|
|||||||
apitesting "k8s.io/apimachinery/pkg/api/testing"
|
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/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"
|
||||||
@ -38,7 +38,7 @@ func TestDecodeUnstructured(t *testing.T) {
|
|||||||
rawJson := fmt.Sprintf(`{"kind":"Pod","apiVersion":"%s","metadata":{"name":"test"}}`, groupVersionString)
|
rawJson := fmt.Sprintf(`{"kind":"Pod","apiVersion":"%s","metadata":{"name":"test"}}`, groupVersionString)
|
||||||
pl := &List{
|
pl := &List{
|
||||||
Items: []runtime.Object{
|
Items: []runtime.Object{
|
||||||
&example.Carp{ObjectMeta: metav1.ObjectMeta{Name: "1"}},
|
&testapigroup.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),
|
||||||
@ -458,7 +458,7 @@ func TestDecodeNumbers(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}`)
|
}`)
|
||||||
|
|
||||||
pod := &example.Carp{}
|
pod := &testapigroup.Carp{}
|
||||||
|
|
||||||
_, codecs := TestScheme()
|
_, codecs := TestScheme()
|
||||||
codec := apitesting.TestCodec(codecs, schema.GroupVersion{Group: "", Version: runtime.APIVersionInternal})
|
codec := apitesting.TestCodec(codecs, schema.GroupVersion{Group: "", Version: runtime.APIVersionInternal})
|
||||||
@ -489,7 +489,7 @@ 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.(*example.Carp)
|
pod2, ok := obj2.(*testapigroup.Carp)
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("expected an *api.Pod, got %#v", obj2)
|
t.Fatalf("expected an *api.Pod, got %#v", obj2)
|
||||||
}
|
}
|
||||||
|
@ -21,14 +21,14 @@ import (
|
|||||||
|
|
||||||
apitesting "k8s.io/apimachinery/pkg/api/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/apis/testapigroup"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDecodeList(t *testing.T) {
|
func TestDecodeList(t *testing.T) {
|
||||||
pl := List{
|
pl := List{
|
||||||
Items: []runtime.Object{
|
Items: []runtime.Object{
|
||||||
&example.Carp{ObjectMeta: metav1.ObjectMeta{Name: "1"}},
|
&testapigroup.Carp{ObjectMeta: metav1.ObjectMeta{Name: "1"}},
|
||||||
&runtime.Unknown{
|
&runtime.Unknown{
|
||||||
TypeMeta: runtime.TypeMeta{Kind: "Carp", APIVersion: "v1"},
|
TypeMeta: runtime.TypeMeta{Kind: "Carp", APIVersion: "v1"},
|
||||||
Raw: []byte(`{"kind":"Carp","apiVersion":"` + "v1" + `","metadata":{"name":"test"}}`),
|
Raw: []byte(`{"kind":"Carp","apiVersion":"` + "v1" + `","metadata":{"name":"test"}}`),
|
||||||
@ -38,12 +38,12 @@ func TestDecodeList(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_, codecs := TestScheme()
|
_, codecs := TestScheme()
|
||||||
Codec := apitesting.TestCodec(codecs, example.SchemeGroupVersion)
|
Codec := apitesting.TestCodec(codecs, testapigroup.SchemeGroupVersion)
|
||||||
|
|
||||||
if errs := runtime.DecodeList(pl.Items, Codec); len(errs) != 0 {
|
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].(*example.Carp); !ok || pod.Name != "test" {
|
if pod, ok := pl.Items[1].(*testapigroup.Carp); !ok || pod.Name != "test" {
|
||||||
t.Errorf("object not converted: %#v", pl.Items[1])
|
t.Errorf("object not converted: %#v", pl.Items[1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@ package test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
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/apis/testapigroup"
|
||||||
examplev1 "k8s.io/apimachinery/pkg/apis/testapigroup/v1"
|
"k8s.io/apimachinery/pkg/apis/testapigroup/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
apiserializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
apiserializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
||||||
@ -40,17 +40,17 @@ func TestScheme() (*runtime.Scheme, apiserializer.CodecFactory) {
|
|||||||
scheme := runtime.NewScheme()
|
scheme := runtime.NewScheme()
|
||||||
|
|
||||||
scheme.AddKnownTypes(internalGV,
|
scheme.AddKnownTypes(internalGV,
|
||||||
&example.Carp{},
|
&testapigroup.Carp{},
|
||||||
&example.CarpList{},
|
&testapigroup.CarpList{},
|
||||||
&List{},
|
&List{},
|
||||||
)
|
)
|
||||||
scheme.AddKnownTypes(externalGV,
|
scheme.AddKnownTypes(externalGV,
|
||||||
&examplev1.Carp{},
|
&v1.Carp{},
|
||||||
&examplev1.CarpList{},
|
&v1.CarpList{},
|
||||||
&List{},
|
&List{},
|
||||||
)
|
)
|
||||||
example.AddToScheme(scheme)
|
testapigroup.AddToScheme(scheme)
|
||||||
examplev1.AddToScheme(scheme)
|
v1.AddToScheme(scheme)
|
||||||
|
|
||||||
codecs := apiserializer.NewCodecFactory(scheme)
|
codecs := apiserializer.NewCodecFactory(scheme)
|
||||||
return scheme, codecs
|
return scheme, codecs
|
||||||
|
Loading…
Reference in New Issue
Block a user