Skip to content

Commit

Permalink
manual prep for move
Browse files Browse the repository at this point in the history
  • Loading branch information
deads2k committed Nov 28, 2017
1 parent 9d41cbe commit e491d07
Show file tree
Hide file tree
Showing 41 changed files with 544 additions and 793 deletions.
17 changes: 4 additions & 13 deletions pkg/api/latest/latest.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,6 @@ func IsOriginAPIGroup(groupName string) bool {
return false
}

// IsKindInAnyOriginGroup returns true if OpenShift owns the kind described in any apiVersion.
// TODO: this may not work once we divide builds/deployments/images into their own API groups
func IsKindInAnyOriginGroup(kind string) bool {
for _, version := range Versions {
if OriginKind(version.WithKind(kind)) {
return true
}
}

return false
}

func getOrCreateOriginKinds() map[schema.GroupVersionKind]bool {
if originTypes == nil {
originTypesLock.Do(func() {
Expand All @@ -90,9 +78,12 @@ func getOrCreateOriginKinds() map[schema.GroupVersionKind]bool {
if kind == "SecurityContextConstraints" {
continue
}
if !strings.Contains(t.PkgPath(), "github.com/openshift/origin") || strings.Contains(t.PkgPath(), "github.com/openshift/origin/vendor/") {
isExternal := strings.Contains(t.PkgPath(), "github.com/openshift/api")
isVendored := strings.Contains(t.PkgPath(), "github.com/openshift/origin/vendor/")
if isVendored && !isExternal {
continue
}

gvk := version.WithKind(kind)
newOriginTypes[gvk] = true
}
Expand Down
9 changes: 5 additions & 4 deletions pkg/apps/apis/apps/v1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/intstr"

"github.com/openshift/api/apps/v1"
newer "github.com/openshift/origin/pkg/apps/apis/apps"
imageapi "github.com/openshift/origin/pkg/image/apis/image"
)

func Convert_v1_DeploymentTriggerImageChangeParams_To_apps_DeploymentTriggerImageChangeParams(in *DeploymentTriggerImageChangeParams, out *newer.DeploymentTriggerImageChangeParams, s conversion.Scope) error {
func Convert_v1_DeploymentTriggerImageChangeParams_To_apps_DeploymentTriggerImageChangeParams(in *v1.DeploymentTriggerImageChangeParams, out *newer.DeploymentTriggerImageChangeParams, s conversion.Scope) error {
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
Expand All @@ -28,7 +29,7 @@ func Convert_v1_DeploymentTriggerImageChangeParams_To_apps_DeploymentTriggerImag
return nil
}

func Convert_apps_DeploymentTriggerImageChangeParams_To_v1_DeploymentTriggerImageChangeParams(in *newer.DeploymentTriggerImageChangeParams, out *DeploymentTriggerImageChangeParams, s conversion.Scope) error {
func Convert_apps_DeploymentTriggerImageChangeParams_To_v1_DeploymentTriggerImageChangeParams(in *newer.DeploymentTriggerImageChangeParams, out *v1.DeploymentTriggerImageChangeParams, s conversion.Scope) error {
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
Expand All @@ -45,7 +46,7 @@ func Convert_apps_DeploymentTriggerImageChangeParams_To_v1_DeploymentTriggerImag
return nil
}

func Convert_v1_RollingDeploymentStrategyParams_To_apps_RollingDeploymentStrategyParams(in *RollingDeploymentStrategyParams, out *newer.RollingDeploymentStrategyParams, s conversion.Scope) error {
func Convert_v1_RollingDeploymentStrategyParams_To_apps_RollingDeploymentStrategyParams(in *v1.RollingDeploymentStrategyParams, out *newer.RollingDeploymentStrategyParams, s conversion.Scope) error {
SetDefaults_RollingDeploymentStrategyParams(in)

out.UpdatePeriodSeconds = in.UpdatePeriodSeconds
Expand Down Expand Up @@ -75,7 +76,7 @@ func Convert_v1_RollingDeploymentStrategyParams_To_apps_RollingDeploymentStrateg
return nil
}

func Convert_apps_RollingDeploymentStrategyParams_To_v1_RollingDeploymentStrategyParams(in *newer.RollingDeploymentStrategyParams, out *RollingDeploymentStrategyParams, s conversion.Scope) error {
func Convert_apps_RollingDeploymentStrategyParams_To_v1_RollingDeploymentStrategyParams(in *newer.RollingDeploymentStrategyParams, out *v1.RollingDeploymentStrategyParams, s conversion.Scope) error {
out.UpdatePeriodSeconds = in.UpdatePeriodSeconds
out.IntervalSeconds = in.IntervalSeconds
out.TimeoutSeconds = in.TimeoutSeconds
Expand Down
31 changes: 16 additions & 15 deletions pkg/apps/apis/apps/v1/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
kapi "k8s.io/kubernetes/pkg/api"

"github.com/openshift/api/apps/v1"
newer "github.com/openshift/origin/pkg/apps/apis/apps"
)

Expand Down Expand Up @@ -49,7 +50,7 @@ func TestTriggerRoundTrip(t *testing.T) {
}

for _, test := range tests {
p := DeploymentTriggerImageChangeParams{
p := v1.DeploymentTriggerImageChangeParams{
From: kapiv1.ObjectReference{
Kind: test.kind,
Name: test.name,
Expand All @@ -70,20 +71,20 @@ func TestTriggerRoundTrip(t *testing.T) {

func Test_convert_v1_RollingDeploymentStrategyParams_To_apps_RollingDeploymentStrategyParams(t *testing.T) {
tests := []struct {
in *RollingDeploymentStrategyParams
in *v1.RollingDeploymentStrategyParams
out *newer.RollingDeploymentStrategyParams
}{
{
in: &RollingDeploymentStrategyParams{
in: &v1.RollingDeploymentStrategyParams{
UpdatePeriodSeconds: newInt64(5),
IntervalSeconds: newInt64(6),
TimeoutSeconds: newInt64(7),
MaxUnavailable: newIntOrString(intstr.FromString("25%")),
Pre: &LifecycleHook{
FailurePolicy: LifecycleHookFailurePolicyIgnore,
Pre: &v1.LifecycleHook{
FailurePolicy: v1.LifecycleHookFailurePolicyIgnore,
},
Post: &LifecycleHook{
FailurePolicy: LifecycleHookFailurePolicyAbort,
Post: &v1.LifecycleHook{
FailurePolicy: v1.LifecycleHookFailurePolicyAbort,
},
},
out: &newer.RollingDeploymentStrategyParams{
Expand All @@ -101,7 +102,7 @@ func Test_convert_v1_RollingDeploymentStrategyParams_To_apps_RollingDeploymentSt
},
},
{
in: &RollingDeploymentStrategyParams{
in: &v1.RollingDeploymentStrategyParams{
UpdatePeriodSeconds: newInt64(5),
IntervalSeconds: newInt64(6),
TimeoutSeconds: newInt64(7),
Expand All @@ -116,7 +117,7 @@ func Test_convert_v1_RollingDeploymentStrategyParams_To_apps_RollingDeploymentSt
},
},
{
in: &RollingDeploymentStrategyParams{
in: &v1.RollingDeploymentStrategyParams{
UpdatePeriodSeconds: newInt64(5),
IntervalSeconds: newInt64(6),
TimeoutSeconds: newInt64(7),
Expand All @@ -132,7 +133,7 @@ func Test_convert_v1_RollingDeploymentStrategyParams_To_apps_RollingDeploymentSt
},
},
{
in: &RollingDeploymentStrategyParams{
in: &v1.RollingDeploymentStrategyParams{
UpdatePeriodSeconds: newInt64(5),
IntervalSeconds: newInt64(6),
TimeoutSeconds: newInt64(7),
Expand Down Expand Up @@ -162,7 +163,7 @@ func Test_convert_v1_RollingDeploymentStrategyParams_To_apps_RollingDeploymentSt
func Test_convert_api_RollingDeploymentStrategyParams_To_v1_RollingDeploymentStrategyParams(t *testing.T) {
tests := []struct {
in *newer.RollingDeploymentStrategyParams
out *RollingDeploymentStrategyParams
out *v1.RollingDeploymentStrategyParams
}{
{
in: &newer.RollingDeploymentStrategyParams{
Expand All @@ -172,7 +173,7 @@ func Test_convert_api_RollingDeploymentStrategyParams_To_v1_RollingDeploymentStr
MaxSurge: intstr.FromInt(0),
MaxUnavailable: intstr.FromString("25%"),
},
out: &RollingDeploymentStrategyParams{
out: &v1.RollingDeploymentStrategyParams{
UpdatePeriodSeconds: newInt64(5),
IntervalSeconds: newInt64(6),
TimeoutSeconds: newInt64(7),
Expand All @@ -188,7 +189,7 @@ func Test_convert_api_RollingDeploymentStrategyParams_To_v1_RollingDeploymentStr
MaxSurge: intstr.FromString("25%"),
MaxUnavailable: intstr.FromInt(0),
},
out: &RollingDeploymentStrategyParams{
out: &v1.RollingDeploymentStrategyParams{
UpdatePeriodSeconds: newInt64(5),
IntervalSeconds: newInt64(6),
TimeoutSeconds: newInt64(7),
Expand All @@ -204,7 +205,7 @@ func Test_convert_api_RollingDeploymentStrategyParams_To_v1_RollingDeploymentStr
MaxSurge: intstr.FromInt(10),
MaxUnavailable: intstr.FromInt(20),
},
out: &RollingDeploymentStrategyParams{
out: &v1.RollingDeploymentStrategyParams{
UpdatePeriodSeconds: newInt64(5),
IntervalSeconds: newInt64(6),
TimeoutSeconds: newInt64(7),
Expand All @@ -215,7 +216,7 @@ func Test_convert_api_RollingDeploymentStrategyParams_To_v1_RollingDeploymentStr
}

for _, test := range tests {
out := &RollingDeploymentStrategyParams{}
out := &v1.RollingDeploymentStrategyParams{}
if err := scheme.Convert(test.in, out, nil); err != nil {
t.Errorf("unexpected error: %v", err)
}
Expand Down
27 changes: 14 additions & 13 deletions pkg/apps/apis/apps/v1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package v1
import (
"k8s.io/apimachinery/pkg/util/intstr"

"github.com/openshift/api/apps/v1"
deployapi "github.com/openshift/origin/pkg/apps/apis/apps"
)

Expand All @@ -18,7 +19,7 @@ func AppsV1DeploymentConfigLayeredDefaults(dc *deployapi.DeploymentConfig) {
}

// Keep this in sync with pkg/api/serialization_test.go#defaultHookContainerName
func defaultHookContainerName(hook *LifecycleHook, containerName string) {
func defaultHookContainerName(hook *v1.LifecycleHook, containerName string) {
if hook == nil {
return
}
Expand All @@ -34,10 +35,10 @@ func defaultHookContainerName(hook *LifecycleHook, containerName string) {
}
}

func SetDefaults_DeploymentConfigSpec(obj *DeploymentConfigSpec) {
func SetDefaults_DeploymentConfigSpec(obj *v1.DeploymentConfigSpec) {
if obj.Triggers == nil {
obj.Triggers = []DeploymentTriggerPolicy{
{Type: DeploymentTriggerOnConfigChange},
obj.Triggers = []v1.DeploymentTriggerPolicy{
{Type: v1.DeploymentTriggerOnConfigChange},
}
}
if len(obj.Selector) == 0 && obj.Template != nil {
Expand All @@ -59,34 +60,34 @@ func SetDefaults_DeploymentConfigSpec(obj *DeploymentConfigSpec) {
}
}

func SetDefaults_DeploymentStrategy(obj *DeploymentStrategy) {
func SetDefaults_DeploymentStrategy(obj *v1.DeploymentStrategy) {
if len(obj.Type) == 0 {
obj.Type = DeploymentStrategyTypeRolling
obj.Type = v1.DeploymentStrategyTypeRolling
}

if obj.Type == DeploymentStrategyTypeRolling && obj.RollingParams == nil {
obj.RollingParams = &RollingDeploymentStrategyParams{
if obj.Type == v1.DeploymentStrategyTypeRolling && obj.RollingParams == nil {
obj.RollingParams = &v1.RollingDeploymentStrategyParams{
IntervalSeconds: mkintp(deployapi.DefaultRollingIntervalSeconds),
UpdatePeriodSeconds: mkintp(deployapi.DefaultRollingUpdatePeriodSeconds),
TimeoutSeconds: mkintp(deployapi.DefaultRollingTimeoutSeconds),
}
}
if obj.Type == DeploymentStrategyTypeRecreate && obj.RecreateParams == nil {
obj.RecreateParams = &RecreateDeploymentStrategyParams{}
if obj.Type == v1.DeploymentStrategyTypeRecreate && obj.RecreateParams == nil {
obj.RecreateParams = &v1.RecreateDeploymentStrategyParams{}
}

if obj.ActiveDeadlineSeconds == nil {
obj.ActiveDeadlineSeconds = mkintp(deployapi.MaxDeploymentDurationSeconds)
}
}

func SetDefaults_RecreateDeploymentStrategyParams(obj *RecreateDeploymentStrategyParams) {
func SetDefaults_RecreateDeploymentStrategyParams(obj *v1.RecreateDeploymentStrategyParams) {
if obj.TimeoutSeconds == nil {
obj.TimeoutSeconds = mkintp(deployapi.DefaultRecreateTimeoutSeconds)
}
}

func SetDefaults_RollingDeploymentStrategyParams(obj *RollingDeploymentStrategyParams) {
func SetDefaults_RollingDeploymentStrategyParams(obj *v1.RollingDeploymentStrategyParams) {
if obj.IntervalSeconds == nil {
obj.IntervalSeconds = mkintp(deployapi.DefaultRollingIntervalSeconds)
}
Expand Down Expand Up @@ -120,7 +121,7 @@ func SetDefaults_RollingDeploymentStrategyParams(obj *RollingDeploymentStrategyP
}
}

func SetDefaults_DeploymentConfig(obj *DeploymentConfig) {
func SetDefaults_DeploymentConfig(obj *v1.DeploymentConfig) {
for _, t := range obj.Spec.Triggers {
if t.ImageChangeParams != nil {
if len(t.ImageChangeParams.From.Kind) == 0 {
Expand Down
Loading

0 comments on commit e491d07

Please sign in to comment.