Skip to content

Commit

Permalink
Always migrate to latest patch version
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Dec 9, 2024
1 parent 9c2550d commit 92e3ec9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions core/goflow/flows.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ func CloneDefinition(data []byte, depMapping map[uuids.UUID]uuids.UUID) ([]byte,

// MigrateDefinition migrates the given flow definition to the specified version
func MigrateDefinition(cfg *runtime.Config, data []byte, toVersion *semver.Version) ([]byte, error) {
// if requested version only differs by patch from current version, use current version
if toVersion == nil || (toVersion.LessThan(definition.CurrentSpecVersion) && toVersion.Major() == definition.CurrentSpecVersion.Major() && toVersion.Minor() == definition.CurrentSpecVersion.Minor()) {
toVersion = definition.CurrentSpecVersion
}

f, err := migrations.MigrateToVersion(data, toVersion, MigrationConfig(cfg))
if err != nil {
return nil, &FlowDefError{cause: err}
Expand Down
4 changes: 2 additions & 2 deletions core/goflow/flows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestMigrateDefinition(t *testing.T) {
v13_3_0 := testsuite.ReadFile("testdata/migrate/13.3.0.json")
v13_4_0 := testsuite.ReadFile("testdata/migrate/13.4.0.json")
v13_5_0 := testsuite.ReadFile("testdata/migrate/13.5.0.json")
v13_6_0 := testsuite.ReadFile("testdata/migrate/13.6.0.json")
//v13_6_0 := testsuite.ReadFile("testdata/migrate/13.6.0.json")
v13_6_1 := testsuite.ReadFile("testdata/migrate/13.6.1.json")

// 13.0 > 13.1
Expand Down Expand Up @@ -95,7 +95,7 @@ func TestMigrateDefinition(t *testing.T) {
// 13.5 > 13.6
migrated, err = goflow.MigrateDefinition(rt.Config, migrated, semver.MustParse("13.6.0"))
assert.NoError(t, err)
test.AssertEqualJSON(t, v13_6_0, migrated)
test.AssertEqualJSON(t, v13_6_1, migrated) // because we bump to the latest patch version

// 13.6 > 13.6.1
migrated, err = goflow.MigrateDefinition(rt.Config, migrated, semver.MustParse("13.6.1"))
Expand Down

0 comments on commit 92e3ec9

Please sign in to comment.