openflighthpc/flight-inventory

Asset types and default render templates

Closed this issue · 5 comments

Initially we only needed one default template for a "server" rendered in "flightcenter ready markdown yaml"

Moving on we now have potentially many templates. For one we now can hold information for any kind of asset type (each type likely to need rendering differently), but also at least 2 output types (1: flightcenter import 2: standard markdown to view directly on the cluster)
I think that we can contain the number of templates to about 5 asset types, 2 documents for each but with that many It's going to be hard to have to choose the correct template each time you want to view an asset. With that in mind I'm thinking something like:

1 - have a special compulsory key/value 'AssetType', parsed files would all be set to 'server' currently but manually created ones can be set to anything, eg 'switch'
2 - have a configuration file somewhere in the file tree that allows mapping any asset type to a default template. eg:

---
server: templates/serverFC.erb
switch: templates/switch.erb

3 - the [template] option to show document could then be optional, as we can try and map a default template, falling back to requesting one if we can't work it out.

@ColonelPanicks might need you to clarify the above :)

@ste78 am I right in thinking that in the above you've not proposed a solution for the issue of having 2+ output types (e.g. for flight center vs. conventional markdown)? Using an asset's type to determine a template is fine but doesn't allow for >1 default template per asset type.

This is alright as you can still manually specify a template, just wanted to confirm I hadn't missed some other method of determining templates that would account for the output type wanted

i’m not proposing anything, merely suggesting 🙂

ask @ColonelPanicks to clarify he’s the product manager x

@DavidMarchant while there's no proposition for handling markdown vs flight center format it'd definitely be worth implementing something to ease the handling for it.

To me it feels like we could set defaults for both "outputs" for the various asset types, such that the show command can have a default behaviour (markdown default for asset type) and accepts an option to toggle what "output" default to use. Something like:

markdown:
  server: server.md.erb
  switch: switch.md.erb
flightcenter:
  server: server_flightcenter.md.erb
  switch: switch_flightcenter.md.erb

What are you thoughts on this?

wat stu said looks luvly 😍

That looks great by me! On it now