Refactor PodStatus to PodCondition in internal API for v1beta3

This commit is contained in:
markturansky
2014-11-05 10:22:54 -05:00
parent 3bd10d4fb4
commit 119f654a13
13 changed files with 139 additions and 46 deletions

View File

@@ -17,6 +17,7 @@ limitations under the License.
package v1beta2
import (
"errors"
"strconv"
newer "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
@@ -89,7 +90,43 @@ func init() {
return s.Convert(&in.Annotations, &out.Annotations, 0)
},
// Convert all the standard objects
// Convert all to the new PodCondition constants
func(in *newer.PodCondition, out *PodStatus, s conversion.Scope) error {
switch *in {
case "":
*out = ""
case newer.PodPending:
*out = PodWaiting
case newer.PodRunning:
*out = PodRunning
case newer.PodSucceeded:
*out = PodTerminated
case newer.PodFailed:
*out = PodTerminated
default:
return errors.New("The string provided is not a valid PodCondition constant value")
}
return nil
},
func(in *PodStatus, out *newer.PodCondition, s conversion.Scope) error {
switch *in {
case "":
*out = ""
case PodWaiting:
*out = newer.PodPending
case PodRunning:
*out = newer.PodRunning
case PodTerminated:
// Older API versions did not contain enough info to map to PodFailed
*out = newer.PodFailed
default:
return errors.New("The string provided is not a valid PodCondition constant value")
}
return nil
},
// Convert all the standard objects
func(in *newer.Pod, out *Pod, s conversion.Scope) error {
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {