Page MenuHomePhabricator

Figure out type coercion rules for puppet parameter config in horizon UI
Closed, ResolvedPublic

Description

Puppet params have types (string, undef, int, float, bool, array, hash), and these do matter - 'true' is not equal to true, etc. But we have no type information from puppet, so we have to make users make this determination, without being overwhelmed by it.

Assumptions:

  1. Strings are going to be the most popular type
  2. Things that appear to be integers / bools / floats are more likely to be integers / bools / floats of the appropriate type than strings that just have the appropriate contents
  3. There will be a 'raw yaml' interface for arrays and hashes
  4. We need to support 'undefined'
  5. We would like the UI to be as unconfusing as possible

Proposed co-ercion solution:

  1. Empty string implies undefined
  2. The literal value '' implies empty string
  3. The literal values true and false imply the boolean values true and false
  4. Values that are integers / floats will just be integers/floats
  5. Values that are integers / floats with quotes around them will be strings
  6. The literal values 'true' and 'false' will be literal strings

Basically, we guess-check to see if it is a bool or int or float - and if guess fails, it is a string. If users want to force it to be a string, put quotes around it.

To make this simple and easy and avoid people asking questions, ideally we'd pop up a nice and simple callout whenever someone types in 'true' or 'false' or a number into the textbox.

Event Timeline

Restricted Application added a subscriber: Zppix. · View Herald Transcript

For arrays and lists, I presume there'll be a different interface somewhere that replaces our current Hiera: namespace on wikitech, and those will have to be specified there.

I keep looking at this task, and I'm still not sure if there's anything the gui needs to actually do. At the moment, I preserve quote marks that the user enters, and that's it. I presume that means that the back-end interprets something like

value: /srv/mountpoint

as a string and something like

value: 'true'

as a string and something like

value: true

as a bool. Am I missing things that users will get trapped by?

My tests have all produced reasonable behavior so far, so I think we're good.