Merge pull request #16212 from AmericanAirlines/allow-hidden-folder-paths

Allow hidden folders to be imported into catalog
This commit is contained in:
Patrik Oldsberg
2023-02-13 22:13:42 +01:00
committed by GitHub
3 changed files with 29 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend': patch
---
Location rule target patterns now also match hidden files, i.e. path components with a leading dot.
@@ -35,6 +35,10 @@ const entity = {
};
const location: Record<string, LocationSpec> = {
v: {
type: 'url',
target: 'https://github.com/b/c/blob/master/.folder/v.yaml',
},
w: {
type: 'url',
target: 'https://github.com/b/c/blob/master/w.yaml',
@@ -263,4 +267,20 @@ describe('DefaultCatalogRulesEnforcer', () => {
expect(enforcer.isAllowed(entity.component, location.z)).toBe(false);
});
});
it('should allow locations with a hidden folder', () => {
const enforcer = DefaultCatalogRulesEnforcer.fromConfig(
new ConfigReader({
catalog: {
rules: [
{
allow: ['Component'],
locations: [{ type: 'url', pattern: 'https://github.com/b/**' }],
},
],
},
}),
);
expect(enforcer.isAllowed(entity.component, location.v)).toBe(true);
});
});
@@ -186,7 +186,10 @@ export class DefaultCatalogRulesEnforcer implements CatalogRulesEnforcer {
}
if (
matcher.pattern &&
!minimatch(location?.target, matcher.pattern, { nocase: true })
!minimatch(location?.target, matcher.pattern, {
nocase: true,
dot: true,
})
) {
continue;
}