mirror of
https://github.com/actions/cache.git
synced 2026-07-04 06:09:31 +00:00
Proxy support
This commit is contained in:
parent
2f484236b8
commit
847b0c7400
9 changed files with 206748 additions and 91 deletions
|
|
@ -1,10 +1,10 @@
|
|||
import * as core from "@actions/core";
|
||||
import { S3ClientConfig } from "@aws-sdk/client-s3";
|
||||
|
||||
import * as cache from "./backend";
|
||||
import { Events, Inputs, Outputs, State } from "./constants";
|
||||
import { IStateProvider } from "./stateProvider";
|
||||
import * as utils from "./utils/actionUtils";
|
||||
import { getConfig } from "./utils/options";
|
||||
|
||||
async function restoreImpl(
|
||||
stateProvider: IStateProvider
|
||||
|
|
@ -32,18 +32,10 @@ async function restoreImpl(
|
|||
const cachePaths = utils.getInputAsArray(Inputs.Path, {
|
||||
required: true
|
||||
});
|
||||
const s3Config = {
|
||||
credentials: {
|
||||
accessKeyId: core.getInput(Inputs.AwsAccessKeyId),
|
||||
secretAccessKey: core.getInput(Inputs.AwsSecretAccessKey)
|
||||
},
|
||||
region: core.getInput(Inputs.AwsRegion)
|
||||
} as S3ClientConfig;
|
||||
|
||||
const s3Bucket = core.getInput(Inputs.AwsBucket);
|
||||
|
||||
const failOnCacheMiss = utils.getInputAsBool(Inputs.FailOnCacheMiss);
|
||||
const lookupOnly = utils.getInputAsBool(Inputs.LookupOnly);
|
||||
const s3Bucket = core.getInput(Inputs.AwsBucket);
|
||||
const s3Config = getConfig();
|
||||
|
||||
const cacheKey = await cache.restoreCache(
|
||||
cachePaths,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import * as core from "@actions/core";
|
||||
import { S3ClientConfig } from "@aws-sdk/client-s3";
|
||||
|
||||
import * as cache from "./backend";
|
||||
import { Events, Inputs, State } from "./constants";
|
||||
import { IStateProvider } from "./stateProvider";
|
||||
import * as utils from "./utils/actionUtils";
|
||||
import { getConfig } from "./utils/options";
|
||||
|
||||
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
||||
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
|
||||
|
|
@ -52,16 +52,8 @@ async function saveImpl(stateProvider: IStateProvider): Promise<number | void> {
|
|||
const cachePaths = utils.getInputAsArray(Inputs.Path, {
|
||||
required: true
|
||||
});
|
||||
|
||||
const s3Config = {
|
||||
credentials: {
|
||||
accessKeyId: core.getInput(Inputs.AwsAccessKeyId),
|
||||
secretAccessKey: core.getInput(Inputs.AwsSecretAccessKey)
|
||||
},
|
||||
region: core.getInput(Inputs.AwsRegion)
|
||||
} as S3ClientConfig;
|
||||
|
||||
const s3Bucket = core.getInput(Inputs.AwsBucket);
|
||||
const s3Config = getConfig();
|
||||
|
||||
cacheId = await cache.saveCache(
|
||||
cachePaths,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,32 @@
|
|||
import * as core from "@actions/core";
|
||||
import { getProxyUrl } from "@actions/http-client";
|
||||
import { S3ClientConfig } from "@aws-sdk/client-s3";
|
||||
import { NodeHttpHandler } from "@aws-sdk/node-http-handler";
|
||||
import ProxyAgent from "proxy-agent";
|
||||
|
||||
import { Inputs } from "../constants";
|
||||
import { DownloadOptions, UploadOptions } from "./contracts";
|
||||
|
||||
export function getConfig(): S3ClientConfig {
|
||||
const proxy = getProxyUrl("https://amazonaws.com");
|
||||
|
||||
const config: S3ClientConfig = {
|
||||
credentials: {
|
||||
accessKeyId: core.getInput(Inputs.AwsAccessKeyId),
|
||||
secretAccessKey: core.getInput(Inputs.AwsSecretAccessKey)
|
||||
},
|
||||
region: core.getInput(Inputs.AwsRegion)
|
||||
};
|
||||
|
||||
if (proxy) {
|
||||
config.requestHandler = new NodeHttpHandler({
|
||||
httpsAgent: ProxyAgent(proxy)
|
||||
});
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy of the upload options with defaults filled in.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue