Skip to content

Accept YAML input for profile#1209

Merged
2 commits merged intodevelopfrom
unknown repository
Mar 14, 2023
Merged

Accept YAML input for profile#1209
2 commits merged intodevelopfrom
unknown repository

Conversation

@ghost
Copy link

@ghost ghost commented Mar 9, 2023

Purpose

This PR allows to pass the profile as a YAML file.
This is the first step towards replacing the current JSON input format. JSON does not support comments, and it would be nice to provide a profile document that supports comments for values and properties.

Context

Meeting discussion on 2023-03-09.

Changes

  • new from_yaml() and to_yaml() methods in Profile.pm
  • new share/profile.yaml
  • update MANIFEST
  • upgrade script util/json2yaml.pl

How to test this PR

Unit test should pass.

@ghost ghost added this to the v2023.1 milestone Mar 9, 2023
@matsduf
Copy link
Contributor

matsduf commented Mar 9, 2023

Can you add POD documentation for from_yaml() and to_yaml()? Some documentation for json2yaml.pl is needed. Can you add that as POD into the script?

Why is profile.json kept?

I cannot see that profile.yaml is read.

profile_additional_properties.json should also be provided in yaml format, shouldn't it?

sub to_yaml {
my ( $self ) = @_;

return Dump( $self->{q{profile}} );
Copy link
Contributor

Choose a reason for hiding this comment

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

The automatic exports of Dump() and Load() by YAML::XS makes this code slightly confusing, because Dump() sounds like a function that could have been exported by Data::Dumper (which, by the way, does provide a Dump function)…

I suggest changing use YAML::XS; to use YAML::XS qw(); to prevent the automatic exports, then calling the Dump function with its fully-qualified name, YAML::XS::Dump().

Copy link
Author

@ghost ghost Mar 13, 2023

Choose a reason for hiding this comment

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

Good point. I'll provide an update. Update provided.

@ghost
Copy link
Author

ghost commented Mar 13, 2023

Can you add POD documentation for from_yaml() and to_yaml()? Some documentation for json2yaml.pl is needed. Can you add that as POD into the script?

Done.

Why is profile.json kept?
I cannot see that profile.yaml is read.

This PR is about accepting YAML input, not replacing the JSON input.

profile_additional_properties.json should also be provided in yaml format, shouldn't it?

Not necessarily. Since the end goal of using YAML as the input format, is to have only one profile file with commented values, I think this can be left for a future work (when a new unified profile.yaml file is created and used for instance).

@matsduf
Copy link
Contributor

matsduf commented Mar 13, 2023

Can you add POD documentation for from_yaml() and to_yaml()? Some documentation for json2yaml.pl is needed. Can you add that as POD into the script?

Done.

I can see the documentation in Profile.pm. Thanks. Could you provide some documentation for json2yaml.pl too?

Why is profile.json kept?
I cannot see that profile.yaml is read.

This PR is about accepting YAML input, not replacing the JSON input.

I cannot see that the profile.yaml is used. Is it? If not, what is the purpose of it?

profile_additional_properties.json should also be provided in yaml format, shouldn't it?

Not necessarily. Since the end goal of using YAML as the input format, is to have only one profile file with commented values, I think this can be left for a future work (when a new unified profile.yaml file is created and used for instance).

That is fine, but then profile_additional_properties.json should be incorporated in profile.yaml, shouldn't they?

@ghost
Copy link
Author

ghost commented Mar 13, 2023

Could you provide some documentation for json2yaml.pl too?

I forgot to add it. I'll do it. I've added it.

I cannot see that the profile.yaml is used. Is it? If not, what is the purpose of it?

Not yet. Its current purpose is to document how we could use it and start from there.

That is fine, but then profile_additional_properties.json should be incorporated in profile.yaml, shouldn't they?

This is the idea. Nevertheless I'd like to keep this PR about providing the basic methods to deal with a YAML formatted profile.

Copy link
Contributor

@matsduf matsduf left a comment

Choose a reason for hiding this comment

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

I guess this is fine.

Copy link
Contributor

@marc-vanderwal marc-vanderwal left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@ghost ghost merged commit 67726fc into zonemaster:develop Mar 14, 2023
@ghost ghost deleted the yaml-profile branch March 31, 2023 13:10
@matsduf matsduf added V-Minor Versioning: The change gives an update of minor in version. T-Feature Type: New feature in software or test case description labels May 15, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-Feature Type: New feature in software or test case description V-Minor Versioning: The change gives an update of minor in version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants