@@ -65,15 +65,28 @@ export interface GitHubApiExternalRepoDetails {
6565 * if it is available in the environment.
6666 *
6767 * @param action The required Action state.
68+ * @returns The hostname, port, and CA retrieved from the corresponding environment variables.
69+ */
70+ export function getRegistryProxyConfig ( action : ActionState < [ "ReadOnlyEnv" ] > ) {
71+ return {
72+ host : action . env . getOptional ( RegistryProxyVars . PROXY_HOST ) ,
73+ port : action . env . getOptional ( RegistryProxyVars . PROXY_PORT ) ,
74+ ca : action . env . getOptional ( RegistryProxyVars . PROXY_CA_CERTIFICATE ) ,
75+ } ;
76+ }
77+
78+ /**
79+ * Gets the configuration for the private registry authentication proxy,
80+ * and uses it to initialise a corresponding `ProxyAgent`.
81+ *
82+ * @param action The required Action state.
6883 * @returns A `ProxyAgent` corresponding to the private registry proxy,
6984 * or `undefined` if we couldn't retrieve the host and port.
7085 */
7186export function getRegistryProxy (
72- action : ActionState < [ "Logger" , "Env " ] > ,
87+ action : ActionState < [ "Logger" , "ReadOnlyEnv " ] > ,
7388) : ProxyAgent | undefined {
74- const host = action . env . getOptional ( RegistryProxyVars . PROXY_HOST ) ;
75- const port = action . env . getOptional ( RegistryProxyVars . PROXY_PORT ) ;
76- const cert = action . env . getOptional ( RegistryProxyVars . PROXY_CA_CERTIFICATE ) ;
89+ const { host, port, ca } = getRegistryProxyConfig ( action ) ;
7790
7891 if ( host && port ) {
7992 const uri = `http://${ host } :${ port } ` ;
@@ -84,7 +97,7 @@ export function getRegistryProxy(
8497 uri,
8598 keepAliveTimeout : 10 ,
8699 keepAliveMaxTimeout : 10 ,
87- requestTls : cert ? { ca : cert } : undefined ,
100+ requestTls : ca ? { ca } : undefined ,
88101 } ) ;
89102 }
90103
0 commit comments