Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Configurable /app/config/config.xqy file #665

Closed
miguelrgonzalez opened this issue Sep 27, 2016 · 12 comments
Closed

Configurable /app/config/config.xqy file #665

miguelrgonzalez opened this issue Sep 27, 2016 · 12 comments

Comments

@miguelrgonzalez
Copy link
Contributor

Currently it's not possible to include roxy environment variables into SJS configuration modules.
I will be nice to be able to configure which file we intend to use as a central configuration file.

For example:
application-conf-file=/app/config/config.sjs

Or even better:
application-conf-file=('/app/config/service1-related-config.xqy', '/app/config/service2-related-config.xqy')

@grtjn
Copy link
Contributor

grtjn commented Sep 27, 2016

We could perhaps think of something slightly more generic too. replace-properties-files=src/*.xqy,src/*.sjs

@dmcassel
Copy link
Collaborator

I don't think we want to get into wildcards. The idea was that there should be a place to communicate properties from Roxy to code. I like the idea of using a property to specify what that file should be (and allowing SJS), but we don't want to be doing property replacements throughout the code.

@grtjn
Copy link
Contributor

grtjn commented Sep 27, 2016

I'm not suggesting enabling this by default. The default would be just doing what happens now. But I see not much harm in allowing wider scale application. It could be convenient to be able to do something like replace-props-in=src/*-config.xqy..

@miguelrgonzalez
Copy link
Contributor Author

I'm with Dave in this one.
Allowing wildcards will only enable developers to have properties defined all over the place, which does not sound like a good idea.

@dmcassel
Copy link
Collaborator

The potential harm of allowing widespread property substitution:

  • The Deployer code would need to be more complex
  • more potential bugs from accidental substitutions

Keeping it to a particular file or two (configurable) is the principle of encapsulation, which I think makes sense.

@grtjn
Copy link
Contributor

grtjn commented Sep 29, 2016

Fair enough.. comma-separated, no wildcards then. Who wants to do a PR? :)

@dmcassel dmcassel added this to the April 2017 milestone Feb 13, 2017
@divino
Copy link
Contributor

divino commented Mar 22, 2017

Is it ok if I implement it like the following pattern:

application-conf-file=<template1>,<target1>,<template2>,<target2>...<templateN>,<targetN>

example:

application-conf-file=src/ui/util/rest.service.tmpl.js,src/ui/util/rest.service.js,src/rest-api/config.tmpl.xqy,src/rest-api/config.xqy

or

application-conf-file=<template1>'=>'<target1>,<template2>'=>'<target2>...<templateN>'>'<targetN>

example:

application-conf-file=src/ui/util/rest.service.tmpl.js=>src/ui/util/rest.service.js,src/rest-api/config.tmpl.xqy=>src/rest-api/config.xqy

This will avoid overwriting the template or putting everything into a temporary folder before deploying.

@dmcassel
Copy link
Collaborator

@divino I'm not sure what you mean by templates. This feature is described in the Deployer Substitution wiki, allowing the developer to have code such as:

declare variable $c:ENV := "@ml.environment";

The deployer will replace @ml.environment in a particular file with the property value. This issue would allow us to specify which file(s) get the property replacement.

@divino
Copy link
Contributor

divino commented Mar 22, 2017

Upon review of the code, it looks like this is already implemented but the current implementation forces user to use "/app/config/config.xqy" as configuration file. See code below.

app_config_file = File.join xquery_dir, "/app/config/config.xqy"

...

      if File.exist? app_config_file
        buffer = File.read app_config_file
        replace_properties(buffer, File.basename(app_config_file))

        total_count += xcc.load_buffer "/config.xqy",
                                       buffer,
                                       :db => dest_db,
                                       :add_prefix => File.join(@properties["ml.modules-root"], "app/config"),
                                       :permissions => src_permissions
      end

@divino
Copy link
Contributor

divino commented Mar 22, 2017

Do we support both the current and the proposed?

@dmcassel
Copy link
Collaborator

The current feature handles replacement of properties in a single, hard-coded file. The intent of this issue is to enhance the capability:

  • establish a property to control the name of the file in which substitutions are made
    • the property must be defined in default.properties as "/app/config/config.xqy" to make sure existing projects will work when upgraded
    • the property should also be added to build.sample.properties, commented out, with a comment describing the feature
  • the property must allow a comma-separated list of file paths; substitutions must be made in all files specified
    • the list make consist of a combination of XQuery and SJS files

With all that in mind, a project that currently uses the feature should be able to update the Roxy Deployer code and still work without change.

@divino divino mentioned this issue Apr 25, 2017
dmcassel added a commit that referenced this issue Apr 26, 2017
@dmcassel
Copy link
Collaborator

fixed in dev

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants