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

feat!: update data type in ResourceProperties #809

Merged
merged 1 commit into from
Mar 9, 2023
Merged

feat!: update data type in ResourceProperties #809

merged 1 commit into from
Mar 9, 2023

Conversation

chr1shung
Copy link

@chr1shung chr1shung commented Feb 22, 2023

BREAKING CHANGE: update mask,shift,base,scale,offset to numeric data type

also rename 'Others' to 'Optional' for the consistency with message broker settings.

closes #770

If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/go-mod-core-contracts/blob/main/.github/Contributing.md

PR Checklist

Please check if your PR fulfills the following requirements:

  • I am not introducing a breaking change (if you are, flag in conventional commit message with BREAKING CHANGE: describing the break)
  • I am not introducing a new dependency (add notes below if you are)
  • I have added unit tests for the new feature or bug fix (if not, why?)
  • I have fully tested (add details below) this the new feature or bug fix (if not, why?)
  • I have opened a PR for the related docs change (if not, why?)

Testing Instructions

New Dependency Instructions (If applicable)

@codecov-commenter
Copy link

codecov-commenter commented Feb 22, 2023

Codecov Report

Merging #809 (9353c25) into main (7d700bc) will not change coverage.
The diff coverage is 50.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@           Coverage Diff           @@
##             main     #809   +/-   ##
=======================================
  Coverage   64.60%   64.60%           
=======================================
  Files          80       80           
  Lines        3099     3099           
=======================================
  Hits         2002     2002           
  Misses        908      908           
  Partials      189      189           
Impacted Files Coverage Δ
dtos/resourceproperties.go 50.00% <50.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

dtos/deviceprofile_test.go Outdated Show resolved Hide resolved
BREAKING CHANGE: update mask,shift,base,scale,offset to numeric data type

also rename 'Others' to 'Optional' for the consistency with
message broker settings.

closes #770

Signed-off-by: Chris Hung <chris@iotechsys.com>
Copy link
Member

@lenny-goodell lenny-goodell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@iain-anderson iain-anderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use json.Number for scale, offset and base - so that they can be integer or float?

@chr1shung
Copy link
Author

chr1shung commented Mar 1, 2023

Can we use json.Number for scale, offset and base - so that they can be integer or float?

json.Number is alias of string which provides useful methods to transform value to numeric data type.
But there still will be error in the same place if user provides illegal value:
https://github.com/edgexfoundry/device-sdk-go/blob/b46b419fd49731d0deb4deed8e6127ef6a42900c/internal/transformer/transformresult.go#L92-L93

Using float64 directly can avoid the error during device profile creation but it's a breaking change.

Another way to improve this is to use json.Number for these properties, but leverage validator to check the type.
For example https://pkg.go.dev/github.com/go-playground/validator/v10#hdr-Numeric for base, scale and offset.
But we might need to implement custom tag for mask(uint) and shift(int)

@lenny-intel @cloudxxx8 @iain-anderson thought ?

@cloudxxx8
Copy link
Member

@iain-anderson is it ok?

@iain-anderson
Copy link
Member

OK with this as is

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.

[EdgeX 3.0] Device Profile model improvement
5 participants