@@ -42,14 +42,17 @@ internal virtual string GetApiVersion(ResourceType resourceType, CancellationTok
42
42
{
43
43
string version ;
44
44
Dictionary < string , string > resourceVersions ;
45
- if ( ! Client . ResourceApiVersionCache . TryGetValue ( resourceType . Namespace , out resourceVersions ) )
45
+ if ( ! Client . ApiVersionOverrides . TryGetValue ( resourceType , out version ) )
46
46
{
47
- resourceVersions = LoadResourceVersionsFromApi ( resourceType . Namespace , cancellationToken ) ;
48
- Client . ResourceApiVersionCache . TryAdd ( resourceType . Namespace , resourceVersions ) ;
49
- }
50
- if ( ! resourceVersions . TryGetValue ( resourceType . Type , out version ) )
51
- {
52
- throw new InvalidOperationException ( $ "Invalid resource type { resourceType } ") ;
47
+ if ( ! Client . ResourceApiVersionCache . TryGetValue ( resourceType . Namespace , out resourceVersions ) )
48
+ {
49
+ resourceVersions = LoadResourceVersionsFromApi ( resourceType . Namespace , cancellationToken ) ;
50
+ Client . ResourceApiVersionCache . TryAdd ( resourceType . Namespace , resourceVersions ) ;
51
+ }
52
+ if ( ! resourceVersions . TryGetValue ( resourceType . Type , out version ) )
53
+ {
54
+ throw new InvalidOperationException ( $ "Invalid resource type { resourceType } ") ;
55
+ }
53
56
}
54
57
return version ;
55
58
}
@@ -59,14 +62,17 @@ internal virtual async ValueTask<string> GetApiVersionAsync(ResourceType resourc
59
62
{
60
63
string version ;
61
64
Dictionary < string , string > resourceVersions ;
62
- if ( ! Client . ResourceApiVersionCache . TryGetValue ( resourceType . Namespace , out resourceVersions ) )
63
- {
64
- resourceVersions = await LoadResourceVersionsFromApiAsync ( resourceType . Namespace , cancellationToken ) . ConfigureAwait ( false ) ;
65
- Client . ResourceApiVersionCache . TryAdd ( resourceType . Namespace , resourceVersions ) ;
66
- }
67
- if ( ! resourceVersions . TryGetValue ( resourceType . Type , out version ) )
65
+ if ( ! Client . ApiVersionOverrides . TryGetValue ( resourceType , out version ) )
68
66
{
69
- throw new InvalidOperationException ( $ "Invalid resource type { resourceType } ") ;
67
+ if ( ! Client . ResourceApiVersionCache . TryGetValue ( resourceType . Namespace , out resourceVersions ) )
68
+ {
69
+ resourceVersions = await LoadResourceVersionsFromApiAsync ( resourceType . Namespace , cancellationToken ) . ConfigureAwait ( false ) ;
70
+ Client . ResourceApiVersionCache . TryAdd ( resourceType . Namespace , resourceVersions ) ;
71
+ }
72
+ if ( ! resourceVersions . TryGetValue ( resourceType . Type , out version ) )
73
+ {
74
+ throw new InvalidOperationException ( $ "Invalid resource type { resourceType } ") ;
75
+ }
70
76
}
71
77
return version ;
72
78
}
0 commit comments