Skip to content

Commit

Permalink
Apply default values on new fields at each step of the upgrade
Browse files Browse the repository at this point in the history
Signed-off-by: David Gageot <david@gageot.net>
  • Loading branch information
dgageot committed Nov 28, 2018
1 parent 9c2e4bb commit 067fd07
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 10 deletions.
10 changes: 8 additions & 2 deletions pkg/skaffold/schema/v1alpha1/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (config *SkaffoldPipeline) Upgrade() (util.VersionedConfig, error) {
}
}

return &next.SkaffoldPipeline{
upgraded := &next.SkaffoldPipeline{
APIVersion: next.Version,
Kind: config.Kind,
Deploy: next.DeployConfig{
Expand All @@ -120,5 +120,11 @@ func (config *SkaffoldPipeline) Upgrade() (util.VersionedConfig, error) {
BuildType: newBuildType,
TagPolicy: tagPolicy,
},
}, nil
}

if err := upgraded.SetDefaultValues(); err != nil {
return nil, err
}

return upgraded, nil
}
1 change: 1 addition & 0 deletions pkg/skaffold/schema/v1alpha1/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ deploy:
}

upgradedPipeline := upgraded.(*next.SkaffoldPipeline)
tt.expected.SetDefaultValues()
testutil.CheckDeepEqual(t, tt.expected, upgradedPipeline)
})
}
Expand Down
10 changes: 8 additions & 2 deletions pkg/skaffold/schema/v1alpha2/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,19 @@ func (config *SkaffoldPipeline) Upgrade() (util.VersionedConfig, error) {
}
}

return &next.SkaffoldPipeline{
upgraded := &next.SkaffoldPipeline{
APIVersion: next.Version,
Kind: config.Kind,
Deploy: newDeploy,
Build: newBuild,
Profiles: newProfiles,
}, nil
}

if err := upgraded.SetDefaultValues(); err != nil {
return nil, err
}

return upgraded, nil
}

func convert(old interface{}, new interface{}) error {
Expand Down
10 changes: 8 additions & 2 deletions pkg/skaffold/schema/v1alpha3/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,19 @@ func (config *SkaffoldPipeline) Upgrade() (util.VersionedConfig, error) {
}
convertBuild(oldBuild, newBuild)

return &next.SkaffoldPipeline{
upgraded := &next.SkaffoldPipeline{
APIVersion: next.Version,
Kind: config.Kind,
Deploy: newDeploy,
Build: newBuild,
Profiles: newProfiles,
}, nil
}

if err := upgraded.SetDefaultValues(); err != nil {
return nil, err
}

return upgraded, nil
}

func convertBuild(oldBuild BuildConfig, newBuild next.BuildConfig) {
Expand Down
10 changes: 8 additions & 2 deletions pkg/skaffold/schema/v1alpha4/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,20 @@ func (config *SkaffoldPipeline) Upgrade() (util.VersionedConfig, error) {
return nil, errors.Wrap(err, "converting new test")
}

return &next.SkaffoldPipeline{
upgraded := &next.SkaffoldPipeline{
APIVersion: next.Version,
Kind: config.Kind,
Build: newBuild,
Test: newTest,
Deploy: newDeploy,
Profiles: newProfiles,
}, nil
}

if err := upgraded.SetDefaultValues(); err != nil {
return nil, err
}

return upgraded, nil
}

func convert(old interface{}, new interface{}) error {
Expand Down
10 changes: 8 additions & 2 deletions pkg/skaffold/schema/v1alpha5/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,20 @@ func (config *SkaffoldPipeline) Upgrade() (util.VersionedConfig, error) {
return nil, errors.Wrap(err, "converting new test")
}

return &next.SkaffoldPipeline{
upgraded := &next.SkaffoldPipeline{
APIVersion: next.Version,
Kind: config.Kind,
Build: newBuild,
Test: newTest,
Deploy: newDeploy,
Profiles: newProfiles,
}, nil
}

if err := upgraded.SetDefaultValues(); err != nil {
return nil, err
}

return upgraded, nil
}

func convert(old interface{}, new interface{}) error {
Expand Down

0 comments on commit 067fd07

Please sign in to comment.