Skip to content

bug: Infrahubctl protocols doesn't support all attribute kind #57

@BaptisteGi

Description

@BaptisteGi

Component

Python SDK, infrahubctl

Infrahub SDK version

0.14

Current Behavior

When I try to generate protocols for my schema it fails if my schema contains node with attributes of certain kind.

Expected Behavior

I expect my command to pass and generate protocols

Steps to Reproduce

  • invoke demo.stop demo.destroy demo.build demo.start
  • load the following schema
version: "1.0"

nodes:
  - name: FullAttributesNode
    namespace: Example
    description: "Node with all possible attribute kinds"
    attributes:
      - name: identifier
        kind: ID
      - name: text_attribute
        kind: Text
      - name: text_area_attribute
        kind: TextArea
      - name: datetime_attribute
        kind: DateTime
      - name: email_attribute
        kind: Email
      - name: password_attribute
        kind: Password
      - name: hashed_password_attribute
        kind: HashedPassword
      - name: url_attribute
        kind: URL
      - name: file_attribute
        kind: File
      - name: mac_address_attribute
        kind: MacAddress
      - name: color_attribute
        kind: Color
      - name: number_attribute
        kind: Number
      - name: bandwidth_attribute
        kind: Bandwidth
      - name: ip_host_attribute
        kind: IPHost
      - name: ip_network_attribute
        kind: IPNetwork
      - name: boolean_attribute
        kind: Boolean
      - name: checkbox_attribute
        kind: Checkbox
      - name: list_attribute
        kind: List
      - name: json_attribute
        kind: JSON
      - name: any_attribute
        kind: Any
      - name: dropdown_attribute
        kind: Dropdown
        choices:
          - name: option_1
            label: Option 1
            color: "#7fbf7f"
          - name: option_2
            label: Option 2
            color: "#ffff7f"
  • Then run infrahubctl protocols

Additional Information

So far are not supported:

  • Bandwidth
  • Color
  • Checkbox
  • ID
  • Email
  • MacAddress
  • File
  • Any

Seems to be missing in this map: https://github.com/opsmill/infrahub-sdk-python/blob/develop/infrahub_sdk/code_generator.py#L71

This is the error returned by the command:

infrahub-py3.12➜  infrahub git:(develop) ✗ infrahubctl protocols --branch main                
Error: 'email'
Traceback (most recent call last):
  File "/Users/Baptiste/Workspaces/Infrahub/infrahub/python_sdk/infrahub_sdk/ctl/utils.py", line 89, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/Baptiste/Workspaces/Infrahub/infrahub/python_sdk/infrahub_sdk/ctl/cli_commands.py", line 356, in protocols
    write_to_file(output_file, code_generator.render(sync=sync))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/Baptiste/Workspaces/Infrahub/infrahub/python_sdk/infrahub_sdk/code_generator.py", line 53, in render
    return template.render(
           ^^^^^^^^^^^^^^^^
  File "/Users/Baptiste/Library/Caches/pypoetry/virtualenvs/infrahub-6p6-ZiP_-py3.12/lib/python3.12/site-packages/jinja2/environment.py", line 1304, in render
    self.environment.handle_exception()
  File "/Users/Baptiste/Library/Caches/pypoetry/virtualenvs/infrahub-6p6-ZiP_-py3.12/lib/python3.12/site-packages/jinja2/environment.py", line 939, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 73, in top-level template code
  File "/Users/Baptiste/Workspaces/Infrahub/infrahub/python_sdk/infrahub_sdk/code_generator.py", line 90, in _jinja2_filter_render_attribute
    attribute_kind = attribute_kind_map
                     ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
KeyError: 'email'

Metadata

Metadata

Assignees

Labels

type/bugSomething isn't working as expected

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions