backend-app-api: remove unique producer constraint from dependency tree
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -24,17 +24,6 @@ describe('DependencyTree', () => {
|
||||
expect(empty.detectCircularDependency()).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should reject multiple producers', () => {
|
||||
expect(() =>
|
||||
DependencyTree.fromMap({
|
||||
1: { produces: ['a'] },
|
||||
2: { produces: ['a'] },
|
||||
}),
|
||||
).toThrow(
|
||||
"Dependency conflict detected, 'a' may not be produced by both '1' and '2'",
|
||||
);
|
||||
});
|
||||
|
||||
it('should detect circular dependencies', () => {
|
||||
expect(
|
||||
DependencyTree.fromMap({
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ConflictError, ForwardedError, InputError } from '@backstage/errors';
|
||||
import { ForwardedError, InputError } from '@backstage/errors';
|
||||
|
||||
interface NodeInput {
|
||||
id: string;
|
||||
@@ -62,26 +62,16 @@ export class DependencyTree {
|
||||
|
||||
#allProduced: Set<string>;
|
||||
#allConsumed: Set<string>;
|
||||
#producedBy: Map<string, string>;
|
||||
#consumedBy: Map<string, Set<string>>;
|
||||
|
||||
private constructor(readonly nodes: Map<string, Node>) {
|
||||
this.#allProduced = new Set();
|
||||
this.#allConsumed = new Set();
|
||||
this.#producedBy = new Map();
|
||||
this.#consumedBy = new Map();
|
||||
|
||||
for (const node of this.nodes.values()) {
|
||||
for (const produced of node.produces) {
|
||||
this.#allProduced.add(produced);
|
||||
if (this.#producedBy.has(produced)) {
|
||||
throw new ConflictError(
|
||||
`Dependency conflict detected, '${produced}' may not be produced by both '${this.#producedBy.get(
|
||||
produced,
|
||||
)}' and '${node.id}'`,
|
||||
);
|
||||
}
|
||||
this.#producedBy.set(produced, node.id);
|
||||
}
|
||||
for (const consumed of node.consumes) {
|
||||
this.#allConsumed.add(consumed);
|
||||
|
||||
Reference in New Issue
Block a user