Add a subbindings resource as /pods/{name}/binding

Allows POST to create a binding as a child. Also refactors internal
and v1beta3 Binding to be more generic (so that other resources can
support Bindings).
This commit is contained in:
Clayton Coleman
2015-03-04 15:55:41 -05:00
parent 227a1d306d
commit dfc19185f5
19 changed files with 175 additions and 255 deletions

View File

@@ -101,6 +101,10 @@ func FuzzerFor(t *testing.T, version string, src rand.Source) *fuzz.Fuzzer {
j.Spec = api.PodSpec{}
c.Fuzz(&j.Spec)
},
func(j *api.Binding, c fuzz.Continue) {
c.Fuzz(&j.ObjectMeta)
j.Target.Name = c.RandString()
},
func(j *api.ReplicationControllerSpec, c fuzz.Continue) {
c.FuzzNoCustom(j) // fuzz self without calling this function again
j.TemplateRef = nil // this is required for round trip

View File

@@ -918,13 +918,14 @@ type NamespaceList struct {
Items []Namespace `json:"items"`
}
// Binding is written by a scheduler to cause a pod to be bound to a host.
// Binding ties one object to another - for example, a pod is bound to a node by a scheduler.
type Binding struct {
TypeMeta `json:",inline"`
TypeMeta `json:",inline"`
// ObjectMeta describes the object that is being bound.
ObjectMeta `json:"metadata,omitempty"`
PodID string `json:"podID"`
Host string `json:"host"`
// Target is the object to bind to.
Target ObjectReference `json:"target"`
}
// Status is a return value for calls that don't return other objects.

View File

@@ -1324,6 +1324,24 @@ func init() {
return nil
},
func(in *Binding, out *newer.Binding, s conversion.Scope) error {
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
out.Target = newer.ObjectReference{
Name: in.Host,
}
out.Name = in.PodID
return nil
},
func(in *newer.Binding, out *Binding, s conversion.Scope) error {
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
out.Host = in.Target.Name
out.PodID = in.Name
return nil
},
)
if err != nil {
// If one of the conversion functions is malformed, detect it immediately.

View File

@@ -1240,6 +1240,24 @@ func init() {
return nil
},
func(in *Binding, out *newer.Binding, s conversion.Scope) error {
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
out.Target = newer.ObjectReference{
Name: in.Host,
}
out.Name = in.PodID
return nil
},
func(in *newer.Binding, out *Binding, s conversion.Scope) error {
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
out.Host = in.Target.Name
out.PodID = in.Name
return nil
},
)
if err != nil {
// If one of the conversion functions is malformed, detect it immediately.

View File

@@ -940,16 +940,14 @@ type NamespaceList struct {
Items []Namespace `json:"items" description:"items is the list of Namespace objects in the list"`
}
// Binding is written by a scheduler to cause a pod to be bound to a node. Name is not
// required for Bindings.
// Binding ties one object to another - for example, a pod is bound to a node by a scheduler.
type Binding struct {
TypeMeta `json:",inline"`
TypeMeta `json:",inline"`
// ObjectMeta describes the object that is being bound.
ObjectMeta `json:"metadata,omitempty" description:"standard object metadata; see https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/api-conventions.md#metadata"`
// PodID is a Pod name to be bound to a node.
PodID string `json:"podID" description:"name of the pod to be bound to a node"`
// Host is the name of a node to bind to.
Host string `json:"host" description:"name of the node to bind to"`
// Target is the object to bind to.
Target ObjectReference `json:"target" description:"an object to bind to"`
}
// Status is a return value for calls that don't return other objects.