Skip to content

Fix fqdn_rand_string regression#1367

Merged
jordanbreen28 merged 1 commit intopuppetlabs:mainfrom
alexjfisher:fix_fqdn_rand_string_regression
Jun 12, 2023
Merged

Fix fqdn_rand_string regression#1367
jordanbreen28 merged 1 commit intopuppetlabs:mainfrom
alexjfisher:fix_fqdn_rand_string_regression

Conversation

@alexjfisher
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
deric added a commit to deric/puppet-pgprobackup that referenced this pull request Jun 21, 2024
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.

4 participants