Update to use the latest Azure SDK (#7)
Update to use the latest Azure SDK Supply user agent prefix Ensure that setting values passed to the SDK are strings as they expect
This commit is contained in:
Родитель
1086a531fd
Коммит
0529ea33c3
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -17,9 +17,9 @@
|
|||
}
|
||||
},
|
||||
"@azure/app-configuration": {
|
||||
"version": "1.0.0-preview.10",
|
||||
"resolved": "https://registry.npmjs.org/@azure/app-configuration/-/app-configuration-1.0.0-preview.10.tgz",
|
||||
"integrity": "sha512-l3sbyAe78w0PoBXMKAM+nzZzkvS1mvdH5W1Ny6BfiSPxs6Bvzpu8BOQHDAJ9WArqFweHJcU3mPthCGQTnLegxQ==",
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@azure/app-configuration/-/app-configuration-1.0.0.tgz",
|
||||
"integrity": "sha512-HsqGXdO3BRswANuVS/6LuahoTf/sfQB8IJhusBPcMEyrsi/elNty/HdZX1v8RH6yqECXknM1YjBY3mxUyL6+UA==",
|
||||
"requires": {
|
||||
"@azure/core-asynciterator-polyfill": "^1.0.0",
|
||||
"@azure/core-http": "^1.0.0",
|
||||
|
@ -27,7 +27,7 @@
|
|||
"@azure/core-tracing": "1.0.0-preview.7",
|
||||
"@azure/identity": "^1.0.0",
|
||||
"@opentelemetry/types": "^0.2.0",
|
||||
"tslib": "^1.9.3"
|
||||
"tslib": "^1.10.0"
|
||||
}
|
||||
},
|
||||
"@azure/core-asynciterator-polyfill": {
|
||||
|
@ -47,9 +47,9 @@
|
|||
}
|
||||
},
|
||||
"@azure/core-http": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@azure/core-http/-/core-http-1.0.2.tgz",
|
||||
"integrity": "sha512-wjtY0Ks0+/4SEcIiMAvXdYvZZpyYj0rgs4dbd1MfgBlXgvvzpDOsPpcvI6ty5pyPBrjAyqrpyQeFud6hqsAnDQ==",
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@azure/core-http/-/core-http-1.0.3.tgz",
|
||||
"integrity": "sha512-hmsalo2i1noF5LMwNBNymJnf210ha7Rh6x+BQBBcb+wUZI5hVGRbaRgHzqpJiH8FmfJrDuKZI+S7i2rILUBJTg==",
|
||||
"requires": {
|
||||
"@azure/abort-controller": "^1.0.0",
|
||||
"@azure/core-auth": "^1.0.0",
|
||||
|
@ -62,7 +62,7 @@
|
|||
"node-fetch": "^2.6.0",
|
||||
"process": "^0.11.10",
|
||||
"tough-cookie": "^3.0.1",
|
||||
"tslib": "^1.9.3",
|
||||
"tslib": "^1.10.0",
|
||||
"tunnel": "^0.0.6",
|
||||
"uuid": "^3.3.2",
|
||||
"xml2js": "^0.4.19"
|
||||
|
@ -1438,6 +1438,7 @@
|
|||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz",
|
||||
"integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"object-keys": "^1.0.12"
|
||||
}
|
||||
|
@ -1569,6 +1570,7 @@
|
|||
"version": "1.16.2",
|
||||
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.16.2.tgz",
|
||||
"integrity": "sha512-jYo/J8XU2emLXl3OLwfwtuFfuF2w6DYPs+xy9ZfVyPkDcrauu6LYrw/q2TyCtrbc/KUdCiC5e9UajRhgNkVopA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"es-to-primitive": "^1.2.1",
|
||||
"function-bind": "^1.1.1",
|
||||
|
@ -1586,6 +1588,7 @@
|
|||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz",
|
||||
"integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-callable": "^1.1.4",
|
||||
"is-date-object": "^1.0.1",
|
||||
|
@ -2637,7 +2640,8 @@
|
|||
"function-bind": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
|
||||
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
|
||||
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
|
||||
"dev": true
|
||||
},
|
||||
"functional-red-black-tree": {
|
||||
"version": "1.0.1",
|
||||
|
@ -2750,6 +2754,7 @@
|
|||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
|
||||
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"function-bind": "^1.1.1"
|
||||
}
|
||||
|
@ -2763,7 +2768,8 @@
|
|||
"has-symbols": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz",
|
||||
"integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg=="
|
||||
"integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==",
|
||||
"dev": true
|
||||
},
|
||||
"has-value": {
|
||||
"version": "1.0.0",
|
||||
|
@ -2959,7 +2965,8 @@
|
|||
"is-callable": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz",
|
||||
"integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA=="
|
||||
"integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==",
|
||||
"dev": true
|
||||
},
|
||||
"is-ci": {
|
||||
"version": "2.0.0",
|
||||
|
@ -2999,7 +3006,8 @@
|
|||
"is-date-object": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz",
|
||||
"integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY="
|
||||
"integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=",
|
||||
"dev": true
|
||||
},
|
||||
"is-descriptor": {
|
||||
"version": "0.1.6",
|
||||
|
@ -3098,6 +3106,7 @@
|
|||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz",
|
||||
"integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"has": "^1.0.1"
|
||||
}
|
||||
|
@ -3112,6 +3121,7 @@
|
|||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz",
|
||||
"integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"has-symbols": "^1.0.1"
|
||||
}
|
||||
|
@ -4230,12 +4240,14 @@
|
|||
"object-inspect": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz",
|
||||
"integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw=="
|
||||
"integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==",
|
||||
"dev": true
|
||||
},
|
||||
"object-keys": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
|
||||
"integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA=="
|
||||
"integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==",
|
||||
"dev": true
|
||||
},
|
||||
"object-visit": {
|
||||
"version": "1.0.1",
|
||||
|
@ -4250,6 +4262,7 @@
|
|||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz",
|
||||
"integrity": "sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"define-properties": "^1.1.2",
|
||||
"es-abstract": "^1.5.1"
|
||||
|
@ -5256,6 +5269,7 @@
|
|||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.0.tgz",
|
||||
"integrity": "sha512-FJ6b7EgdKxxbDxc79cOlok6Afd++TTs5szo+zJTUyow3ycrRfJVE2pq3vcN53XexvKZu/DJMDfeI/qMiZTrjTw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"define-properties": "^1.1.3",
|
||||
"function-bind": "^1.1.1"
|
||||
|
@ -5265,6 +5279,7 @@
|
|||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.0.tgz",
|
||||
"integrity": "sha512-fXZTSV55dNBwv16uw+hh5jkghxSnc5oHq+5K/gXgizHwAvMetdAJlHqqoFC1FSDVPYWLkAKl2cxpUT41sV7nSg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"define-properties": "^1.1.3",
|
||||
"function-bind": "^1.1.1"
|
||||
|
@ -5651,6 +5666,7 @@
|
|||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/util.promisify/-/util.promisify-1.0.0.tgz",
|
||||
"integrity": "sha512-i+6qA2MPhvoKLuxnJNpXAGhg7HphQOSUq2LKMZD0m15EiskXUkMvKdF4Uui0WYeCUGea+o2cw/ZuwehtfsrNkA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"define-properties": "^1.1.2",
|
||||
"object.getownpropertydescriptors": "^2.0.3"
|
||||
|
@ -5842,12 +5858,11 @@
|
|||
"dev": true
|
||||
},
|
||||
"xml2js": {
|
||||
"version": "0.4.22",
|
||||
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.22.tgz",
|
||||
"integrity": "sha512-MWTbxAQqclRSTnehWWe5nMKzI3VmJ8ltiJEco8akcC6j3miOhjjfzKum5sId+CWhfxdOs/1xauYr8/ZDBtQiRw==",
|
||||
"version": "0.4.23",
|
||||
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz",
|
||||
"integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==",
|
||||
"requires": {
|
||||
"sax": ">=0.6.0",
|
||||
"util.promisify": "~1.0.0",
|
||||
"xmlbuilder": "~11.0.0"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.0",
|
||||
"@azure/app-configuration": "^1.0.0-preview.10",
|
||||
"@types/flat": "0.0.28",
|
||||
"@azure/app-configuration": "^1.0.0",
|
||||
"@types/flat": "^0.0.28",
|
||||
"@types/glob": "^7.1.1",
|
||||
"@types/js-yaml": "^3.12.1",
|
||||
"@types/lodash": "^4.14.148",
|
||||
|
|
|
@ -4,6 +4,8 @@ import { AppConfigurationClient, ConfigurationSettingId, SetConfigurationSetting
|
|||
import { getErrorMessage } from './errors';
|
||||
import { Tags } from './input';
|
||||
|
||||
const userAgentPrefix = "GitHub-AppConfiguration-Sync/1.0.0";
|
||||
|
||||
/**
|
||||
* Sync from a config object to a config store
|
||||
*
|
||||
|
@ -15,7 +17,12 @@ import { Tags } from './input';
|
|||
* @param tags Tags applied to the modified settings.
|
||||
*/
|
||||
export async function syncConfig(config: any, connectionString: string, strict: boolean, label?: string, prefix?: string, tags?: Tags): Promise<void> {
|
||||
const client = new AppConfigurationClient(connectionString);
|
||||
const appConfigurationOptions = {
|
||||
userAgentOptions: {
|
||||
userAgentPrefix: userAgentPrefix
|
||||
}
|
||||
};
|
||||
const client = new AppConfigurationClient(connectionString, appConfigurationOptions);
|
||||
|
||||
core.info('Determining which keys to sync');
|
||||
const settingsToAdd = getSettingsToAdd(config, label, prefix, tags);
|
||||
|
@ -50,7 +57,7 @@ function getSettingsToAdd(config: any, label?: string, prefix?: string, tags?: T
|
|||
for (const key in config) {
|
||||
settings.push({
|
||||
key: prefix ? prefix + key : key,
|
||||
value: config[key],
|
||||
value: getSettingValue(config[key]),
|
||||
label: label ? label : undefined,
|
||||
tags: tags ? tags : undefined,
|
||||
});
|
||||
|
@ -59,6 +66,16 @@ function getSettingsToAdd(config: any, label?: string, prefix?: string, tags?: T
|
|||
return settings;
|
||||
}
|
||||
|
||||
function getSettingValue(value: any): string | undefined {
|
||||
if (value === null || value === undefined) {
|
||||
return "";
|
||||
} else if (typeof value === "object") {
|
||||
return JSON.stringify(value);
|
||||
} else {
|
||||
return String(value);
|
||||
}
|
||||
}
|
||||
|
||||
async function getSettingsToDelete(client: AppConfigurationClient, settingsToAdd: SetConfigurationSettingParam[], label?: string, prefix?: string): Promise<ConfigurationSettingId[]> {
|
||||
const settings: ConfigurationSettingId[] = [];
|
||||
const keysToIgnore = new Set(settingsToAdd.map(e => e.key));
|
||||
|
|
|
@ -327,6 +327,37 @@ describe('syncConfig', () => {
|
|||
expect(core.error).toHaveBeenNthCalledWith(1, "Failed to add key 'Key1' with label ''. Status code: 409 Conflict");
|
||||
})
|
||||
|
||||
it('adds settings with different value types ', async () => {
|
||||
let config = {
|
||||
"String": "Value",
|
||||
"Number1": 0,
|
||||
"Number2": 7,
|
||||
"Boolean1": true,
|
||||
"Boolean2": false,
|
||||
"Array": [1, 2, 3],
|
||||
"Object": { "Foo": "Bar" },
|
||||
"Null": null,
|
||||
"Undefined": undefined,
|
||||
};
|
||||
await configstore.syncConfig(config, "connection string", false);
|
||||
|
||||
expect(AppConfigurationClient).toBeCalled();
|
||||
expect(AppConfigurationClient.prototype.listConfigurationSettings).not.toBeCalled();
|
||||
expect(AppConfigurationClient.prototype.deleteConfigurationSetting).not.toBeCalled();
|
||||
expect(AppConfigurationClient.prototype.setConfigurationSetting).toHaveBeenCalledTimes(9);
|
||||
expect(AppConfigurationClient.prototype.setConfigurationSetting).toHaveBeenNthCalledWith(1, { key: "String", value: "Value" });
|
||||
expect(AppConfigurationClient.prototype.setConfigurationSetting).toHaveBeenNthCalledWith(2, { key: "Number1", value: "0" });
|
||||
expect(AppConfigurationClient.prototype.setConfigurationSetting).toHaveBeenNthCalledWith(3, { key: "Number2", value: "7" });
|
||||
expect(AppConfigurationClient.prototype.setConfigurationSetting).toHaveBeenNthCalledWith(4, { key: "Boolean1", value: "true" });
|
||||
expect(AppConfigurationClient.prototype.setConfigurationSetting).toHaveBeenNthCalledWith(5, { key: "Boolean2", value: "false" });
|
||||
expect(AppConfigurationClient.prototype.setConfigurationSetting).toHaveBeenNthCalledWith(6, { key: "Array", value: "[1,2,3]" });
|
||||
expect(AppConfigurationClient.prototype.setConfigurationSetting).toHaveBeenNthCalledWith(7, { key: "Object", value: "{\"Foo\":\"Bar\"}" });
|
||||
expect(AppConfigurationClient.prototype.setConfigurationSetting).toHaveBeenNthCalledWith(8, { key: "Null", value: "" });
|
||||
expect(AppConfigurationClient.prototype.setConfigurationSetting).toHaveBeenNthCalledWith(9, { key: "Undefined", value: "" });
|
||||
expect(core.setFailed).not.toBeCalled();
|
||||
expect(core.error).not.toBeCalled();
|
||||
})
|
||||
|
||||
function setListConfigurationSettingsMock(...configurationSettings: ConfigurationSetting[]) {
|
||||
AppConfigurationClient.prototype.listConfigurationSettings = jest.fn((options?: ListConfigurationSettingsOptions) => {
|
||||
const iter = getConfigurationSettingIterator(configurationSettings);
|
||||
|
|
Загрузка…
Ссылка в новой задаче