Persisting command-generated config values across application versions


#1

When populating config values with commands, particularly the random command, it can be useful to suppress the regeneration of the random value in question across your app versions

To stop config values which are generated using the random command from regenerating every time a new app update is installed, make the config item hidden

Example app

cmds:
  - name: generate_random_password_32_char
    cmd: random
    args:
      - "32"

...

config:
- name: App
  title: "App Configuration"
  description: Set default values for my App to Use
  items:
  - name: admin_pw
    title: "Generated Admin User Password"
    hidden: true
    value_cmd:
      name: generate_random_password_32_char
      value_at: 0

this approach will hide the value from the customer. To make it visible to the customer while retaining the persistent property, chain config items:

config:
- name: App
  title: "App Configuration"
  description: Set default values for my App to Use
  items:
  - name: admin_pw
    title: "Generated Admin User Password"
    hidden: true
    value_cmd:
      name: generate_random_password_32_char
      value_at: 0
  - name: admin_pw_view
    title: "The Visible Admin User Password"
    type: text
    readonly: true
    value: '{{repl ConfigOption "admin_pw" }}'