@CheckForNull
    @Override
    public CNode describe(Object instance, ConfigurationContext context) {

        if (instance == null) {
            return null;
        }

        if (instance instanceof Number) {
            return new Scalar((Number) instance);
        }
        if (instance instanceof Boolean) {
            return new Scalar((Boolean) instance);
        }
        if (instance instanceof Secret) {
            // Secrets are sensitive, but they do not need masking since they are exported in the encrypted form
            return new Scalar(((Secret) instance).getEncryptedValue()).encrypted(true);
        }
        if (target.isEnum()) {
            return new Scalar((Enum) instance);
        }

        return new Scalar(context.getSecretSourceResolver().encode(String.valueOf(instance)));
    }
@author <a href="mailto:nicolas.deloof@gmail.com">Nicolas De Loof</a>
plugin/src/main/java/io/jenkins/plugins/casc/impl/configurators/PrimitiveConfigurator.java