provision to add custom attribute in fields

Registered by Kushal Agrawal

Provision to provide custom attributes to artifact type field

- Why we want to add this feature? The drive to make the change:

Currently only few predefined attributes can be configured as part of field definition. these are :
 nullable, default, mutable, required_on_activate, system, sortable

But if we need any other custom attributes to be predefined as part of field definition it is not possible as of now.

- Solution: providing custom attribtue option as part of field definition

- how: <More technical details than the high level overview of `solution` if needed.>

there are currently 2 options to provide this feature :

1. add a attribute named "custom_attribute"/"additional_attribute" of Dictionary type. which will hold all the custom_attributes related to field. As it below example "custom_attributes" is holding all excess annotations.

Ex : 'source_url': Field(fields.StringField, validators=[validators.Regex(_allowed_url_pattern)],
                            description="URL where the data for this image already resides."
                                        "Eg: http://yum.cloud-band.com/Installs/Templates/tiny/tinycentos.qcow2",
                            custom_attributes={'ui_help_key':'PACKAGE.HELP_MESSAGES.IMAGE.SOURCE_URL', 'display_name':"Source URL"}),

2. Add all attributes in linear way. without defining it inside a map. But there is a limitation that all custom field attributes has to be defined after all glare defined attribtues.

Ex : 'source_url': Field(fields.StringField, validators=[validators.Regex(_allowed_url_pattern)],
                            description="URL where the data for this image already resides."
                                        "Eg: http://yum.cloud-band.com/Installs/Templates/tiny/tinycentos.qcow2",
                            ui_help_key='PACKAGE.HELP_MESSAGES.IMAGE.SOURCE_URL', display_name="Source URL")

 DB prespective: As these are static field changes, There are no database changes required.

APIs prespective: It does not affect any API.

- impacts:
   Schema API: It will update field schema definition.

- How to use this feature from client prespective: <Cli usage example/story> :
  Based on the option we choose, we can define custom attribtues in same way as provided example above.

Blueprint information

Status:
Complete
Approver:
Moshe Elisha
Priority:
Undefined
Drafter:
Kushal Agrawal
Direction:
Needs approval
Assignee:
Kushal Agrawal
Definition:
Approved
Series goal:
Proposed for trunk
Implementation:
Implemented
Milestone target:
None
Started by
Kushal Agrawal
Completed by
Kushal Agrawal

Related branches

Sprints

Whiteboard

I like the first option better. I would suggest to rename "custom_attributes" to "metadata"

(Idan):
1. What's the motivation for this blueprint - Did we encounter such need somewhere?
2. So the first option suggest to add "metadata" field for every artifact?
3. Why can't we let the user create new artifact type by his needs?

(kushal)
1. Yes, while providing the help text for image_reference artifact we needed it as part of "/schema" response.
2. No, this will always be optional.
3. Yes, we will not be changing anything in BaseArtifact but it will provide an option to other artifactType writers.

Gerrit topic: https://review.openstack.org/#q,topic:bp/field-custom-attribute,n,z

Addressed by: https://review.openstack.org/580147
    field custom metadata

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.