Skip to content

introduce DecodeMapstructure to allow type to define custom decode logic#465

Merged
ndeloof merged 6 commits intocompose-spec:masterfrom
ndeloof:decode_mapstructure
Oct 2, 2023
Merged

introduce DecodeMapstructure to allow type to define custom decode logic#465
ndeloof merged 6 commits intocompose-spec:masterfrom
ndeloof:decode_mapstructure

Conversation

@ndeloof
Copy link
Copy Markdown
Collaborator

@ndeloof ndeloof commented Sep 27, 2023

This introduces a reflexion-based mechanism, comparable to yaml/json Unmarshaler interface, for types to define their own logic to convert value into internal data. This allows to have a single implementation of data type normalization, vs one declared as a mapstructure hook + one declared as a interpolation type cast (even if those redirect to a central func).

This also will make it easier to convert those into plain yaml.Unmarshaler if/once we get the parse+merge logic implemented before converting to go structs

note: only implemented in a few structs, a few more are eligible to this approach

@ndeloof ndeloof force-pushed the decode_mapstructure branch 3 times, most recently from 05d4ae2 to 524c865 Compare September 27, 2023 13:13
@ndeloof ndeloof force-pushed the decode_mapstructure branch 2 times, most recently from 22f9cdc to ef825af Compare September 28, 2023 13:55
Copy link
Copy Markdown
Collaborator

@glours glours left a comment

Choose a reason for hiding this comment

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

👌

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
@ndeloof ndeloof force-pushed the decode_mapstructure branch from a7f2c57 to 54b9780 Compare October 2, 2023 06:53
@ndeloof ndeloof merged commit 2d32c3f into compose-spec:master Oct 2, 2023
@ndeloof ndeloof deleted the decode_mapstructure branch October 2, 2023 08:47
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.

2 participants