How to deprecate/hide existing fields in the config?

We have a few fields in our config (like the one following) which we do not want to show to our users anymore. These fields are all currently optional and have a a default value set on them, like so:

# ...
items:
  - name: eg_broker_password
    title: Example broker password
    type: password
    value: ""
    default: random@1234

To hide them, I changed it to following:

# ...
items:
  - name: eg_broker_password
    title: Example broker password
    type: password
    value: {{repl RandomString 15}}
    hidden: true

My thoughts were that changing the item to hidden: true and specifying value as {{repl RandomString 15}} would have the following effect:

  • For existing customers who use the default value, Replicated will keep using the [old] default value.
  • For existing customers who changed the default value, the modified value will be used.
  • For any new customers, the value field will be evaluated using {{repl RandomString 15}} and will be persisted.

However, for #1 (i.e. existing customers using the default value), an empty string was being injected now. I guess it was copying this from the old value. I did not test for the other two cases. Instead, I added the old default value as well:

# ...
items:
  - name: eg_broker_password
    title: Example broker password
    type: password
    value: {{repl RandomString 15}}
    hidden: true
    default: random@1234

This works fine for #1 (existing customers using the default value still get the default value). But for #2 (existing customers who had modified this value), we again receive the default value (random@1234), rather than the actual value.

Rather than testing for #3, I thought it wise to just ask here since this must be a common use case for a lot of your other customers as well. How do you recommend that we hide these fields?

1 Like

Great question. They way I would handle this would actually be to not reuse an existing field.

Step 1: Make a custom field in the license, and set it to true for existing customers. For new customers, put it on false
Step 2: Create a new ConfigValue for the hidden auto generated password.
Step 3: Add a when field to the existing ConfigValue that checks for the custom license field (Config | Replicated Docs)
Step 4: In the actual application (Secret?), based on the custom license field you can decide which ConfigValue to use (using go templating).

Once a customer is upgraded to the new version, you could switch their custom license field to start hiding the old ConfigValue.

Would this strategy work for you?

1 Like