Skip to content

Add the FOG settings catalog and a settings read helper - #202

Merged
fog-workflows[bot] merged 1 commit into
masterfrom
factory/issue-198
Nov 17, 2026
Merged

fog-workflows[bot] merged 1 commit into
masterfrom
factory/issue-198

Conversation

@mastacontrola

Copy link
Copy Markdown
Member

I added a settings catalog in code and a read helper, sails.helpers.settings.get(key). The two list-table settings now read through the helper. npm test and npm run test:ui both pass. Both reviewers signed off on the final commit.

What changed

  • config/fog-settings.js (new) exports sails.config.fogSettings. Each entry has category, description, type, options, default, normalize and reload.
    • The comment at the top states the rules for adding a key. A key goes in with the code that reads it. Install-time configuration stays in config/local.js. Secrets never go in. schema is never a key.
    • The catalog has two entries: FOG_TABLE_SCROLL_MODE and FOG_VIEW_DEFAULT_SCREEN. Both are in category FOG View Settings, with reload: true.
    • Each normalize keeps the old reader rule exactly: the same trim, lowercase and /^(-1|[1-9][0-9]*)$/. No stored value changes meaning.
    • The descriptions come from 1.6 schema.php at 98ac5bb732eb, as plain text with the HTML tags removed. Scroll mode uses step 296. Page length uses the repaired text from step 397.
  • api/helpers/settings/get.js (new) reads Setting.findOne({name: key}) and returns normalize(row.value). A missing record or a bad value gives the default. It never creates a record.
    • A key that is not in the catalog throws Unknown setting: <key>.
    • The key check uses Object.hasOwn. Without it, a name like constructor would read an inherited property as a setting.
  • api/helpers/table-settings.js calls sails.helpers.settings.get for both keys. It no longer calls sails.models.setting.findOne itself. The output {scrollMode, pageLength} does not change.
  • test/helpers/settings-catalog.test.js (new) checks the following. The test creates and removes its own Setting record.
    • Both keys are present.
    • Each entry has the full shape.
    • Each default and each select option normalizes to itself.
    • schema is absent.
    • The four get cases from the spec: no record, a good record, a bad record and an unknown key.
    • An inherited name such as constructor is rejected as unknown.

These stay unchanged, as the spec requires:

  • The four other readers: FOG_HOST_IDENTIFY_SMBIOS, FOG_AGENT_ENROLL_DEPLOY_WINDOW, FOG_CLIENT_CHECKIN_TIME and FOG_ENABLE_SHOW_PASSWORDS.
  • FOG_AGENT_ROOT_FINGERPRINT.
  • The schema: the change adds no migration and seeds no record.

Why

Issue #198 asks for one code-side list of the runtime settings. The FOG Configuration page in the next brief renders from this list. migrate: 'safe' forbids seeding rows, so the database holds only the values an admin changed.

Tests

  • npm test: passed. Lint is clean ("Your .js files look good."). 492 tests pass and none fail. All 8 new Settings catalog:: tests pass. The existing table-settings:: tests in test/integration/list-pages.test.js still pass.
  • npm run test:ui: passed: "All UI checks passed." That includes ok ui16-06: FOG 1.6 list tables, which covers paged mode. The run changed no tracked file.
  • Red check: I ran the new test file against base commit ae0b618. All 8 tests failed, because sails.config.fogSettings and sails.helpers.settings do not exist there.

The sandbox blocks GitHub, so the test setup needed three workarounds:

  • Packages: npm ci could not fetch sails-mongo, which installs from GitHub. I copied node_modules from a local clone with the same lockfile. Then I replaced the 5 packages that did not match the lockfile versions with tarballs from the npm registry.
  • Databases: MongoDB 7.0 and Redis 7.4 ran from binaries in the local container image cache. They started and stopped with each run, and no process is left running.
  • Browser: the UI run used the Chromium 1254 build that was already in ~/.cache/ms-playwright.

Reviewer verdicts

  • Spec reviewer (opus):
    • First pass: no defect. It flagged that the test:ui result was still missing; that run now passes. It noted that the spec does not ask for the Object.hasOwn guard; I kept the guard as a correctness fix.
    • Re-review of commit e32b762: clean. Every acceptance criterion is met, with no regression.
  • Standards reviewer (sonnet):
    • First pass: five judgment calls. I applied three:
      • I removed a || {} fallback that hid a missing catalog.
      • The key test now asserts that the two keys are present, not an exact key list.
      • The constructor test now matches the full Unknown setting: constructor message.
    • I kept the other two because the spec requires them: the list of four types, and the explicit schema test. The schema test now reads through the local catalog() helper.
    • Re-review of commit e32b762: clean.

Holdout scenarios: none for this repo.
Tier: normal (opus, effort high).

Closes #198

🤖 Generated with Claude Code

config/fog-settings.js (sails.config.fogSettings) is the one code-side
list of the runtime settings: category, description, type, options,
default, normalize and reload per key. The database holds only the
values an admin changed; fog-node seeds no rows (migrate: 'safe').

sails.helpers.settings.get(key) reads the key's Setting record and
returns normalize(value), or the default for a missing record or a bad
value. It never creates a record. An unknown key throws
"Unknown setting: <key>".

The catalog starts with the two table settings, FOG_TABLE_SCROLL_MODE
and FOG_VIEW_DEFAULT_SCREEN, with their 1.6 descriptions as plain text
and their current reader rules. api/helpers/table-settings.js now reads
both through the helper; its output shape is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fog-workflows
fog-workflows Bot enabled auto-merge November 17, 2026 12:08
@fog-workflows
fog-workflows Bot added this pull request to the merge queue Nov 17, 2026
Merged via the queue into master with commit 1c3235c Nov 17, 2026
6 checks passed
@fog-workflows
fog-workflows Bot deleted the factory/issue-198 branch November 17, 2026 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the FOG settings catalog and a settings read helper

1 participant