Skip to content

Top level attribute definition in a devfile #239

Closed
@elsony

Description

@elsony

The existing devfile does not have a way to define global attributes. If there are some values that I wanted to reuse in different sections of the devfile, I need to repeat those values in various places within a devfile.

Sample use case:
I wanted to create a couple of maven stacks and all of them have pretty much the same content except that the commands/images will make use of a different version of java. If I can define global attributes in a devfile, I can use the attribute key in places where I need to reference the java version, e.g. image path, commands, etc. Then, I can just have a single parent for those maven stacks and each child devfile of them just override the java version attribute in the devfile to provide the specific java version behaviour in different stacks.

Proposal:

  1. Define attributes as a map of implementation-dependent free-form YAML attributes on the top level in a devfile.
  2. Use {{attribute-name}} to refer to the attribute with the key attribute-name
  3. To the implementation simple and avoiding to the need introducing hierarchy path on attribute reference, only attributes on the top level can be resolved within a devfile. Attributes defined on other levels, e.g. attributes defined under a command, cannot be resolved.

Example:
This example defines a global attribute java version number on the top level and references the value of the variable in the container image field.

schemaVersion: 2.0.0
metadata:
  name: java-maven
  version: 1.1.1
attributes:
  javaVersion: 11
components:
  - name: tools
    container:
      image: quay.io/eclipse/che-java{{javaVersion}}-maven:nightly
...

Note: Using this mechanism, we can also address the requirement #149 where each container can refer to the global attribute value and add the required environment variables in the container definition.

Metadata

Metadata

Assignees

Labels

area/apiEnhancement or issue related to the api/devfile specificationarea/documentationImprovements or additions to documentation

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions