The prod-env.properties property set contains the property log-level=error
The test-env.properties property set contains the property log-level=debug
Is there a documented way to do this? I can package only the target environment file at deploy time, but wanted to check there wasn’t a way to do this intrinsically.
I came up with a solution to this. I couldn’t find any reference to a variable that exposed which project you are in, so I created a property set to map between environment names and projects. I then used used the format
<project>.<property>=<value>
and then used AssignMessage to map the env to a project, and then use that to find the value for that project.
Admittedly you could just do the same with environment.name as the discriminator, but I needed the project name to use in my Cloud Logging path anyway.
There is an “organization.name” variable which is the same as the GCP project name, in Apigee X and hybrid.
That might get you what you want in a different way.
Also, you can apply multiple levels of indirection via AssignMessage/AssignVariable. What I mean is this: suppose you have a properties file that has property names that depend on the environment.name. (If you use an environment-scoped properties file, you wouldn’t do this, but … the idea extends beyond environment-scoped properties. It could be properties based on API Product name, or … anything).
And in the proxy you would like to get the value for the current environment. How? You can do this with 2 cascades of indirection. It looks like this:
<AssignMessage name='AM-Eval-Settings'>
<AssignVariable>
<Name>target-variable</Name>
<Template>propertyset.settings.target1-{environment.name}</Template>
</AssignVariable>
<!-- result of the above is propertyset.settings.target1-dev, for example. -->
<AssignVariable>
<Name>target-template</Name>
<Template> { {target-variable} } </Template> <!-- see note below -->
</AssignVariable>
<!-- result of the above is {propertyset.settings.target1-dev}, for example. -->
<!-- it's suitable for use as a message template. -->
<AssignVariable>
<Name>resolved-target</Name>
<Template ref='target-template'/>
</AssignVariable>
<!-- the above just resolves that message template. so the value will be -->
<!-- https://my-dev-server.com -->
</AssignMessage>
Please note , you must collapse the double-curlies. I cannot post the correct code without spaces here, for some reason.
I couldn’t get it to work, even after following your instructions precisely. Hmm, could this be related to the double curly braces? I see that they’re collapsed, but your note indicates that this shouldn’t be an issue. I’m a bit confused.
What would you suggest for applying this to all the variables? Is there a for loop we could use to assign the message, since this is currently set up for just one variable?
I see that they’re collapsed, but your note indicates that this shouldn’t be an issue. I’m a bit confused.
I didn’t word my note very clearly. What I meant was, the correct syntax requires both curly braces to be together, no intervening spaces. When I tried posting it in the correct format to this forum, it would not display. so I injected a space between the two curlies, but that space must not be there when you use this. It should be {{target-variable}}.