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

Use data types instead of validate functions #163

Merged
merged 1 commit into from
Mar 15, 2019

Conversation

alexjfisher
Copy link
Member

This is a breaking change as several parameters now only accept integers
instead of strings.

Fixes #159

String[1] $virtual_server,
Stdlib::IP::Address $ip_address,
Stdlib::Port $port,
Hash $options = {},
Copy link
Member

Choose a reason for hiding this comment

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

Looking at https://github.com/voxpupuli/puppet-keepalived/blob/master/templates/_format_options.erb it looks like we can have a defined type type Keepalived::Options = Hash[String, Variant[Hash, String, Boolean]]. Technically the latter Hash is a Keepalived::Options but I don't know if Puppet supports recursive types.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it'd need to be
Keepalived::Options = Hash[String, Variant[Hash, String, Boolean, Integer]]

Not sure it's worth it.

Copy link
Member

Choose a reason for hiding this comment

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

Hash[String, Any] then?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, ok. I'd imagine 90% of the times where we're currently using Hash we could use this instead. It's probably quite rare to use anything other than a string as the hash key.

The primary aim of this PR was just to get rid of the validate functions. There are a few classes that still have no types at all.

@alexjfisher alexjfisher changed the title Use data types instead of validate functions WIP: Use data types instead of validate functions Mar 15, 2019
Stdlib::Filemode $config_dir_mode = $keepalived::params::config_dir_mode,
Stdlib::Filemode $config_file_mode = $keepalived::params::config_file_mode,

String[1] $config_group = $keepalived::params::config_group,
Copy link
Member

@Dan33l Dan33l Mar 15, 2019

Choose a reason for hiding this comment

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

Why not Variant[String[1], Integer] ? This will permit to use GID also .

Copy link
Member Author

Choose a reason for hiding this comment

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

It might be very rare anyone wants to do this and GID as a string does already work. Dunno if it just complicates the type with no real benefit.

Copy link
Member

Choose a reason for hiding this comment

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

I am thinking about this because with root i always use 0.
But i am fine also with KIS.

@alexjfisher alexjfisher force-pushed the remove_validate branch 3 times, most recently from 9d6539d to 79a878e Compare March 15, 2019 13:41
@alexjfisher alexjfisher changed the title WIP: Use data types instead of validate functions Use data types instead of validate functions Mar 15, 2019
@alexjfisher
Copy link
Member Author

I'll merge #162 first (after it goes green), then rebase this.

This is a breaking change as several parameters now only accept integers
instead of strings.

Fixes voxpupuli#159
@alexjfisher alexjfisher merged commit 1bef40a into voxpupuli:master Mar 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants