Suggested added functionality: Expanding properties in repository configurations

24 views
Skip to first unread message

Håkan Lindqvist

unread,
Feb 13, 2025, 9:30:12 AM2/13/25
to vocbench-user
It would be good to have support for standard string expression resolving for the properties that you enter when configuring repositories.

Some context
For instance, on Openshift it's quite common to use secrets to store passwords (please see https://docs.openshift.com/container-platform/4.15/nodes/pods/nodes-pods-secrets.html for more details).

Moreover, it's useful to be able to use variables from the environment in the same manner as can be done with the application.yml file.

What I think would help
From a quick look around within the code base, it seems that something along the lines of the code below could be utilised to expand the values read from an "STRepositoryInfo" instance.

If using the crude code below, that would mean applying "serverUrlExpand" and "pwdExpand" to respective property just before attempting to connect to the repository, or perhaps when reading the value from the STRepositoryInfo-instance?

    @Value("${my.local.expand.serverurl:false}")
    private boolean expandServerUrl;

    @Value("${my.local.expand.password:false}")
    private boolean expandPassword;

    @Autowired
    private ConfigurableEnvironment environment;

    public class ConnectionDetailExpander {
        private final boolean expandServerUrl;
        private final boolean expandPassword;
        private final PropertyResolver propertyResolver;

        public ConnectionDetailExpander(final boolean expandServerUrl, final boolean expandPassword, final PropertyResolver propertyResolver) {
            this.expandServerUrl = expandServerUrl;
            this.expandPassword = expandPassword;
            this.propertyResolver = propertyResolver;
        }

        public String expandServerUrl(final String url) {
            if (url != null && expandServerUrl) {
                return propertyResolver.resolvePlaceholders(url);
            }
            return url;
        }

        public String expandPassword(final String password) {
            if (password != null && expandPassword) {
                return propertyResolver.resolvePlaceholders(password);
            }
            return password;
        }
    }


        final ConnectionDetailExpander expander = new ConnectionDetailExpander(expandServerUrl, expandPassword, environment);
        final Function<String, String> serverUrlExpand = expander::expandServerUrl;
        final Function<String, String> pwdExpand = expander::
expandPassword ;


Håkan Lindqvist

unread,
Feb 14, 2025, 8:31:50 AM2/14/25
to vocbench-user
I reposted this is "vocbench-developer" as well.
Reply all
Reply to author
Forward
0 new messages