spring-cloud / spring-cloud-config

External configuration (server and client) for Spring Cloud
Apache License 2.0
1.95k stars 1.29k forks source link

Spring Cloud Config Server and managing plain text files #147

Closed iceycake closed 8 years ago

iceycake commented 9 years ago

Spring Cloud Config Server is a perfect solution for simple key/value application properties. However, a lot of applications have additional resource files based on different profile. For example, keystore jks file, custom XML file, etc.

My current workaround is storing those files under the same config-repo in git. During deployment, I need to write script to copy those files over from git to the application server config/ directory. It is not perfect but doing the job.

However, I am running into issue about there are text file contains sensitive data. I can encrypt those files and storing them onto git and decrypt them during deployment.

I don't know if this make any sense?

dsyer commented 9 years ago

I presume you are talking about legacy applications (otherwise why wouldn't you just re-write them to use key-value pairs)? I'm not sure how or whether we should support legacy, non-cloud-native apps.

iceycake commented 9 years ago

Yes and No.

  1. I may have different logback.xml or log4j.properties that uses different log appender depending on different spring profile. Please let me know if there is a SpringBoot/SpringCloud way to handle this situation.
  2. Application that has 3rd party libraries that requires a license file, which is a XML file containing a key. This file is only allowed to be used in production but not other environment so it needs to be encrypted.
  3. This is completely outside the scope of Spring Cloud Config Server but supporting NON SpringBoot/Java application. In our organization, we have a lot teams using different programming languages (Perl, PHP, node.js, C#, Python, Ruby, etc.)
shakuzen commented 8 years ago

@dsyer Should this be tagged with a milestone?

vishalmanohar commented 8 years ago

Hi, Spring cloud config looks like a great solution for distributed config. Thanks!

We have a use case where we want to also load plain files like XML through centralized config server.

Is this fix intended to also cover non key value type plain text files like a logback xml and such?

Looks like the resource is always loaded to an Environment object and this is not supported yet.

StandardEnvironment environment = prepareEnvironment( this.environmentRepository.findOne(name, profile, label));

spencergibb commented 8 years ago

Looks like the resource is always loaded to an Environment object and this is not supported yet.

@vishalmanohar Not sure what that means. Loading plain text files (including xml) is supported.

vishalmanohar commented 8 years ago

I get this error when I try to load an XML resource using the config server (using this path) from this config repo

Am I missing anything?

2016-03-23 09:45:58.376 ERROR 18199 --- [nio-8888-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: Unable to load configuration files] with root cause

org.xml.sax.SAXParseException: Document root element "catalog", must match DOCTYPE root "null".
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203) ~[na:1.8.0_66]
spencergibb commented 8 years ago

@vishalmanohar that's the wrong url according to the docs it should be. /{appname}/{profile}/{label}/{path}.

So in your case http://localhost:8888/myapp/default/master/books.xml.

This does environment expansion in the text file. If you don't need that, it won't matter the /

vishalmanohar commented 8 years ago

Ah thanks. This path is however failing http://localhost:8888/books/default/master/books.xml Is that a bug or incorrect use?

dsyer commented 8 years ago

Failing how? Is there actually an XML file? Are you using the latest code base?

xxlabaza commented 8 years ago

I have the same issue, as vishalmanohar

dsyer commented 8 years ago

What is it (the issue)? How is it failing?

vishalmanohar commented 8 years ago

This path http://localhost:8888/books/default/master/books.xml is failing on pointing latest spring config server to this repo

Using any other app name works. For e.g. http://localhost:8888/random/default/master/books.xml

i.e. when the appname is the name of the file, there is an error.

dsyer commented 8 years ago

I see. Thanks for the clarification. That's actually because your XML file is not a valid java.util.Properties file ("books" is the name of the app, so we need to read all the environment properties for that app, and XML is a valid representation of Properties, in principle). You can work around it (obviously) by putting your non-properties XML in a different path. If you want to continue the discussion, please open another issue, instead of camping on this old one.

kaeukola commented 7 years ago

Hi I am Trying to connecting with Redis cloud bus for native file configuration. My client is not getting refreshed.

I have enabled RefreshScope but not getting the events. Following are dependencies from Brixton.RELEASE

Any Suggestions? Thanks in advance.

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-autoconfigure</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-bus-redis</artifactId>
        <version>1.1.0.M5</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-stream-binder-redis</artifactId>
        <version>1.0.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-config-client</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-config</artifactId>
    </dependency>
spencergibb commented 7 years ago

@kaeukola please don't comment on closed, unrelated issue. For a question like that, please use stack overflow with spring-cloud tag.

githubyong commented 5 years ago

how to get the books.xml in spring bean ?