Skip to content

Commit

Permalink
api: rename conditionkind -> conditiontype
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedanese committed Feb 24, 2015
1 parent 754a2a8 commit 5267127
Show file tree
Hide file tree
Showing 17 changed files with 324 additions and 72 deletions.
14 changes: 7 additions & 7 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,18 +472,18 @@ const (
PodUnknown PodPhase = "Unknown"
)

type PodConditionKind string
type PodConditionType string

// These are valid conditions of pod.
const (
// PodReady means the pod is able to service requests and should be added to the
// load balancing pools of all matching services.
PodReady PodConditionKind = "Ready"
PodReady PodConditionType = "Ready"
)

// TODO: add LastTransitionTime, Reason, Message to match NodeCondition api.
type PodCondition struct {
Kind PodConditionKind `json:"kind"`
Type PodConditionType `json:"type"`
Status ConditionStatus `json:"status"`
}

Expand Down Expand Up @@ -805,20 +805,20 @@ const (
NodeTerminated NodePhase = "Terminated"
)

type NodeConditionKind string
type NodeConditionType string

// These are valid conditions of node. Currently, we don't have enough information to decide
// node condition. In the future, we will add more. The proposed set of conditions are:
// NodeReachable, NodeLive, NodeReady, NodeSchedulable, NodeRunnable.
const (
// NodeReachable means the node can be reached (in the sense of HTTP connection) from node controller.
NodeReachable NodeConditionKind = "Reachable"
NodeReachable NodeConditionType = "Reachable"
// NodeReady means the node returns StatusOK for HTTP health check.
NodeReady NodeConditionKind = "Ready"
NodeReady NodeConditionType = "Ready"
)

type NodeCondition struct {
Kind NodeConditionKind `json:"kind"`
Type NodeConditionType `json:"type"`
Status ConditionStatus `json:"status"`
LastProbeTime util.Time `json:"lastProbeTime,omitempty"`
LastTransitionTime util.Time `json:"lastTransitionTime,omitempty"`
Expand Down
126 changes: 126 additions & 0 deletions pkg/api/v1beta1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,132 @@ func init() {
}
return nil
},

func(in *newer.NodeCondition, out *NodeCondition, s conversion.Scope) error {
if err := s.Convert(&in.Type, &out.Kind, 0); err != nil {
return err
}
if err := s.Convert(&in.Status, &out.Status, 0); err != nil {
return err
}
if err := s.Convert(&in.LastProbeTime, &out.LastProbeTime, 0); err != nil {
return err
}
if err := s.Convert(&in.LastTransitionTime, &out.LastTransitionTime, 0); err != nil {
return err
}
if err := s.Convert(&in.Reason, &out.Reason, 0); err != nil {
return err
}
if err := s.Convert(&in.Message, &out.Message, 0); err != nil {
return err
}
return nil
},
func(in *NodeCondition, out *newer.NodeCondition, s conversion.Scope) error {
if err := s.Convert(&in.Kind, &out.Type, 0); err != nil {
return err
}
if err := s.Convert(&in.Status, &out.Status, 0); err != nil {
return err
}
if err := s.Convert(&in.LastProbeTime, &out.LastProbeTime, 0); err != nil {
return err
}
if err := s.Convert(&in.LastTransitionTime, &out.LastTransitionTime, 0); err != nil {
return err
}
if err := s.Convert(&in.Reason, &out.Reason, 0); err != nil {
return err
}
if err := s.Convert(&in.Message, &out.Message, 0); err != nil {
return err
}
return nil
},

func(in *newer.NodeConditionType, out *NodeConditionKind, s conversion.Scope) error {
switch *in {
case newer.NodeReachable:
*out = NodeReachable
break
case newer.NodeReady:
*out = NodeReady
break
case "":
*out = ""
default:
*out = NodeConditionKind(*in)
break
}

return nil
},
func(in *NodeConditionKind, out *newer.NodeConditionType, s conversion.Scope) error {
switch *in {
case NodeReachable:
*out = newer.NodeReachable
break
case NodeReady:
*out = newer.NodeReady
break
case "":
*out = ""
default:
*out = newer.NodeConditionType(*in)
break
}

return nil
},

func(in *newer.PodCondition, out *PodCondition, s conversion.Scope) error {
if err := s.Convert(&in.Type, &out.Kind, 0); err != nil {
return err
}
if err := s.Convert(&in.Status, &out.Status, 0); err != nil {
return err
}
return nil
},
func(in *PodCondition, out *newer.PodCondition, s conversion.Scope) error {
if err := s.Convert(&in.Kind, &out.Type, 0); err != nil {
return err
}
if err := s.Convert(&in.Status, &out.Status, 0); err != nil {
return err
}
return nil
},

func(in *newer.PodConditionType, out *PodConditionKind, s conversion.Scope) error {
switch *in {
case newer.PodReady:
*out = PodReady
break
case "":
*out = ""
default:
*out = PodConditionKind(*in)
break
}

return nil
},
func(in *PodConditionKind, out *newer.PodConditionType, s conversion.Scope) error {
switch *in {
case PodReady:
*out = newer.PodReady
break
case "":
*out = ""
default:
*out = newer.PodConditionType(*in)
break
}

return nil
},
)
if err != nil {
// If one of the conversion functions is malformed, detect it immediately.
Expand Down
126 changes: 126 additions & 0 deletions pkg/api/v1beta2/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,132 @@ func init() {
}
return nil
},

