Skip to content

Feat/198- Enable sharable predefined templates for hardware#212

Open
DavidWalshe93 wants to merge 4 commits intoTimmoth:mainfrom
DavidWalshe93:feat/198-sharable-predefined-templates
Open

Feat/198- Enable sharable predefined templates for hardware#212
DavidWalshe93 wants to merge 4 commits intoTimmoth:mainfrom
DavidWalshe93:feat/198-sharable-predefined-templates

Conversation

@DavidWalshe93
Copy link
Contributor

@DavidWalshe93 DavidWalshe93 commented Mar 1, 2026

Related to 198

Summary

Implements the hardware template system proposed in #198. Users can now create resources from pre-filled templates (via CLI --template flag or Web UI dropdown), validate community-contributed template YAML files, and export existing resources as templates from the Web UI with a single click.

Changes

  • Domain: template engineBundledHardwareTemplateStore reads/caches YAML templates from templates/{kind}/, AddResourceFromTemplateUseCase<T> creates resources from templates, TemplateValidator checks templates against per-kind schemas, ResourceTemplateSerializer exports resources as template YAML
  • CLI: template commandsrpk templates list [--kind], rpk templates show Kind/Model, rpk templates validate <path>; all add commands now accept --template/-t
  • Web UI: template pickerHardwareTemplateSelectorComponent dropdown (alphabetically sorted) on the add-resource form; CopyAsTemplateButton (gold-yellow) on every hardware card prompts for official model name then copies template YAML to clipboard
  • 58 bundled templates — 7 access points (UniFi U6/U7), 2 firewalls (Netgate), 10 routers (UniFi gateways), 22 servers (Minisforum, GMKtec, Beelink), 18 switches (UniFi USW), 1 UPS (APC)
  • Tests — unit tests for template store, validator, serializer, and use case; CLI E2E workflow tests for template commands; browser E2E test for copy-as-template
  • Documentationdocs/Hardware-Templates.md covering usage, YAML format per kind, validation, and full contribution workflow (including Copy as Template from Web UI)

How to test

  1. just build — verify the solution compiles cleanly
  2. just validate-templates — all 60 templates should pass validation
  3. just test-cli — CLI tests pass (template list/show/validate/add workflows)
  4. just test-e2e — browser E2E tests pass (note: a small number of pre-existing flaky failures on the hardware tree navigation may appear — unrelated to this branch)
  5. Manual CLI smoke test:
    rpk templates list
    rpk templates list --kind Switch
    rpk templates show Server/Minisforum-MS-01-13900H
    rpk servers add my-server --template Minisforum-MS-01-13900H
    rpk servers describe my-server
    
  6. Manual Web UI smoke test: add a server via template dropdown, then click Copy as Template on its card and verify clipboard contains valid YAML

Notes for reviewers

  • The BundledHardwareTemplateStore sorts templates alphabetically by model name (case-insensitive) so the dropdown and templates list output are deterministic.
  • ResourceTemplateSerializer strips instance-specific fields (tags, labels, notes, runsOn) before serializing, so exported templates are clean.
  • Template YAML files include comment headers with product URLs for traceability.
  • The justfile recipe validate-templates runs the validator across all template directories — useful as a CI gate for template contributions.
Selection_083 Selection_084 Selection_085

templates-demo

@0xNF
Copy link

0xNF commented Mar 1, 2026

This is more or less exactly what I was hoping to see. Pretty cool to see it come together so quickly!

The only comments I have are basically just aesthetic ones, I could be happy with all, any, or none of these being in, the current PR is already good enough to be used.

In the copy-as-template menu

  • "Enter the official hardware name from the vendor (e.g. Minisforum-MS-01)."
    This wording is pretty strong. I only mention this because I can imagine situations where one wouldn't necessarily want to name a template exactly like that. But the idea is fine.

  • Possibly nice to have a YAML-viewer to see whats actually being copied

  • Copy As Template button shifts to "copied", but it's really subtle. I wasn't sure what, if anything, had happened after I clicked the "Accept" button. Some kind of toast or something would be nice to really inform the user that some effect has occurred.

Template List

It would be nice to have another option in the Tools menu for seeing whats available across all potential device categories

The template selection dropdown

Until one clicks on the --blank-- dropdown, what it actually is is a little unclear. A small header would go a long way to some friendly UX. Forgive this 17-second mockup done in mspaint:
image

Live feedback

In the various hardware menus / other places where a template can be applied, it'd be nice to get live feedback as to what each template's effect would be.
Screencast_20260301_142523.webm

It'd be nice to have the same html elements that display for concrete devices so that when one pages through the possible templates they can see what the differences between them are.

@DavidWalshe93
Copy link
Contributor Author

Thank @0xNF for the great feedback you provided above, i think each point helps polish out this feature in terms of user ergonomics and UX 💯

I would like to have someone on the core team review my existing additions to ensure this is the correct path for this feature add before iterating on it further.

If @Timmoth / @Chester-alt review and they align with the way this has been added/implemented, il try and add in your feedback to this pr (or a subsequent pr) 😊

@DavidWalshe93
Copy link
Contributor Author

DavidWalshe93 commented Mar 1, 2026

This wording is pretty strong. I only mention this because I can imagine situations where one wouldn't necessarily want to name a template exactly like that. But the idea is fine.

I am a little unclear on what you mean on this one? Can you please provide examples where a template would/may not be an official vendor supplied unit name?

@Timmoth
Copy link
Owner

Timmoth commented Mar 1, 2026

Very cool stuff!

It's quite a large PR so may take me some time to review properly, initially it looks really good!

I'll just spit out a few points here:

  • Seems to be missing e2e tests for compatible hardware type other than server.
  • CLI tests are not passing!
  • agree with the template drop down header, maybe by default it can just show 'none'
  • For the 'Live feedback' suggestion, I'm not sure how essential it is, since adding one then seeing how it looks and deleting / updating it if it's not right is a super easy process, it's probably easier to do that on the next page then it would be before even clicking 'add'
  • Not sure about the 'Copy As Template button', in general i think those actions are getting a little bit too overcrowded. I'd possibly consider a separate tool (page) around the templating stuff, linked from the homepage, where people can create new templates.

@DavidWalshe93
Copy link
Contributor Author

Will try and get this feedback seen to in the coming days 👍 thanks for the feedback 💯

@str8edgedave
Copy link

I can help by adding in a couple more templates (RaspberryPI 3, RaspberryPi 4, Raspberry Pi 5, and some other Unifi APs). Once this is committed, I can either do another PR, or share with @DavidWalshe93.

@DavidWalshe93
Copy link
Contributor Author

Just fyi, Il be AFK until the weekend to resume work on this one, sorry for the delay 🙈

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.

4 participants