onecommons / unfurl

A command line tool for deploying services and applications using git.
https://docs.unfurl.run
MIT License
98 stars 14 forks source link

Metadata at Artifact Types #340

Open milesstoetzner opened 1 month ago

milesstoetzner commented 1 month ago

Does Unfurl support modeling metadata at artifact types?

From my understanding, an artifact type is an entity type and, hence, should support metadata. However, Unfurl seems not to support this.

Here is a simple example with a custom artifact type my_artifact_type , which has the metadata key assigned.

apiVersion: unfurl/v1alpha1
kind: Ensemble
spec:
  service_template:
    artifact_types:
      my_artifact_type:
        derived_from: tosca.artifacts.Root
        metadata:
          key: value

    topology_template:
      node_templates:
        my_app:
          type: tosca.nodes.Root

          interfaces:
            Standard:
              operations:
                create:
                  implementation: Ansible
                  inputs:
                    playbook:
                      q:
                      - shell: exit 1

          artifacts:
            my_artifact:
              type: my_artifact_type
              file: some_value

However, validation fails.

(.venv) stoetzms@storm:~/unfurl-issue$ unfurl validate
   INFO   UNFURL Using home project at: "/home/stoetzms/.unfurl_home/unfurl.yaml"
   INFO   UNFURL Loaded project at /home/stoetzms/unfurl-issue/unfurl.yaml
   INFO   UNFURL Vault password found, configuring vault ids: ['unfurl-issueVM', '.unfurl_homeF0']
   INFO   UNFURL Validating TOSCA template at /home/stoetzms/unfurl-issue/ensemble/ensemble.yaml
Exiting with error: TOSCA validation failed for /home/stoetzms/unfurl-issue/ensemble/ensemble.yaml:
UnknownFieldError: Artifacttype "my_artifact_type" contains unknown field "metadata". Refer to the definition to verify valid values. in node template "my_app"
UnknownFieldError: Artifacttype "my_artifact_type" contains unknown field "metadata". Refer to the definition to verify valid values. in node template "my_app"

I tried this on Unfurl v1.0.0 and v1.1.0.

Best regards Miles

aszs commented 5 days ago

yes, good catch -- i just updated the tosca parser to allow this.

milesstoetzner commented 4 days ago

Great to hear!