mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #7468 from simon3z/serialized-reference
replica: serialize created-by reference
This commit is contained in:
commit
8a47574644
@ -64,6 +64,7 @@ func init() {
|
||||
&PodProxyOptions{},
|
||||
&ComponentStatus{},
|
||||
&ComponentStatusList{},
|
||||
&SerializedReference{},
|
||||
)
|
||||
// Legacy names are supported
|
||||
Scheme.AddKnownTypeWithName("", "Minion", &Node{})
|
||||
@ -109,3 +110,4 @@ func (*PodExecOptions) IsAnAPIObject() {}
|
||||
func (*PodProxyOptions) IsAnAPIObject() {}
|
||||
func (*ComponentStatus) IsAnAPIObject() {}
|
||||
func (*ComponentStatusList) IsAnAPIObject() {}
|
||||
func (*SerializedReference) IsAnAPIObject() {}
|
||||
|
@ -1591,6 +1591,11 @@ type ObjectReference struct {
|
||||
FieldPath string `json:"fieldPath,omitempty"`
|
||||
}
|
||||
|
||||
type SerializedReference struct {
|
||||
TypeMeta `json:",inline"`
|
||||
Reference ObjectReference `json:"reference,omitempty" description:"the reference to an object in the system"`
|
||||
}
|
||||
|
||||
type EventSource struct {
|
||||
// Component from which the event is generated.
|
||||
Component string `json:"component,omitempty"`
|
||||
|
@ -63,6 +63,7 @@ func init() {
|
||||
&PodProxyOptions{},
|
||||
&ComponentStatus{},
|
||||
&ComponentStatusList{},
|
||||
&SerializedReference{},
|
||||
)
|
||||
// Legacy names are supported
|
||||
api.Scheme.AddKnownTypeWithName("v1", "Minion", &Node{})
|
||||
@ -106,3 +107,4 @@ func (*PodExecOptions) IsAnAPIObject() {}
|
||||
func (*PodProxyOptions) IsAnAPIObject() {}
|
||||
func (*ComponentStatus) IsAnAPIObject() {}
|
||||
func (*ComponentStatusList) IsAnAPIObject() {}
|
||||
func (*SerializedReference) IsAnAPIObject() {}
|
||||
|
@ -1527,6 +1527,11 @@ type ObjectReference struct {
|
||||
FieldPath string `json:"fieldPath,omitempty" description:"if referring to a piece of an object instead of an entire object, this string should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]"`
|
||||
}
|
||||
|
||||
type SerializedReference struct {
|
||||
TypeMeta `json:",inline"`
|
||||
Reference ObjectReference `json:"reference,omitempty" description:"the reference to an object in the system"`
|
||||
}
|
||||
|
||||
type EventSource struct {
|
||||
// Component from which the event is generated.
|
||||
Component string `json:"component,omitempty" description:"component that generated the event"`
|
||||
|
@ -70,6 +70,7 @@ func init() {
|
||||
&PodProxyOptions{},
|
||||
&ComponentStatus{},
|
||||
&ComponentStatusList{},
|
||||
&SerializedReference{},
|
||||
)
|
||||
// Future names are supported
|
||||
api.Scheme.AddKnownTypeWithName("v1beta1", "Node", &Minion{})
|
||||
@ -114,3 +115,4 @@ func (*PodExecOptions) IsAnAPIObject() {}
|
||||
func (*PodProxyOptions) IsAnAPIObject() {}
|
||||
func (*ComponentStatus) IsAnAPIObject() {}
|
||||
func (*ComponentStatusList) IsAnAPIObject() {}
|
||||
func (*SerializedReference) IsAnAPIObject() {}
|
||||
|
@ -1382,6 +1382,11 @@ type ObjectReference struct {
|
||||
FieldPath string `json:"fieldPath,omitempty" description:"if referring to a piece of an object instead of an entire object, this string should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]"`
|
||||
}
|
||||
|
||||
type SerializedReference struct {
|
||||
TypeMeta `json:",inline"`
|
||||
Reference ObjectReference `json:"reference,omitempty" description:"the reference to an object in the system"`
|
||||
}
|
||||
|
||||
// Event is a report of an event somewhere in the cluster.
|
||||
// TODO: Decide whether to store these separately or with the object they apply to.
|
||||
type Event struct {
|
||||
|
@ -70,6 +70,7 @@ func init() {
|
||||
&PodProxyOptions{},
|
||||
&ComponentStatus{},
|
||||
&ComponentStatusList{},
|
||||
&SerializedReference{},
|
||||
)
|
||||
// Future names are supported
|
||||
api.Scheme.AddKnownTypeWithName("v1beta2", "Node", &Minion{})
|
||||
@ -114,3 +115,4 @@ func (*PodExecOptions) IsAnAPIObject() {}
|
||||
func (*PodProxyOptions) IsAnAPIObject() {}
|
||||
func (*ComponentStatus) IsAnAPIObject() {}
|
||||
func (*ComponentStatusList) IsAnAPIObject() {}
|
||||
func (*SerializedReference) IsAnAPIObject() {}
|
||||
|
@ -1415,6 +1415,11 @@ type ObjectReference struct {
|
||||
FieldPath string `json:"fieldPath,omitempty" description:"if referring to a piece of an object instead of an entire object, this string should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]"`
|
||||
}
|
||||
|
||||
type SerializedReference struct {
|
||||
TypeMeta `json:",inline"`
|
||||
Reference ObjectReference `json:"reference,omitempty" description:"the reference to an object in the system"`
|
||||
}
|
||||
|
||||
// Event is a report of an event somewhere in the cluster.
|
||||
// TODO: Decide whether to store these separately or with the object they apply to.
|
||||
//
|
||||
|
@ -2098,6 +2098,26 @@ func convert_api_SecretVolumeSource_To_v1beta3_SecretVolumeSource(in *newer.Secr
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_v1beta3_SerializedReference_To_api_SerializedReference(in *SerializedReference, out *newer.SerializedReference, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Reference, &out.Reference, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_api_SerializedReference_To_v1beta3_SerializedReference(in *newer.SerializedReference, out *SerializedReference, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Reference, &out.Reference, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_v1beta3_Service_To_api_Service(in *Service, out *newer.Service, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
@ -2531,6 +2551,7 @@ func init() {
|
||||
convert_api_SecretList_To_v1beta3_SecretList,
|
||||
convert_api_SecretVolumeSource_To_v1beta3_SecretVolumeSource,
|
||||
convert_api_Secret_To_v1beta3_Secret,
|
||||
convert_api_SerializedReference_To_v1beta3_SerializedReference,
|
||||
convert_api_ServiceList_To_v1beta3_ServiceList,
|
||||
convert_api_ServicePort_To_v1beta3_ServicePort,
|
||||
convert_api_ServiceSpec_To_v1beta3_ServiceSpec,
|
||||
@ -2621,6 +2642,7 @@ func init() {
|
||||
convert_v1beta3_SecretList_To_api_SecretList,
|
||||
convert_v1beta3_SecretVolumeSource_To_api_SecretVolumeSource,
|
||||
convert_v1beta3_Secret_To_api_Secret,
|
||||
convert_v1beta3_SerializedReference_To_api_SerializedReference,
|
||||
convert_v1beta3_ServiceList_To_api_ServiceList,
|
||||
convert_v1beta3_ServicePort_To_api_ServicePort,
|
||||
convert_v1beta3_ServiceSpec_To_api_ServiceSpec,
|
||||
|
@ -63,6 +63,7 @@ func init() {
|
||||
&PodProxyOptions{},
|
||||
&ComponentStatus{},
|
||||
&ComponentStatusList{},
|
||||
&SerializedReference{},
|
||||
)
|
||||
// Legacy names are supported
|
||||
api.Scheme.AddKnownTypeWithName("v1beta3", "Minion", &Node{})
|
||||
@ -106,3 +107,4 @@ func (*PodExecOptions) IsAnAPIObject() {}
|
||||
func (*PodProxyOptions) IsAnAPIObject() {}
|
||||
func (*ComponentStatus) IsAnAPIObject() {}
|
||||
func (*ComponentStatusList) IsAnAPIObject() {}
|
||||
func (*SerializedReference) IsAnAPIObject() {}
|
||||
|
@ -1527,6 +1527,11 @@ type ObjectReference struct {
|
||||
FieldPath string `json:"fieldPath,omitempty" description:"if referring to a piece of an object instead of an entire object, this string should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]"`
|
||||
}
|
||||
|
||||
type SerializedReference struct {
|
||||
TypeMeta `json:",inline"`
|
||||
Reference ObjectReference `json:"reference,omitempty" description:"the reference to an object in the system"`
|
||||
}
|
||||
|
||||
type EventSource struct {
|
||||
// Component from which the event is generated.
|
||||
Component string `json:"component,omitempty" description:"component that generated the event"`
|
||||
|
@ -17,10 +17,10 @@ limitations under the License.
|
||||
package controller
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
|
||||
@ -201,8 +201,9 @@ func (r RealPodControl) createReplica(namespace string, controller *api.Replicat
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to get controller reference: %v", err)
|
||||
}
|
||||
// TODO: Version this serialization per #7322
|
||||
createdByRefJson, err := json.Marshal(createdByRef)
|
||||
createdByRefJson, err := latest.Codec.Encode(&api.SerializedReference{
|
||||
Reference: *createdByRef,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to serialize controller reference: %v", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user