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

Fix fqdn_rand_string regression #1367

Merged

Conversation

alexjfisher
Copy link
Collaborator

The function use to be able to accept undef as its second argument.

eg.

fqdn_rand_string(10, undef, 'custom seed')

Using undef to mean 'use the default' is much more conventional than '' (empty string).

This commit restores the old interface broken in 9.0.0

smortex
smortex previously approved these changes Jun 8, 2023
Copy link
Collaborator

@smortex smortex left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines 21 to 23
it { is_expected.to run.with_params(100, nil).and_return(default_charset) }
it { is_expected.to run.with_params(100, nil, 'MY_CUSTOM_SEED').and_return(default_charset) }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we should include these examples a few line bellow to assert that nil and '' as the second parameter produce the same result?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok, can do. Interestingly, undef and empty string use to produce the same result because of this.

(Of Puppet 3 functions)

When functions are called, undef is cast into an empty string. Passing undef to a function is most likely not what you mean to do.

That might explain the history of the way the function was originally coded.

The function use to be able to accept `undef` as its second argument.

eg.
```puppet
fqdn_rand_string(10, undef, 'custom seed')
```

Using `undef` to mean 'use the default' is much more conventional than
`''` (empty string).

This commit restores the old interface broken in `9.0.0`
Copy link
Contributor

@jordanbreen28 jordanbreen28 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the quick fix @alexjfisher

@jordanbreen28 jordanbreen28 merged commit 24a0f21 into puppetlabs:main Jun 12, 2023
44 checks passed
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.

None yet

4 participants