@balena/contrato
Advanced tools
Comparing version 0.12.1-build-readme-12efc3ca2d44cb959323567f6420911aa5fe19bb-1 to 0.12.1-build-readme-2842fc4c036efeab0be53caec9b5fc496d02c084-1
{ | ||
"name": "@balena/contrato", | ||
"version": "0.12.1-build-readme-12efc3ca2d44cb959323567f6420911aa5fe19bb-1", | ||
"version": "0.12.1-build-readme-2842fc4c036efeab0be53caec9b5fc496d02c084-1", | ||
"description": "The official contract implementation", | ||
@@ -74,4 +74,4 @@ "homepage": "https://github.com/product-os/contrato", | ||
"versionist": { | ||
"publishedAt": "2025-01-17T15:19:55.583Z" | ||
"publishedAt": "2025-01-18T15:26:29.112Z" | ||
} | ||
} |
@@ -45,3 +45,3 @@ # Contrato | ||
The concept of contracts is generic enough that it can be applied to seemingly unrelated scenarios, from base images and OS images, to device types and backend components. Re-using the same contract "format" between them allows us to multiply the gains we get by developing complex contract-related programming modules. | ||
The concept of contracts is generic enough that it can be applied to seemingly unrelated scenarios, from base images and OS images, to device types and backend components. Re-using the same contract syntax between them allows us to multiply the gains we get by developing complex contract-related programming modules. | ||
@@ -117,10 +117,2 @@ ### What can be done with contracts? | ||
"requires": [{ "type": "sw.blob", "slug": "balena-idle" }], | ||
"assets": { | ||
"test": { | ||
"main": "test-os", | ||
"name": "test-os.sh", | ||
"commit": "a95300eda2320833e537ca20d728a870bf02177d", | ||
"url": "https://raw.githubusercontent.com/balena-io-library/base-images/{{this.assets.test.commit}}/scripts/assets/tests/{{this.assets.test.name}}" | ||
} | ||
}, | ||
"variants": [ | ||
@@ -157,7 +149,7 @@ { | ||
See the [contracts specification](balena-contracts.md) for additional documentation on the contract format. | ||
See the [contracts specification](./balena-contracts.md) for additional documentation on the contract format. | ||
## About contrato | ||
Contrato is the Balena contracts implementation. It provides capabilities for searching, comparing, validating and cross referencing contracts, as well as generating combinations of the contracts from a given context (via [blueprints](#blueprints)) and using these combinations to build templates. Some additional description about these features is provided below | ||
Contrato is the Balena contracts implementation. It provides capabilities for searching, comparing, validating and cross referencing contracts, as well as generating combinations of the contracts from a given context (via [blueprints](#blueprints)) and using these combinations to build templates. Some additional description about these features is provided below. | ||
@@ -228,3 +220,3 @@ ### Contract validation | ||
String properties of contracts may reference other number or string properties declared on the same contract by using the this keyword along with handlebars notation. | ||
String properties of contracts may reference other number or string properties declared on the same contract by using the `this` keyword along with handlebars notation. | ||
@@ -250,3 +242,3 @@ For example | ||
The template can be compiled into concrete contracts using the `Contract.build` method in Contrato. | ||
In Contrato, the template can be compiled into concrete contracts using the [Contract.build](https://balena-io.github.io/contrato/classes/contrato.contract.html#build) function. | ||
@@ -264,3 +256,3 @@ ```ts | ||
Contrato provides the `Universe` type for working with a universe of contracts. | ||
Contrato provides the [Universe type](https://balena-io.github.io/contrato/classes/universe.html) for working with a universe of contracts. | ||
@@ -336,3 +328,3 @@ ```ts | ||
Contracts can be rendered with contrato using the `buildTemplate` function | ||
Contracts can be rendered with contrato using the [buildTemplate](https://balena-io.github.io/contrato/modules/contrato.html#buildtemplate) function | ||
@@ -372,9 +364,9 @@ ```ts | ||
The combination section defines the types of contracts that come into play for a particular partials subtree, separated by a `+` symbol. If the combination is sw.os+arch.sw, then it means that the subtree will take into account the combination of operating systems and architectures. Note that there can be combinations of a single type. | ||
The type combination section specifies the types of contracts that come into play for a particular partials subtree, separated by a `+` symbol. If the combination is `sw.os+arch.sw`, then it means that the subtree will take into account the combination of operating systems and architectures. Note that there can be combinations of a single type. | ||
The combination instantiation section defines a subtree for a specific set of contracts that match the combination type. If the combination is `sw.os+arch.sw`, a valid combination instantiation can be `debian+amd64`, which is the subtree that will be selected when matching the Debian GNU/Linux contract with the amd64 architecture contract. | ||
The slug combination section defines a subtree for a specific set of contracts that match the combination type. If the combination is `sw.os+arch.sw`, a valid combination instantiation can be `debian+amd64`, which is the subtree that will be selected when matching the Debian GNU/Linux contract with the amd64 architecture contract. | ||
Note that a combination instantiation may use `@` symbols to define subtrees for a specific version of one or more contracts in the combination. For example, `debian@wheezy+amd64` will be the subtree containing partials for the combination of Debian Wheezy and amd64. | ||
You can also omit trailing portions of the combination instantiation to implement wildcards. If the combination is `sw.os+arch.s`w and the instantiation is `debian`, it means that such subtree will apply to the combination of Debian GNU/Linux with any architecture. | ||
You can also omit trailing portions of the combination instantiation to implement wildcards. If the combination is `sw.os+arch.sw` and the instantiation is `debian`, it means that such subtree will apply to the combination of Debian GNU/Linux with any architecture. | ||
@@ -381,0 +373,0 @@ The partial tree is then traversed from specific to general, until a match is found. This is the path that the contract system will follow when searching for the `download` template on the `sw.os+arch.sw` combination: |
142505
409