Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename {Node,Pod}ConditionKind -> {Node,Pod}ConditionType #4767

Merged
merged 1 commit into from
Feb 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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