@lage-run/cache 1.1.7 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.json CHANGED
@@ -2,7 +2,22 @@
2
2
  "name": "@lage-run/cache",
3
3
  "entries": [
4
4
  {
5
- "date": "Thu, 23 May 2024 18:14:47 GMT",
5
+ "date": "Mon, 10 Jun 2024 23:50:24 GMT",
6
+ "version": "1.2.0",
7
+ "tag": "@lage-run/cache_v1.2.0",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "author": "brunoru@microsoft.com",
12
+ "package": "@lage-run/cache",
13
+ "commit": "0894d97ebfedc339b77161c40fa8643d93e4486d",
14
+ "comment": "Add support for DefaultAzureCredentials when storage endpoint is passed in."
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Thu, 23 May 2024 18:15:05 GMT",
6
21
  "version": "1.1.7",
7
22
  "tag": "@lage-run/cache_v1.1.7",
8
23
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,20 @@
1
1
  # Change Log - @lage-run/cache
2
2
 
3
- This log was last generated on Thu, 23 May 2024 18:14:47 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 10 Jun 2024 23:50:24 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 1.2.0
8
+
9
+ Mon, 10 Jun 2024 23:50:24 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - Add support for DefaultAzureCredentials when storage endpoint is passed in. (brunoru@microsoft.com)
14
+
7
15
  ## 1.1.7
8
16
 
9
- Thu, 23 May 2024 18:14:47 GMT
17
+ Thu, 23 May 2024 18:15:05 GMT
10
18
 
11
19
  ### Patches
12
20
 
package/README.md CHANGED
@@ -32,7 +32,7 @@ const remoteFallbackCacheProviderOptions = {
32
32
  cacheStorageOptions: {
33
33
  provider: "azure-blob",
34
34
  options: {
35
- connectionString: "asdfasdfasdfafds";
35
+ connectionString: "asdfasdfasdfafds"; // Providing an un-authenitcated Blob Service Endpoint will force use of Azure DefualtAzureCredentials
36
36
  container: "container";
37
37
  maxSize?: 150;
38
38
  }
@@ -0,0 +1,5 @@
1
+ import { DefaultAzureCredential } from "@azure/identity";
2
+ export declare class CredentialCache {
3
+ private static credential;
4
+ static getInstance(): DefaultAzureCredential;
5
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "CredentialCache", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return CredentialCache;
9
+ }
10
+ });
11
+ const _identity = require("@azure/identity");
12
+ function _define_property(obj, key, value) {
13
+ if (key in obj) {
14
+ Object.defineProperty(obj, key, {
15
+ value: value,
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true
19
+ });
20
+ } else {
21
+ obj[key] = value;
22
+ }
23
+ return obj;
24
+ }
25
+ class CredentialCache {
26
+ static getInstance() {
27
+ if (!this.credential) {
28
+ this.credential = new _identity.DefaultAzureCredential();
29
+ }
30
+ return this.credential;
31
+ }
32
+ }
33
+ _define_property(CredentialCache, "credential", null);
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * Backfill wrappers: some functions that uses the `backfill` library that doesn't require them to be inside a class
3
3
  */
4
+ import { CacheStorageConfig } from "backfill-config";
4
5
  import type { Logger as BackfillLogger } from "backfill-logger";
5
6
  import type { CacheOptions } from "./types/CacheOptions.js";
6
7
  export declare function createBackfillLogger(): BackfillLogger;
7
8
  export declare function createBackfillCacheConfig(cwd: string, cacheOptions: Partial<CacheOptions> | undefined, backfillLogger: BackfillLogger): {
8
- cacheStorageConfig: import("backfill-config").CacheStorageConfig;
9
+ cacheStorageConfig: CacheStorageConfig;
9
10
  clearOutput: boolean;
10
11
  internalCacheFolder: string;
11
12
  logFolder: string;
@@ -21,6 +21,7 @@ _export(exports, {
21
21
  const _os = /*#__PURE__*/ _interop_require_wildcard(require("os"));
22
22
  const _backfillconfig = require("backfill-config");
23
23
  const _backfilllogger = require("backfill-logger");
24
+ const _CredentialCache = require("./CredentialCache.js");
24
25
  function _getRequireWildcardCache(nodeInterop) {
25
26
  if (typeof WeakMap !== "function") return null;
26
27
  var cacheBabelInterop = new WeakMap();
@@ -79,9 +80,18 @@ function createBackfillLogger() {
79
80
  }
80
81
  function createBackfillCacheConfig(cwd, cacheOptions = {}, backfillLogger) {
81
82
  const envConfig = (0, _backfillconfig.getEnvConfig)(backfillLogger);
82
- return {
83
+ const mergedConfig = {
83
84
  ...(0, _backfillconfig.createDefaultConfig)(cwd),
84
85
  ...cacheOptions,
85
86
  ...envConfig
86
87
  };
88
+ if (mergedConfig.cacheStorageConfig.provider === "azure-blob") {
89
+ if (mergedConfig.cacheStorageConfig.options.connectionString && !isTokenConnectionString(mergedConfig.cacheStorageConfig.options.connectionString)) {
90
+ mergedConfig.cacheStorageConfig.options.credential = _CredentialCache.CredentialCache.getInstance();
91
+ }
92
+ }
93
+ return mergedConfig;
94
+ }
95
+ function isTokenConnectionString(connectionString) {
96
+ return connectionString.includes("SharedAccessSignature");
87
97
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lage-run/cache",
3
- "version": "1.1.7",
3
+ "version": "1.2.0",
4
4
  "description": "Cache for Lage",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,6 +17,7 @@
17
17
  "lint": "monorepo-scripts lint"
18
18
  },
19
19
  "dependencies": {
20
+ "@azure/identity": "^4.0.1",
20
21
  "@lage-run/target-graph": "^0.8.9",
21
22
  "@lage-run/logger": "^1.3.0",
22
23
  "backfill-cache": "5.8.0",