@@ -51,14 +51,6 @@ const OFFICIAL_NAME_MAP: Record<OfficialCloudName, CloudName> = {
5151 AzureGermanCloud : 'germany' ,
5252} ;
5353
54- /** Map canonical short names to official Azure cloud environment names */
55- const SHORT_TO_OFFICIAL : Record < CloudName , OfficialCloudName > = {
56- public : 'AzureCloud' ,
57- china : 'AzureChinaCloud' ,
58- usgov : 'AzureUSGovernment' ,
59- germany : 'AzureGermanCloud' ,
60- } ;
61-
6254/**
6355 * Resolve a cloud name (short or official long form) to its configuration.
6456 * Throws if the name is not recognized.
@@ -90,18 +82,16 @@ export function getCloudConfig(cloudName: string): CloudConfig {
9082 * official name, such as Azure DevOps service connection JSON bodies.
9183 */
9284export function getOfficialCloudName ( cloudName : string ) : string {
93- // Already an official name?
85+ // Already an official name (key in OFFICIAL_NAME_MAP) — return as-is
9486 if ( cloudName in OFFICIAL_NAME_MAP ) {
9587 return cloudName ;
9688 }
97- // Short name — map to official name
98- const shortName = cloudName as CloudName ;
99- if ( SHORT_TO_OFFICIAL [ shortName ] ) {
100- return SHORT_TO_OFFICIAL [ shortName ] ;
101- }
102- // Fall back to validation error via getCloudConfig
89+ // Short name — find the OFFICIAL_NAME_MAP key whose value matches it;
90+ // getCloudConfig validates and throws for unknown names
10391 getCloudConfig ( cloudName ) ;
104- return 'AzureCloud' ; // unreachable
92+ const entry = ( Object . entries ( OFFICIAL_NAME_MAP ) as [ string , CloudName ] [ ] )
93+ . find ( ( [ , short ] ) => short === ( cloudName as CloudName ) ) ;
94+ return entry ?. [ 0 ] ?? 'AzureCloud' ;
10595}
10696
10797/**
0 commit comments