Skip to content

Commit

Permalink
Merge branch 'main' into fix-trageted-input
Browse files Browse the repository at this point in the history
  • Loading branch information
milesstoetzner committed Dec 26, 2024
2 parents cdebc6b + 739b6bc commit f09aa05
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 6 deletions.
2 changes: 2 additions & 0 deletions docs/docs/variability4tosca/specification/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,8 @@ A node template can also hold conditional types, artifact, and properties.
| implies | false | List(Tuple(Target: VariabilityCondition, Condition?: VariabilityCondition)) | An optional list of implications following the pattern `element implies target` or `(element and condition) implies target`. |
| technology | false | String | List(Map(String, TechnologyTemplate){single}) | An optional conditional assignment of deployment technologies. |
| managed | false | Boolean | Enable if node is managed (default is true). |
| implied | false | Boolean | Enables that the manual conditions are used to imply the element. |


For example, the following node template has a variability condition assigned.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ topology_template:
The following error is expected to be thrown, when resolving variability.

```text linenums="1"
Node default condition mode "incoming(naive)-host" requires at least one persistent node template
Node default condition mode "incoming(naive)-host" requires at least one persistent or implied node template
```
10 changes: 9 additions & 1 deletion src/enricher/constraints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,17 @@ export class ConstraintEnricher {
* However, the method is still written in a generic way.
*/
private enrichImplications(element: Element) {
if (check.isUndefined(element.container)) return
if (!element.implied) return

// Imply node
if (element.isNode()) {
return this.graph.addConstraint({
implies: [element.manualId, element.id],
})
}

if (check.isUndefined(element.container)) return

let left
if (element.implied === 'TARGET') {
assert.isRelation(element)
Expand Down
1 change: 0 additions & 1 deletion src/enricher/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ export default class Transformer {
delete raw.semantic_pruning

delete raw.default_alternative
delete raw.implied
}

private cleanVariabilityDefinition() {
Expand Down
4 changes: 2 additions & 2 deletions src/graph/populator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ export class Populator {
this.graph.options.default.nodeDefaultConditionMode.includes('incoming') &&
this.graph.options.default.nodeDefaultConditionMode.includes('host')
) {
if (check.isUndefined(this.graph.nodes.find(it => it.persistent)))
if (check.isUndefined(this.graph.nodes.find(it => it.persistent || it.implied)))
throw new Error(
`Node default condition mode "incoming(naive)-host" requires at least one persistent node template`
`Node default condition mode "incoming(naive)-host" requires at least one persistent or implied node template`
)
}
}
Expand Down
1 change: 1 addition & 0 deletions src/resolver/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default class Transformer {
delete raw.conditions
delete raw.weight
delete raw.implies
delete raw.implied
delete raw.technology
delete raw.managed
delete raw.persistent
Expand Down
2 changes: 1 addition & 1 deletion tests/conformance/persistent/persistent-throw/test.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
error: Node default condition mode "incoming(naive)-host" requires at least one persistent node template
error: Node default condition mode "incoming(naive)-host" requires at least one persistent or implied node template
1 change: 1 addition & 0 deletions tests/enricher/conditional/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ topology_template:
_generated: true
- key:
value: VINTNER_UNDEFINED
implied: true
conditions:
- node_presence: target
_generated: true
Expand Down
2 changes: 2 additions & 0 deletions tests/enricher/implied/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ topology_template:
requirements:
- left:
node: left
implied: true
conditions:
- and:
- node_presence: worker
Expand All @@ -77,6 +78,7 @@ topology_template:

- right:
node: right
implied: true
conditions:
- and:
- node_presence: worker
Expand Down
1 change: 1 addition & 0 deletions tests/enricher/map-another/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ topology_template:
conditions: []
- key_one:
value: VINTNER_UNDEFINED
implied: true
conditions:
- node_presence: node_one
_generated: true
Expand Down
2 changes: 2 additions & 0 deletions tests/enricher/mode-03-consistent-loose/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ topology_template:
_generated: true
- tier:
value: VINTNER_UNDEFINED
implied: true
conditions:
- node_presence: virtual_machine
_generated: true
Expand All @@ -88,6 +89,7 @@ topology_template:
_bratan: true
- image:
value: VINTNER_UNDEFINED
implied: true
conditions:
- node_presence: virtual_machine
_generated: true
Expand Down
2 changes: 2 additions & 0 deletions tests/enricher/mode-04-default/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ topology_template:
- node_presence: virtual_machine
- tier:
value: VINTNER_UNDEFINED
implied: true
conditions:
- node_presence: virtual_machine
_generated: true
Expand All @@ -85,6 +86,7 @@ topology_template:
_bratan: true
- image:
value: VINTNER_UNDEFINED
implied: true
conditions:
- node_presence: virtual_machine
_generated: true
Expand Down
2 changes: 2 additions & 0 deletions tests/enricher/mode-05-semantic-strict/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ topology_template:
_generated: true
- tier:
value: VINTNER_UNDEFINED
implied: true
conditions:
- node_presence: virtual_machine
_generated: true
Expand All @@ -88,6 +89,7 @@ topology_template:
_bratan: true
- image:
value: VINTNER_UNDEFINED
implied: true
conditions:
- node_presence: virtual_machine
_generated: true
Expand Down
2 changes: 2 additions & 0 deletions tests/enricher/mode-06-semantic-loose/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ topology_template:
_generated: true
- tier:
value: VINTNER_UNDEFINED
implied: true
conditions:
- node_presence: virtual_machine
_generated: true
Expand All @@ -92,6 +93,7 @@ topology_template:
_bratan: true
- image:
value: VINTNER_UNDEFINED
implied: true
conditions:
- node_presence: virtual_machine
_generated: true
Expand Down

0 comments on commit f09aa05

Please sign in to comment.