-
Notifications
You must be signed in to change notification settings - Fork 70
feat: Enable tedge-config to support a generic mapper/bridge configuration #3835
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
base: main
Are you sure you want to change the base?
feat: Enable tedge-config to support a generic mapper/bridge configuration #3835
Conversation
…ge config macro Signed-off-by: James Rhodes <jarhodes314@gmail.com>
…the tedge config macro Signed-off-by: James Rhodes <jarhodes314@gmail.com>
Signed-off-by: James Rhodes <jarhodes314@gmail.com>
| ty: String, | ||
| }, | ||
| #[tedge_config(multi)] | ||
| mapper: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't fully get what's the plan here.
So a mapper can be given a specific type, but what if want to run 2 mappers on my device.
- Is this setting about a mapper or the mapper?
- How this works in combination with profiles?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've now attempted to clarify this in the PR description. It's about a mapper (#[tedge_config(multi)] is what dictates that, though now we've definitely called the feature in question "profiles", we probably ought to change the attribute to say something more like #[tedge_config(multi_profile)] instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If my understanding is correct we will then be able to configure:
A main c8y mapper:
$ tedge config set mapper.type c8y --profile default
$ tedge config set mapper.c8y.url "my.c8y.com" --profile default
as well as a second c8y mapper:
$ tedge config set mapper.type c8y --profile fallback
$ tedge config set mapper.c8y.url "fallback.c8y.com" --profile fallback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If my understanding is correct
Yes, that is broadly correct, however instead of
$ tedge config set mapper.c8y.url "my.c8y.com" --profile default
it would likely be:
$ tedge config set mapper.url "my.c8y.com" --profile default
as the url is a common configuration to all mappers. The mapper.c8y. would be restricted just to the Cumulocity-specific configurations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though mapper.url would be the new "recommended" config, the old c8y.url setting would still be maintained for backward compatibility, right?
Robot Results
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note about profiles I'm anticipating the mapper configuration to be profiled, however I'm omitting this detail in the example for simplicity. This means profiled mappers would be used like they are today, except that profiles of the mapper group would be used to support multiple cloud types (simultaneously) as well as multiple clouds of the same type.
With this eventual goal in mind, would setting the default c8y.url config look like this?
tedge config set mapper.url "my.c8y.com" --profile c8y
Does it mean that we'll always have to specify the --profile c8y argument for the common settings like url and root_cert_path that don't belong to the C8y::sub_config section?
That UX inconsistency would be a bit weird, where you're trying to configure a single cloud but some are configured with a profile and others aren't.
| ty: String, | ||
| }, | ||
| #[tedge_config(multi)] | ||
| mapper: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though mapper.url would be the new "recommended" config, the old c8y.url setting would still be maintained for backward compatibility, right?
Yes, you would need to specify the profile name, though currently you could just skip using profiles entirely if you only need to connect to a single cloud. That said, I'm inclined to suggest that for this configuration, profiles should be required (and therefore the |
Proposed changes
Allow tedge-config to store a generic configuration which can have a specialised sub configuration. For instance, we currently have configurations like:
With a generalised mapper, it would be useful to de-duplicate these configurations, so we can have something like:
where profiles are used to support the different possible clouds. The changes this PR aims to make would add a new configuration
mapper.type, which could be set toc8yoraz(or another value), and then specialised sub-fields can be added, for instance:Note about profiles I'm anticipating the mapper configuration to be profiled, however I'm omitting this detail in the example for simplicity. This means profiled mappers would be used like they are today, except that profiles of the
mappergroup would be used to support multiple cloud types (simultaneously) as well as multiple clouds of the same type.This
mapper.c8ygroup of configurations would only exist ifmapper.type == "c8y", and we can have other specialised configurations for different clouds (or amapper.type == "custom"where no specialised configuration is applied).Currently this consists of some significant changes to the
define_tedge_configmacro to support this work. At the moment, there is one very small piece of code that isn't generated by the macro, and I haven't added example usage totedge_config.rs, I've only created a separate example file.Usage wise, these changes have two major changes. Firstly, there is a new macro for defining sub configurations:
This is used to define the specialised configuration. It works very much like
define_tedge_config, except it takes a name (in this caseC8y) which is used to namespace the various generated structs and enums (TEdgeConfigDto => C8yDto,ReadableKey => C8yReadableKey).The other change added to the macro usage is the
sub_fieldsattribute:This defines the
mapper.typefield with three possible valid values:c8y,azandcustom. If the type is set toc8y, the mapper group will have theC8yspecialised sub configurations available, e.g.mapper.c8y.enable.log_upload. Similarly foraz, the mapper will have theAzsub configurations.customdoesn't have a specialised configuration, so themappergroup will only have the standard fields, and no "sub-config" will be applied.Types of changes
Paste Link to the issue
Checklist
just prepare-devonce)just formatas mentioned in CODING_GUIDELINESjust checkas mentioned in CODING_GUIDELINESFurther comments