Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Device Custom Attributes #205

Merged
merged 8 commits into from
Jun 15, 2022

Conversation

rbino
Copy link
Collaborator

@rbino rbino commented Jun 13, 2022

This PR introduces the concept of Attributes already present in the draft OTA Documentation.

The first kind of attributes implemented are Custom Attributes, which are completely user-defined.

This PR introduces the infrastructure to support attributes both at the database and at the GraphQL level.

A variant type is also introduced at both ends of the solution to support attributes of all types (currently only scalar types, support for arrays will be tracked by this issue.

Generated with:
mix phx.gen.schema Devices.Attribute device_attributes \
  tenant_id:references:tenants device_id:references:devices \
  namespace:enum:custom:other key:string typed_value:map

Copyright headers added after generation, and "custom" value removed from
enum (it was needed because the generator wants at least two values for an enum
field)

Signed-off-by: Riccardo Binetti <[email protected]>
@coveralls
Copy link

coveralls commented Jun 13, 2022

Pull Request Test Coverage Report for Build cb67fdd1c1908bde54fc32193e9f3b0d9e754525-PR-205

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 8 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.7%) to 84.41%

Files with Coverage Reduction New Missed Lines %
lib/edgehog_web/resolvers/astarte.ex 2 96.83%
lib/edgehog_web/schema.ex 6 14.29%
Totals Coverage Status
Change from base Build b1193c26f403132dead6964c1c052e5dcae533af: 0.7%
Covered Lines: 758
Relevant Lines: 898

💛 - Coveralls

@rbino rbino force-pushed the device-custom-attributes branch from 72956e6 to 70d5d08 Compare June 14, 2022 07:04
rbino added 7 commits June 14, 2022 14:36
Allow storing variants in the database

Signed-off-by: Riccardo Binetti <[email protected]>
Use a compound primary key to make cast_assoc work correctly. This way we're not
inserting new attributes everytime and on the other hand we don't need to send
an explicit id.

Signed-off-by: Riccardo Binetti <[email protected]>
Also add relevant tests

Signed-off-by: Riccardo Binetti <[email protected]>
Support variants for input and output in the schema

Signed-off-by: Riccardo Binetti <[email protected]>
Add relevant tests to verify all types are correctly serialized

Signed-off-by: Riccardo Binetti <[email protected]>
Also add relevant tests

Signed-off-by: Riccardo Binetti <[email protected]>
Signed-off-by: Riccardo Binetti <[email protected]>
@rbino rbino force-pushed the device-custom-attributes branch from 70d5d08 to 8ea6a99 Compare June 14, 2022 12:43
@bettio bettio merged commit 4eab2f1 into edgehog-device-manager:main Jun 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants