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

(CONT-675) Fix fact detection #96

Merged
merged 1 commit into from
Feb 28, 2023
Merged

Conversation

chelnak
Copy link

@chelnak chelnak commented Feb 28, 2023

Prior to this change the legacy facts check would not detect legacy facts defined as follows:

$::facts['osfamily']

This changes updates the check logic to evaluate tokens that may start with :: and extract the fact name as appropriate. `

@chelnak chelnak added the bug Something isn't working label Feb 28, 2023
@chelnak chelnak requested a review from a team as a code owner February 28, 2023 13:23
@chelnak chelnak self-assigned this Feb 28, 2023
@chelnak chelnak force-pushed the CONT-675-fix_fact_detection branch from 9e304eb to 05aa8f6 Compare February 28, 2023 13:23
@chelnak chelnak force-pushed the CONT-675-fix_fact_detection branch from 05aa8f6 to e3815ce Compare February 28, 2023 13:31
end

it 'uses the facts hash' do
expect(manifest).to eq("$facts['os']['family']")
Copy link
Collaborator

Choose a reason for hiding this comment

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

in the future we should consider reworking the legacy_fact/topscope_fact/topscope_variable check because they heavily overlap.

Copy link
Collaborator

Choose a reason for hiding this comment

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

would it make sense to add some tests from https://github.com/puppetlabs/puppet-lint/blob/e3815cebdfa50100acb888e29fde8f03f4e1879b/spec/unit/puppet-lint/plugins/top_scope_facts/top_scope_facts_spec.rb here? But expect no changes? I want to prevent that legacy_fact and topscope_fact fix the same code.

Copy link
Author

Choose a reason for hiding this comment

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

I was looking in to this yesterday. It would seem that they no longer clash but adding extra tests is never a bad thing.

Prior to this change the legacy facts check would not detect legacy
facts defined as follows:

```
$::facts['osfamily']
````

This changes updates the `check` logic to evaluate tokens that may start
with `::` and extract the fact name as appropriate.
`
@chelnak chelnak force-pushed the CONT-675-fix_fact_detection branch from e3815ce to a3b7241 Compare February 28, 2023 13:46
Copy link

@GSPatton GSPatton 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. Tested locally and works as expetced

@GSPatton GSPatton merged commit e8e40f1 into main Feb 28, 2023
@GSPatton GSPatton deleted the CONT-675-fix_fact_detection branch February 28, 2023 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants