Skip to content

Commit

Permalink
Fix up uploadMethod handling
Browse files Browse the repository at this point in the history
  • Loading branch information
elliot-nelson committed Feb 26, 2023
1 parent 3f99657 commit 76346c4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export class HttpBuildCacheProvider implements ICloudBuildCacheProvider {

let credentials: string | undefined = this._environmentCredential;

if (typeof credentials !== 'string') {
if (credentials === undefined) {
credentials = await this._tryGetCredentialsFromCache();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ const PLUGIN_NAME: string = 'HttpBuildCachePlugin';
*/
export interface IRushHttpBuildCachePluginOptions {
/**
* The url to the service that caches builds.
* The URL of the server that stores the caches (e.g. "https://build-caches.example.com").
*/
url: string;

/**
* The HTTP method to use when writing to the cache (defaults to PUT).
*/
uploadMethod?: string;

/**
* An optional set of HTTP headers to pass to the cache server.
*/
Expand Down Expand Up @@ -55,12 +60,14 @@ export class RushHttpBuildCachePlugin implements IRushPlugin {
rushSession.registerCloudBuildCacheProviderFactory(
'http',
(buildCacheConfig): HttpBuildCacheProvider => {
const { url, headers, tokenHandler, cacheKeyPrefix, isCacheWriteAllowed } = this._options;
const { url, uploadMethod, headers, tokenHandler, cacheKeyPrefix, isCacheWriteAllowed } =
this._options;

const options: IHttpBuildCacheProviderOptions = {
pluginName: this.pluginName,
rushProjectRoot: rushConfig.rushJsonFolder,
url: url,
uploadMethod: uploadMethod,
headers: headers,
tokenHandler: tokenHandler,
cacheKeyPrefix: cacheKeyPrefix,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"description": "(Required) The URL of the server that stores the caches (e.g. \"https://build-caches.example.com\").",
"format": "uri"
},
"method": {
"uploadMethod": {
"type": "string",
"description": "(Required) The URL of the server that stores the caches (e.g. \"https://build-caches.example.com\").",
"enum": ["PUT", "POST", "GET", "PATCH"],
"description": "(Optional) The HTTP method to use when writing to the cache (defaults to PUT).",
"enum": ["PUT", "POST", "PATCH"],
"default": "PUT"
},
"headers": {
Expand All @@ -25,7 +25,7 @@
},
"tokenHandler": {
"type": "string",
"description": "(Optional) Shell command that prints the authorization token needed to communicate with the HTTPS server and exits with code 0."
"description": "(Optional) Shell command that prints the authorization token needed to communicate with the HTTPS server and exits with code 0. This command will be executed from the root of the monorepo."
},
"cacheKeyPrefix": {
"type": "string",
Expand Down

0 comments on commit 76346c4

Please sign in to comment.