@@ -45,7 +45,7 @@ import { featuresGenerateDocsHandler, featuresGenerateDocsOptions } from './feat
4545import { templatesGenerateDocsHandler , templatesGenerateDocsOptions } from './templatesCLI/generateDocs' ;
4646import { mapNodeOSToGOOS , mapNodeArchitectureToGOARCH } from '../spec-configuration/containerCollectionsOCI' ;
4747import { templateMetadataHandler , templateMetadataOptions } from './templatesCLI/metadata' ;
48- import { allowCrossOriginAuthHostEnv , parseCrossOriginAuthHosts } from '../spec-configuration/httpOCIRegistry' ;
48+ import { parseCrossOriginAuthHosts } from '../spec-configuration/httpOCIRegistry' ;
4949
5050const defaultDefaultUserEnvProbe : UserEnvProbe = 'loginInteractiveShell' ;
5151
@@ -70,14 +70,14 @@ const mountRegex = /^type=(bind|volume),source=([^,]+),target=([^,]+)(?:,externa
7070 . option ( 'allow-cross-origin-auth-host' , {
7171 type : 'string' ,
7272 array : true ,
73+ nargs : 1 ,
7374 global : true ,
7475 description : 'Allow an OCI registry to use a cross-origin HTTPS authentication host. Format: <registry-host>=<auth-host>. May be repeated.' ,
7576 } )
76- . middleware ( args => {
77- const entries = args [ 'allow-cross-origin-auth-host' ] || [ ] ;
78- parseCrossOriginAuthHosts ( entries ) ;
79- process . env [ allowCrossOriginAuthHostEnv ] = JSON . stringify ( entries ) ;
80- } , true )
77+ . check ( args => {
78+ parseCrossOriginAuthHosts ( getAllowedCrossOriginAuthHosts ( args as OciAuthArgs ) ) ;
79+ return true ;
80+ } )
8181 . strict ( ) ;
8282 y . wrap ( Math . min ( 120 , y . terminalWidth ( ) ) ) ;
8383 y . command ( 'up' , 'Create and run dev container' , provisionOptions , provisionHandler ) ;
@@ -108,6 +108,11 @@ const mountRegex = /^type=(bind|volume),source=([^,]+),target=([^,]+)(?:,externa
108108} ) ( ) . catch ( console . error ) ;
109109
110110export type UnpackArgv < T > = T extends Argv < infer U > ? U : T ;
111+ export type OciAuthArgs = { 'allow-cross-origin-auth-host' ?: string [ ] } ;
112+
113+ export function getAllowedCrossOriginAuthHosts ( args : OciAuthArgs ) {
114+ return args [ 'allow-cross-origin-auth-host' ] || [ ] ;
115+ }
111116
112117function provisionOptions ( y : Argv ) {
113118 return y . options ( {
@@ -188,7 +193,7 @@ function provisionOptions(y: Argv) {
188193 } ) ;
189194}
190195
191- type ProvisionArgs = UnpackArgv < ReturnType < typeof provisionOptions > > ;
196+ type ProvisionArgs = UnpackArgv < ReturnType < typeof provisionOptions > > & OciAuthArgs ;
192197
193198function provisionHandler ( args : ProvisionArgs ) {
194199 runAsyncHandler ( provision . bind ( null , args ) ) ;
@@ -241,6 +246,7 @@ async function provision({
241246 'omit-syntax-directive' : omitSyntaxDirective ,
242247 'include-configuration' : includeConfig ,
243248 'include-merged-configuration' : includeMergedConfig ,
249+ 'allow-cross-origin-auth-host' : allowedCrossOriginAuthHosts ,
244250} : ProvisionArgs ) {
245251
246252 warnDeprecatedLockfileFlags ( experimentalLockfile , experimentalFrozenLockfile ) ;
@@ -315,6 +321,7 @@ async function provision({
315321 omitSyntaxDirective,
316322 includeConfig,
317323 includeMergedConfig,
324+ allowedCrossOriginAuthHosts,
318325 } ;
319326
320327 const result = await doProvision ( options , providedIdLabels ) ;
@@ -395,7 +402,7 @@ function setUpOptions(y: Argv) {
395402 } ) ;
396403}
397404
398- type SetUpArgs = UnpackArgv < ReturnType < typeof setUpOptions > > ;
405+ type SetUpArgs = UnpackArgv < ReturnType < typeof setUpOptions > > & OciAuthArgs ;
399406
400407function setUpHandler ( args : SetUpArgs ) {
401408 runAsyncHandler ( setUp . bind ( null , args ) ) ;
@@ -432,6 +439,7 @@ async function doSetUp({
432439 'container-session-data-folder' : containerSessionDataFolder ,
433440 'include-configuration' : includeConfig ,
434441 'include-merged-configuration' : includeMergedConfig ,
442+ 'allow-cross-origin-auth-host' : allowedCrossOriginAuthHosts ,
435443} : SetUpArgs ) {
436444
437445 const disposables : ( ( ) => Promise < unknown > | undefined ) [ ] = [ ] ;
@@ -482,6 +490,7 @@ async function doSetUp({
482490 installCommand : dotfilesInstallCommand ,
483491 targetPath : dotfilesTargetPath ,
484492 } ,
493+ allowedCrossOriginAuthHosts,
485494 } , disposables ) ;
486495
487496 const { common } = params ;
@@ -573,7 +582,7 @@ function buildOptions(y: Argv) {
573582 } ) ;
574583}
575584
576- type BuildArgs = UnpackArgv < ReturnType < typeof buildOptions > > ;
585+ type BuildArgs = UnpackArgv < ReturnType < typeof buildOptions > > & OciAuthArgs ;
577586
578587function buildHandler ( args : BuildArgs ) {
579588 runAsyncHandler ( build . bind ( null , args ) ) ;
@@ -614,6 +623,7 @@ async function doBuild({
614623 'no-lockfile' : noLockfile ,
615624 'frozen-lockfile' : frozenLockfile ,
616625 'omit-syntax-directive' : omitSyntaxDirective ,
626+ 'allow-cross-origin-auth-host' : allowedCrossOriginAuthHosts ,
617627} : BuildArgs ) {
618628 warnDeprecatedLockfileFlags ( experimentalLockfile , experimentalFrozenLockfile ) ;
619629 const effectiveFrozenLockfile = frozenLockfile || experimentalFrozenLockfile ;
@@ -667,6 +677,7 @@ async function doBuild({
667677 noLockfile,
668678 frozenLockfile : effectiveFrozenLockfile ,
669679 omitSyntaxDirective,
680+ allowedCrossOriginAuthHosts,
670681 } , disposables ) ;
671682
672683 const { common, dockerComposeCLI } = params ;
@@ -842,7 +853,7 @@ function runUserCommandsOptions(y: Argv) {
842853 } ) ;
843854}
844855
845- type RunUserCommandsArgs = UnpackArgv < ReturnType < typeof runUserCommandsOptions > > ;
856+ type RunUserCommandsArgs = UnpackArgv < ReturnType < typeof runUserCommandsOptions > > & OciAuthArgs ;
846857
847858function runUserCommandsHandler ( args : RunUserCommandsArgs ) {
848859 runAsyncHandler ( runUserCommands . bind ( null , args ) ) ;
@@ -1035,7 +1046,7 @@ function readConfigurationOptions(y: Argv) {
10351046 } ) ;
10361047}
10371048
1038- type ReadConfigurationArgs = UnpackArgv < ReturnType < typeof readConfigurationOptions > > ;
1049+ type ReadConfigurationArgs = UnpackArgv < ReturnType < typeof readConfigurationOptions > > & OciAuthArgs ;
10391050
10401051function readConfigurationHandler ( args : ReadConfigurationArgs ) {
10411052 runAsyncHandler ( readConfiguration . bind ( null , args ) ) ;
@@ -1060,6 +1071,7 @@ async function readConfiguration({
10601071 'include-merged-configuration' : includeMergedConfig ,
10611072 'additional-features' : additionalFeaturesJson ,
10621073 'skip-feature-auto-mapping' : skipFeatureAutoMapping ,
1074+ 'allow-cross-origin-auth-host' : allowedCrossOriginAuthHosts ,
10631075} : ReadConfigurationArgs ) {
10641076 const disposables : ( ( ) => Promise < unknown > | undefined ) [ ] = [ ] ;
10651077 const dispose = async ( ) => {
@@ -1116,7 +1128,8 @@ async function readConfiguration({
11161128 env : cliHost . env ,
11171129 output,
11181130 buildPlatformInfo,
1119- targetPlatformInfo : buildPlatformInfo
1131+ targetPlatformInfo : buildPlatformInfo ,
1132+ allowedCrossOriginAuthHosts,
11201133 } ;
11211134 const { container, idLabels } = await findContainerAndIdLabels ( params , containerId , providedIdLabels , workspaceFolder , configPath ?. fsPath ) ;
11221135 if ( container ) {
@@ -1174,7 +1187,7 @@ function outdatedOptions(y: Argv) {
11741187 } ) ;
11751188}
11761189
1177- type OutdatedArgs = UnpackArgv < ReturnType < typeof outdatedOptions > > ;
1190+ type OutdatedArgs = UnpackArgv < ReturnType < typeof outdatedOptions > > & OciAuthArgs ;
11781191
11791192function outdatedHandler ( args : OutdatedArgs ) {
11801193 runAsyncHandler ( outdated . bind ( null , args ) ) ;
@@ -1189,6 +1202,7 @@ async function outdated({
11891202 'log-format' : logFormat ,
11901203 'terminal-rows' : terminalRows ,
11911204 'terminal-columns' : terminalColumns ,
1205+ 'allow-cross-origin-auth-host' : allowedCrossOriginAuthHosts ,
11921206} : OutdatedArgs ) {
11931207 const disposables : ( ( ) => Promise < unknown > | undefined ) [ ] = [ ] ;
11941208 const dispose = async ( ) => {
@@ -1225,6 +1239,7 @@ async function outdated({
12251239 env : cliHost . env ,
12261240 skipFeatureAutoMapping : false ,
12271241 platform : cliHost . platform ,
1242+ allowedCrossOriginAuthHosts,
12281243 } ;
12291244
12301245 const outdated = await loadVersionInfo ( params , configs . config . config ) ;
0 commit comments