@@ -8,11 +8,9 @@ package pipeline
88import (
99 "context"
1010 "fmt"
11- "strings"
1211
1312 "github.com/rotisserie/eris"
1413
15- "github.com/Azure/azure-service-operator/v2/internal/set"
1614 "github.com/Azure/azure-service-operator/v2/tools/generator/internal/astmodel"
1715 "github.com/Azure/azure-service-operator/v2/tools/generator/internal/config"
1816)
@@ -56,17 +54,14 @@ func newVersionMigrationFactory(
5654 return & versionMigrationFactory {
5755 configuration : configuration ,
5856 definitions : definitions ,
59- lastLegacyVersion : "v2.16.0" ,
57+ lastLegacyVersion : "v2.16.0" , //!! Change to v2.16.0 once hybrid mode is in place
6058 }
6159}
6260
6361func (p * versionMigrationFactory ) Process (ctx context.Context ) (astmodel.TypeDefinitionSet , error ) {
6462 // Find all the resources currently using legacy mode
6563 // versioning that need to be moved to use new style versioning
66- toMove , err := p .findLegacyModeResourcesToMove ()
67- if err != nil {
68- return nil , eris .Wrap (err , "finding resources for version migration" )
69- }
64+ toMove := p .findLegacyModeResourcesToMove ()
7065
7166 moved , err := p .moveResources (toMove , "v" )
7267 if err != nil {
@@ -88,19 +83,9 @@ func (p *versionMigrationFactory) Process(ctx context.Context) (astmodel.TypeDef
8883// moved to new packages using new (simpler) versioning.
8984// We scan all definitions looking for resources in groups configured for Legacy mode versioning
9085// that are noted in configuration as being introduced in ASO version 2.17 or later.
91- func (p * versionMigrationFactory ) findLegacyModeResourcesToMove () ( astmodel.TypeDefinitionSet , error ) {
86+ func (p * versionMigrationFactory ) findLegacyModeResourcesToMove () astmodel.TypeDefinitionSet {
9287 result := make (astmodel.TypeDefinitionSet )
9388
94- // For legacy mode groups, we need to ensure that we find at least one resource introduced
95- // prior to v2.17 - this is to catch cases where someone incorrectly configures legacy mode
96- // for a new group. We can't just look for all legacy mode groups, because unit tests focus
97- // on just selected groups.
98- // Instead, we track which legacy mode groups we encounter during our search, and verify
99- // that the set of groups used by newer types is a strict subset of the groups used by
100- // older types.
101- legacyModeGroupsContainingOlderResources := set .Make [string ]()
102- legacyModeGroupsContainingNewerResources := set .Make [string ]()
103-
10489 for _ , def := range p .definitions {
10590 _ , ok := astmodel .AsResourceType (def .Type ())
10691 if ! ok {
@@ -110,38 +95,22 @@ func (p *versionMigrationFactory) findLegacyModeResourcesToMove() (astmodel.Type
11095 pkg := def .Name ().InternalPackageReference ()
11196 group := pkg .Group ()
11297
113- // If the group is not using legacy mode versioning, skip it
11498 mode := astmodel .VersionMigrationModeForGroup (group )
11599 if mode != astmodel .VersionMigrationModeLegacy {
116100 continue
117101 }
118102
119- // Look up which version of ASO this resource was introduced in.
120- // (This might be missing during testing, so it's not an error if we don't find it)
121103 introducedIn , ok := p .configuration .SupportedFrom .Lookup (def .Name ())
122104 if ! ok {
123105 continue
124106 }
125107
126108 if astmodel .ComparePathAndVersion (introducedIn , p .lastLegacyVersion ) > 0 {
127- // This resource was introduced after the last legacy version, it needs to be moved
128109 result .Add (def )
129- legacyModeGroupsContainingNewerResources .Add (group )
130- } else {
131- // Found at least one resource introduced prior to v2.17 in this group
132- legacyModeGroupsContainingOlderResources .Add (group )
133110 }
134111 }
135112
136- // Check to see if any of the legacy mode groups failed to contain older resources
137- legacyGroups := legacyModeGroupsContainingNewerResources .Except (legacyModeGroupsContainingOlderResources )
138- if len (legacyGroups ) > 0 {
139- return nil , eris .Errorf (
140- "expected to find resources introduced prior to ASO version 2.17 in group(s) %s but none were found" ,
141- strings .Join (set .AsSortedSlice (legacyGroups ), ", " ))
142- }
143-
144- return result , nil
113+ return result
145114}
146115
147116// findHybridModeResourcesToCopy identifies resources using hybrid mode versioning that need to be
0 commit comments