Fix legacy Facts#790
Conversation
chouetz
left a comment
There was a problem hiding this comment.
Will trigger the CI before final approval
| @@ -7,6 +7,7 @@ | |||
| let(:facts) do | |||
| { | |||
| ipaddress: '1.2.3.4', | |||
There was a problem hiding this comment.
Eventually this should be removed, correct?
And the same for other spec files.
There was a problem hiding this comment.
I planned to remove the legacy Facts from the Rspec-Tests, as soon as the Tests succeed. But currently they don't.
Honestly, I don't know, whats wrong. In my own Projects I am used to use the Facts from the Gem facterdb like so:
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }
it { is_expected.to compile.with_all_deps }
end
end
os_facts comes out of facterdb.
on_supported_os.each iterates over all OS-Releases stated in metadata.json. So you don't have to specify the Facts yourself for each OS's Context.
But here, the Tests are designed differently, which leaves me a bit lost…
Perhaps you find the Problem. I am a bit short of Time right now.
I invested an Amount of Time in this Module. More PRs are already prepared:
- migrate to PDK 3 with most recent Version of PDK-Templates
- fix all the Linters' Complaints
There was a problem hiding this comment.
@cocker-cc the CI errors are fixed on #791.
You can do the updates or cherry-pick my commits (the second one is merge of main branch because there were additional errors see #793) to be able to merge you PR
Many thanks in advance
There was a problem hiding this comment.
Wow, that's cool. I cherry-picked, rebased against main and force-pushed. Checks seem okay now.
There was a problem hiding this comment.
I'd like to remove the legacy Facts from the Rspec-Tests now in the next Step.
There was a problem hiding this comment.
you can maybe remove in a next PR, seems it raises new errors :/
|
I think I understand the failures in CI: |
ff79961 to
45b5af4
Compare
Since Puppet 4 “structured Facts” are available. The “non-strucured Facts” are legacy and deprecated. So this Commit is a Fix for that. The legacy Facts are kept in Rspec-Tests for now, but can be deleted in near Future.
fb62320 to
64269e3
Compare
64269e3 to
393b900
Compare
|
Please don't squash, when merging. |
| operatingsystem: 'CentOS', | ||
| osfamily: 'redhat', | ||
| facts_array: ['one', 'two'], | ||
| osfamily: 'redhat', |
There was a problem hiding this comment.
| osfamily: 'redhat', |
You probably missed this one
There was a problem hiding this comment.
Actually not. The Test fails in this Case.
If I specify…
facts_to_tags: ['os.family', 'facts_array'],
… then datadog_agent::tag5 tries to find it via…
$value = getvar($tag_name)
… and $os.family does not exist, in Contrast to getvar('facts.os.family'). (see getvar())
But there could be Help: stdlib got a Function called fact(). So this could be changed to…
if $lookup_fact {
$value = fact($tag_name)
… but not in this Change.
It's the repository policy, can I ask you why you require this? The change is pretty uniform. |
Even though I find this Policy stupid, for God's Sake then let it squash. |
Since Puppet 4 “structured Facts” are available.
The “non-strucured Facts” are legacy and deprecated. So this Commit is a Fix for that.
The legacy Facts are kept in Rspec-Tests for now, but can be deleted in near Future.