func(in *newer.NodeCondition, out *NodeCondition, s conversion.Scope) error {
if err := s.Convert(&in.Type, &out.Kind, 0); err != nil {
return err
}
if err := s.Convert(&in.Status, &out.Status, 0); err != nil {
return err
}
if err := s.Convert(&in.LastProbeTime, &out.LastProbeTime, 0); err != nil {
return err
}
if err := s.Convert(&in.LastTransitionTime, &out.LastTransitionTime, 0); err != nil {
return err
}
if err := s.Convert(&in.Reason, &out.Reason, 0); err != nil {
return err
}
if err := s.Convert(&in.Message, &out.Message, 0); err != nil {
return err
}
return nil
},
func(in *NodeCondition, out *newer.NodeCondition, s conversion.Scope) error {
if err := s.Convert(&in.Kind, &out.Type, 0); err != nil {
return err
}
if err := s.Convert(&in.Status, &out.Status, 0); err != nil {
return err
}
if err := s.Convert(&in.LastProbeTime, &out.LastProbeTime, 0); err != nil {
return err
}
if err := s.Convert(&in.LastTransitionTime, &out.LastTransitionTime, 0); err != nil {
return err
}
if err := s.Convert(&in.Reason, &out.Reason, 0); err != nil {
return err
}
if err := s.Convert(&in.Message, &out.Message, 0); err != nil {
return err
}
return nil
},

func(in *newer.NodeConditionType, out *NodeConditionKind, s conversion.Scope) error {
switch *in {
case newer.NodeReachable:
*out = NodeReachable
break
case newer.NodeReady:
*out = NodeReady
break
case "":
*out = ""
default:
*out = NodeConditionKind(*in)
break
}

return nil
},
func(in *NodeConditionKind, out *newer.NodeConditionType, s conversion.Scope) error {
switch *in {
case NodeReachable:
*out = newer.NodeReachable
break
case NodeReady:
*out = newer.NodeReady
break
case "":
*out = ""
default:
*out = newer.NodeConditionType(*in)
break
}

return nil
},

func(in *newer.PodCondition, out *PodCondition, s conversion.Scope) error {
if err := s.Convert(&in.Type, &out.Kind, 0); err != nil {
return err
}
if err := s.Convert(&in.Status, &out.Status, 0); err != nil {
return err
}
return nil
},
func(in *PodCondition, out *newer.PodCondition, s conversion.Scope) error {
if err := s.Convert(&in.Kind, &out.Type, 0); err != nil {
return err
}
if err := s.Convert(&in.Status, &out.Status, 0); err != nil {
return err
}
return nil
},

func(in *newer.PodConditionType, out *PodConditionKind, s conversion.Scope) error {
switch *in {
case newer.PodReady:
*out = PodReady
break
case "":
*out = ""
default:
*out = PodConditionKind(*in)
break
}

return nil
},
func(in *PodConditionKind, out *newer.PodConditionType, s conversion.Scope) error {
switch *in {
case PodReady:
*out = newer.PodReady
break
case "":
*out = ""
default:
*out = newer.PodConditionType(*in)
break
}

return nil
},
)
if err != nil {
// If one of the conversion functions is malformed, detect it immediately.
Expand Down
18 changes: 9 additions & 9 deletions pkg/api/v1beta3/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,20 +490,20 @@ const (
PodUnknown PodPhase = "Unknown"
)

// PodConditionKind is a valid value for PodCondition.Kind
type PodConditionKind string
// PodConditionType is a valid value for PodCondition.Type
type PodConditionType string

// These are valid conditions of pod.
const (
// PodReady means the pod is able to service requests and should be added to the
// load balancing pools of all matching services.
PodReady PodConditionKind = "Ready"
PodReady PodConditionType = "Ready"
)

// TODO: add LastTransitionTime, Reason, Message to match NodeCondition api.
type PodCondition struct {
// Status is the status of the condition
Kind PodConditionKind `json:"kind"`
// Type is the type of the condition
Type PodConditionType `json:"type"`
// Status is the status of the condition
Status ConditionStatus `json:"status"`
}
Expand Down Expand Up @@ -838,20 +838,20 @@ const (
NodeTerminated NodePhase = "Terminated"
)

type NodeConditionKind string
type NodeConditionType string

// These are valid conditions of node. Currently, we don't have enough information to decide
// node condition. In the future, we will add more. The proposed set of conditions are:
// NodeReachable, NodeLive, NodeReady, NodeSchedulable, NodeRunnable.
const (
// NodeReachable means the node can be reached (in the sense of HTTP connection) from node controller.
NodeReachable NodeConditionKind = "Reachable"
NodeReachable NodeConditionType = "Reachable"
// NodeReady means the node returns StatusOK for HTTP health check.
NodeReady NodeConditionKind = "Ready"
NodeReady NodeConditionType = "Ready"
)

type NodeCondition struct {
Kind NodeConditionKind `json:"kind"`
Type NodeConditionType `json:"type"`
Status ConditionStatus `json:"status"`
LastProbeTime util.Time `json:"lastProbeTime,omitempty"`
LastTransitionTime util.Time `json:"lastTransitionTime,omitempty"`
Expand Down
Loading

0 comments on commit 5267127

Please sign in to comment.