|
7 | 7 | os_names = os_support.map { |o| ((o['operatingsystem'] || '').to_s.downcase rescue '') } |
8 | 8 | linux_names = %w[redhat centos oraclelinux scientific sles suse opensuse debian ubuntu rocky almalinux amazon fedora virtuozzolinux gentoo archlinux] |
9 | 9 | has_windows = os_names.include?('windows') |
| 10 | + # Empty/unknown metadata (e.g. a fresh `pdk new module`) defaults to the Linux section. Modules that |
| 11 | + # support only non-Linux, non-Windows platforms (AIX/Solaris/Darwin) render neither OS section and |
| 12 | + # rely on the OS-agnostic guidance above -- rather than being mislabelled as Linux. |
10 | 13 | has_linux = os_names.empty? || os_names.any? { |n| linux_names.include?(n) } |
11 | | - # Guarantee at least one OS section: any non-Windows module (incl. AIX/Solaris/Darwin-only) |
12 | | - # defaults to the Linux content; Windows-only modules stay Windows-only. |
13 | | - has_linux ||= !has_windows |
14 | 14 | -%> |
15 | 15 | # CLAUDE.md |
16 | 16 |
|
17 | 17 | This file provides guidance to Claude Code (claude.ai/code) and human contributors when |
18 | 18 | working with code in this repository. |
19 | 19 |
|
20 | | -> **This file is synced from [puppetlabs/pdk-templates](https://github.com/puppetlabs/pdk-templates) |
21 | | -> (`moduleroot/CLAUDE.md.erb`).** Do not edit it directly in a module repo -- changes are |
22 | | -> overwritten on the next `pdk update`. To customise per module, add module-specific notes via a |
23 | | -> `## Module-specific notes` section in a file PDK does not manage, or opt this file out entirely |
24 | | -> with `CLAUDE.md: unmanaged: true` in the module's `.sync.yml` and maintain a hand-written copy. |
| 20 | +> **Starting point, not a straitjacket.** This file ships from |
| 21 | +> [puppetlabs/pdk-templates](https://github.com/puppetlabs/pdk-templates) as a baseline of conventions |
| 22 | +> common to CAT-supported modules. **Tailor it to this repo** -- add the specifics Claude actually |
| 23 | +> needs: what the manifests/types/providers/functions here do, module-specific gotchas, and anything |
| 24 | +> learned while working in the codebase. A generic framework alone is not enough to guide good changes. |
| 25 | +> |
| 26 | +> PDK adds this file when a module is first created (`pdk new module`, or `pdk convert` for a module |
| 27 | +> that doesn't have one yet) and then leaves it alone -- it is **not** re-synced or overwritten on |
| 28 | +> `pdk update`. It is yours to edit freely; keep it current as the module grows. |
25 | 29 |
|
26 | 30 | For generic Puppet/PDK workflow that *is* derivable from the files themselves (the full PDK command |
27 | 31 | reference, CI matrix mechanics, README badges), see the PDK docs and the README. The notes below are |
@@ -98,6 +102,8 @@ bundle exec rake litmus:acceptance:parallel |
98 | 102 | - Every class/defined type should have `it { is_expected.to compile.with_all_deps }` -- a clean |
99 | 103 | compile across the supported OS matrix is the baseline gate. |
100 | 104 | - Drive OS variants with `on_supported_os` (reads `metadata.json`) rather than hand-listing facts. |
| 105 | +- Facts come largely from **facterdb** (via `rspec-puppet-facts` / `on_supported_os`) -- you rarely |
| 106 | + need to hand-build fact hashes; override only the specific facts a test needs on top of the OS set. |
101 | 107 | - Stub facts via the `:facts` hash or `spec/default_facts.yml`; do not rely on the host's real facts. |
102 | 108 | - Provide Hiera test data through `spec/fixtures/hiera/` and a test `hiera.yaml` when behaviour is |
103 | 109 | data-driven. Use `let(:params)` / `let(:pre_condition)` for class params and dependencies. |
@@ -135,14 +141,17 @@ COVERAGE=yes bundle exec rspec # SimpleCov report |
135 | 141 | ### Spec helpers |
136 | 142 |
|
137 | 143 | - `spec/spec_helper.rb` is **PDK-managed -- do not edit**; it is overwritten on `pdk update`. |
138 | | -- Put project-local setup in `spec/spec_helper_local.rb` (safe to edit). |
| 144 | +- Put project-local unit setup in `spec/spec_helper_local.rb` (safe to edit). |
| 145 | +- `spec/spec_helper_acceptance.rb` (+ `spec/spec_helper_acceptance_local.rb`) drives the Litmus |
| 146 | + acceptance run; put acceptance-only helpers there, not in the unit spec helper. |
139 | 147 |
|
140 | 148 | --- |
141 | 149 |
|
142 | 150 | ## Ruby code style |
143 | 151 |
|
144 | 152 | - Style is enforced by `.rubocop.yml` (deployed from pdk-templates, `strict` profile). Run |
145 | | - `bundle exec rake rubocop` / `rubocop -a` before pushing; do not hand-tune cops in the synced file. |
| 153 | + `bundle exec rake rubocop` (or `bundle exec rubocop -A` to autocorrect) before pushing -- always |
| 154 | + under `bundle exec` so you get the module's pinned RuboCop version; do not hand-tune cops in the synced file. |
146 | 155 | - Conventions the profile enforces: `Layout/LineLength` max 200, `snake_case` naming, `%r{}` for regex |
147 | 156 | literals, trailing commas on multiline arrays/args, and the `rubocop-performance` / `rubocop-rspec` |
148 | 157 | extensions. Target Ruby version follows `.rubocop.yml`'s `TargetRubyVersion`. |
@@ -337,3 +346,7 @@ PRs are judged on outcomes, not line counts: |
337 | 346 | - Never delete a file without permission -- this applies even after a blanket "yes to all". |
338 | 347 | - Never output, log, save, or hardcode security-sensitive values -- passwords, tokens, API keys, |
339 | 348 | private keys, secrets, or credentials of any kind. Do not write them to files, commit messages, or responses. |
| 349 | + |
| 350 | +> These are guidance, not enforcement. For anything that must hold every run (secret hygiene, no |
| 351 | +> direct pushes to `main`, the coverage gate), back it with a runtime hook in the repo's `.claude/` |
| 352 | +> settings -- prose alone can be treated as a suggestion and skipped. |
0 commit comments