Netflix / zuul

Zuul is a gateway service that provides dynamic routing, monitoring, resiliency, security, and more.
Apache License 2.0
13.53k stars 2.38k forks source link

Setting the deployment context #412

Closed sandy-adi closed 6 years ago

sandy-adi commented 6 years ago

How do you set the deployment context for zuul? I see that you can have a environment specific configuration properties

private static Properties loadCascadedProperties(String configName) throws IOException {
        String defaultConfigFileName = configName + ".properties";
        if (instance == null) {
            instance = getConfigInstance();
        }
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        URL url = loader.getResource(defaultConfigFileName);
        if (url == null) {
            throw new IOException("Cannot locate " + defaultConfigFileName + " as a classpath resource.");
        }
        Properties props = getPropertiesFromFile(url);
        String environment = getDeploymentContext().getDeploymentEnvironment();
        if (environment != null && environment.length() > 0) {
            String envConfigFileName = configName + "-" + environment + ".properties";
            url = loader.getResource(envConfigFileName);
            if (url != null) {
                Properties envProps = getPropertiesFromFile(url);
                if (envProps != null) {
                    props.putAll(envProps);
                }
            }
        }
        return props;
    }

I tried environment variable and that did not work.

PS: Have you guys considered having a gitter chat or a slack channel for answering questions? It feels weird to use github issues for questions.

JacobJohansen commented 6 years ago

gradle -Penv=local run

artgon commented 6 years ago

You can set the environment by using JVM args: -Darchaius.deployment.environment=test

More details on Archaius here: https://github.com/Netflix/archaius/wiki/Deployment-context

You can also add it to the build.gradle: https://github.com/Netflix/zuul/blob/2.1/zuul-sample/build.gradle#L16

sandy-adi commented 6 years ago

Thanks @JacobJohansen & @artgon