I’d like to have a value that’s always defined in my kots Config, but is only visible to users when certain conditions are met – specifically, when a certain boolean value is set in the license. I’m trying to define a component like this:
items:
- name: hub
type: bool
title: Enable special feature
hidden: '{{repl LicenseFieldValue "special-feature-allowed" | ParseBool }}'
default: "0"
I’m getting an error when I run the installer: “Failed to decode kots-config.yaml: json: cannot unmarshal string into Go struct field ConfigItem.spec.groups.items.hidden of type bool”.
I expect this means that templating is not supported, though it’s hard to tell from the docs and the error message.
Hi anyweez! This is Paige from the Docs team at Replicated. Thanks for your question. We just updated the topic to clarify which properties in the Config custom resource support templating, and which do not: Config | Replicated Docs.
As for your specific question, the hidden
property does not support templating. But, you might be looking for the when
property, which allows you to use templated conditional statements to show or hide fields from users. You can find more info about the when
property on that page in the docs as well: Config | Replicated Docs
I also found what looks like a similar example to what you are taking about (using a specific license field in a conditional statement) in another community post here: Conditional custom fields - #2 by grahamnscp
1 Like
Great, thanks @Paige_Calvert! when
worked well for my use case, and I appreciate the clarification in the docs.
1 Like