Merge branch 'master' of https://github.com/spotify/backstage into lintMod

This commit is contained in:
Debajyoti Halder
2021-01-29 14:05:27 +05:30
244 changed files with 4425 additions and 1286 deletions
+18
View File
@@ -1,5 +1,23 @@
# @backstage/config-loader
## 0.5.0
### Minor Changes
- ef7957be4: Removed support for the deprecated `$data` placeholder.
- ef7957be4: Enable further processing of configuration files included using the `$include` placeholder. Meaning that for example for example `$env` includes will be processed as usual in included files.
### Patch Changes
- ef7957be4: Added support for environment variable substitutions in string configuration values using a `${VAR}` placeholder. All environment variables must be available, or the entire expression will be evaluated to `undefined`. To escape a substitution, use `${...}`, which will end up as `${...}`.
For example:
```yaml
app:
baseUrl: https://${BASE_HOST}
```
## 0.4.1
### Patch Changes
+2 -2
View File
@@ -1,7 +1,7 @@
{
"name": "@backstage/config-loader",
"description": "Config loading functionality used by Backstage backend, and CLI",
"version": "0.4.1",
"version": "0.5.0",
"private": false,
"publishConfig": {
"access": "public",
@@ -32,7 +32,7 @@
"dependencies": {
"@backstage/cli-common": "^0.1.1",
"@backstage/config": "^0.1.1",
"ajv": "^6.12.5",
"ajv": "^7.0.3",
"fs-extra": "^9.0.0",
"json-schema": "^0.2.5",
"json-schema-merge-allof": "^0.7.0",
@@ -29,11 +29,11 @@ describe('compileConfigSchemas', () => {
},
]);
expect(validate([{ data: { a: 1 }, context: 'test' }])).toEqual({
errors: ['Config should be string { type=string } at .a'],
errors: ['Config should be string { type=string } at /a'],
visibilityByPath: new Map(),
});
expect(validate([{ data: { b: 'b' }, context: 'test' }])).toEqual({
errors: ['Config should be number { type=number } at .b'],
errors: ['Config should be number { type=number } at /b'],
visibilityByPath: new Map(),
});
});
@@ -80,10 +80,10 @@ describe('compileConfigSchemas', () => {
).toEqual({
visibilityByPath: new Map(
Object.entries({
'.a': 'frontend',
'.b': 'secret',
'.d': 'secret',
'.d.0': 'frontend',
'/a': 'frontend',
'/b': 'secret',
'/d': 'secret',
'/d/0': 'frontend',
}),
),
});
@@ -42,23 +42,25 @@ export function compileConfigSchemas(
const ajv = new Ajv({
allErrors: true,
allowUnionTypes: true,
schemas: {
'https://backstage.io/schema/config-v1': true,
},
}).addKeyword('visibility', {
}).addKeyword({
keyword: 'visibility',
metaSchema: {
type: 'string',
enum: CONFIG_VISIBILITIES,
},
compile(visibility: ConfigVisibility) {
return (_data, dataPath) => {
if (!dataPath) {
return (_data, context) => {
if (context?.dataPath === undefined) {
return false;
}
if (visibility && visibility !== 'backend') {
const normalizedPath = dataPath.replace(
const normalizedPath = context.dataPath.replace(
/\['?(.*?)'?\]/g,
(_, segment) => `.${segment}`,
(_, segment) => `/${segment}`,
);
visibilityByPath.set(normalizedPath, visibility);
}
@@ -40,24 +40,24 @@ const data = {
const visibility = new Map<string, ConfigVisibility>(
Object.entries({
'.arr.0': 'frontend',
'.arr.1': 'backend',
'.arr.2': 'secret',
'.obj.f': 'frontend',
'.obj.b': 'backend',
'.obj.b.s': 'secret',
'.objArr.0.f': 'frontend',
'.objArr.0.b': 'backend',
'.objArr.0.s': 'secret',
'.objArr.1.f': 'frontend',
'.objArr.1.b': 'backend',
'.objArr.1.s': 'secret',
'.arrF': 'frontend',
'.arrB': 'backend',
'.arrS': 'secret',
'.objF': 'frontend',
'.objB': 'backend',
'.objS': 'secret',
'/arr/0': 'frontend',
'/arr/1': 'backend',
'/arr/2': 'secret',
'/obj/f': 'frontend',
'/obj/b': 'backend',
'/obj/b/s': 'secret',
'/objArr/0/f': 'frontend',
'/objArr/0/b': 'backend',
'/objArr/0/s': 'secret',
'/objArr/1/f': 'frontend',
'/objArr/1/b': 'backend',
'/objArr/1/s': 'secret',
'/arrF': 'frontend',
'/arrB': 'backend',
'/arrS': 'secret',
'/objF': 'frontend',
'/objB': 'backend',
'/objS': 'secret',
}),
);
@@ -49,7 +49,7 @@ export function filterByVisibility(
const arr = new Array<JsonValue>();
for (const [index, value] of jsonVal.entries()) {
const out = transform(value, `${path}.${index}`);
const out = transform(value, `${path}/${index}`);
if (out !== undefined) {
arr.push(out);
}
@@ -68,7 +68,7 @@ export function filterByVisibility(
if (value === undefined) {
continue;
}
const out = transform(value, `${path}.${key}`);
const out = transform(value, `${path}/${key}`);
if (out !== undefined) {
outObj[key] = out;
hasOutput = true;
@@ -85,7 +85,7 @@ describe('loadConfigSchema', () => {
expect(() =>
schema2.process([...configs, { data: { key1: 3 }, context: 'test2' }]),
).toThrow(
'Config validation failed, Config should be string { type=string } at .key1',
'Config validation failed, Config should be string { type=string } at /key1',
);
await expect(