Currently I am a programmer at Supremo Tribunal Federal.
- ๐ท Working on STF
- ๐ Programming: ๐ Python/Cython / ๐ป C / ๐ฆ Rust / โก Zig
- ๐ค Machine Learning
- ๐ฅ Debian OS
config-client package for spring cloud config and cloud foundry
Home Page: https://config-client.amenezes.net/
License: Apache License 2.0
Currently I am a programmer at Supremo Tribunal Federal.
On initializing a CF object, profile is not set using the Cloud foundry space name which then defaults to 'development'. This causes the config for development to be fetched for all other environments.
Below code needs to be updated in __attrs_post_init__
function of CF to set profile based on the space name to construct the correct config-server url.
if not self.client:
self.client = ConfigClient(
address=self.cfenv.configserver_uri(),
app_name=self.cfenv.application_name,
profile=self.cfenv.space_name.lower() ##Set profile based on space name.
)
Dependabot can't evaluate your Python dependency files.
As a result, Dependabot couldn't check whether any of your dependencies are out-of-date.
The error Dependabot encountered was:
Illformed requirement [">==19.1.0"]
Hi, as there is no detail on using the Oauth in the documentation, it will be helpful if we provide the documention and/or example for using it.
This might already exist and I just don't know how to utilise it, but is it possible for a local build to use an already existing application.json/yaml inside the project?
In Spring Java, you can put an application.yml
inside src/main/resources/
and it'll pick that up with a local build. The config-server replaces this when deployed to Cloud Foundry. Is it possible for this to do the same?
The library is working fine for Spring Cloud Services 1.x and 2.x (p-config-server) but failing for 3.x config server service instances (p.config-server).
Below files need to be updated to support p.config-server along with p-config-server
config/cfenv.pyโจ
config/cloudfoundry.pyโจ
tests/unit/test_cfenv.pyโจ
tests/unit/test_oauth2.py
All platforms
After 1.0.0, client.get
method does not retrieve array values.
Setting a config like this
example:
- 1
- 2
When I run config.get('example')
#
Prior 1.0.0
Results were
> client.get('example')
[1, 2]
After 1.0.0
Results are empty string
> client.get('example')
''
Running client.get('example[0]')
return first value, but It's not useful because I don't know how many values are configured
> client.get('example[0]')
1
Hi,
I have been looking the way to work with local configuration files, i mean without connection with the Spring Cloud Server. But I didn't find a way to do that so far. Is there any option or argument to indicate to the ConfigClient to take the configuration files from a directory or something similar instead to deploy a SpringCloudConfig locally?
The library is failing for 3.x config server service instances (p.config-server).
I tried your suggestion from issue #35 as below but it still does not work.
from config.cf import CF
from config.cfenv import CFenv
cf = CF(cfenv=CFenv(vcap_service_prefix="p.config-server"))
cf.get_config()
The issue appears to be with the path supplied to glom for accessing credentials from vcap_services. Due to a dot in the service prefix name (p.config-server), glom expands path to the json properties incorrectly (like "p.config-server.0.credentials.uri") and is unable to read the value.
Updating _format_vcap_path
function in cfenv.py as below would address the problem.
from glom import Path
def _format_vcap_path(self, path: str) -> Any:
path = path[1:]
return Path(Path(self.vcap_service_prefix),Path.from_text(path))
Our app runs fine in the docker container locally and is able to connect to the remote config server. However, when deployed to K8s (in the same docker container) it logs "Failed to establish connection with ConfigServer.". When I exec into K8s pod I am able to CURL (after I manually installed CURL) to the config server as well.
Any advice on how to troubleshoot this would be very much appreciated.
in Spring Cloud Services (SCS v3.0 and later, the p-config-server
entry in VCAP_SERVICES has changed to p.config-server
. This causes numerous failures in config-client, as it is explicitly looking for p-config-server
.
The documentation does not mention this, but the value can be overridden by setting os.environ["VCAP_SERVICE_PREFIX"] = "p.config-server"
.
However, in function __attrs_post_init__
of cfenv.py
, there is still a literal "p-config-server"
that does not get overridden by the environment variable.
The Spring Cloud Config standard (https://cloud.spring.io/spring-cloud-static/spring-cloud-config/2.2.0.M3/reference/html/) does NOT require the .json extension. I ask that your module be modified to allow a url format that has no dot-extension.
was testing out this library in our Pivotal CF instance. provisioned service like
cf create-service -c { "git": { "uri": "https://github.com/spring-cloud-samples/config-repo" }, "count": 1 } p.config-server standard config-server
and then i bind it to the simpleweb000
service provisions & binds ok but the simpleweb000 app example crashes. I am suspecting this is because it's looking for p-config-server which is an SCS 2.X but in SCS 3 it is now p.config-server was wondering if config-client is then compatible with SCS 3.x?
2020-03-06T13:46:27.855-06:00 [APP/PROC/WEB/0] [ERR] self.cfenv = __attr_factory_cfenv()
2020-03-06T13:46:27.855-06:00 [APP/PROC/WEB/0] [ERR] File "<attrs generated init 937803616bd1ea7913d956dac2aec481ca1035b7>", line 9, in init
2020-03-06T13:46:27.855-06:00 [APP/PROC/WEB/0] [ERR] self.attrs_post_init()
2020-03-06T13:46:27.855-06:00 [APP/PROC/WEB/0] [ERR] File "/home/vcap/deps/0/python/lib/python3.6/site-packages/config/cfenv.py", line 33, in attrs_post_init
2020-03-06T13:46:27.855-06:00 [APP/PROC/WEB/0] [ERR] "p-config-server"
2020-03-06T13:46:27.855-06:00 [APP/PROC/WEB/0] [ERR] KeyError: 'p-config-server'
2020-03-06T13:46:27.855-06:00 [APP/PROC/WEB/0] [ERR] [2020-03-06 19:46:27 +0000] [109] [ERROR] Exception in worker process
2020-03-06T13:46:27.855-06:00 [APP/PROC/WEB/0] [ERR] [2020-03-06 19:46:27 +0000] [110] [ERROR] Exception in worker process
thanks - if there is another place to ask the question besides here please let me know. thank you for your efforts on this library
Does this client work for the Spring Cloud Config Server on Cloud Foundry? The Config Server on Cloud Foundry uses OAuth 2.0 and the credentials for the Config Server are injected to the bound App as VCAP environment variables.
I'm using spring boot 2.0.2.RELEASE which acts as my configuration server which exposes GET API and python client to read configuration from spring server but python client fails to get the configuration.
Spring Config Server Log:
INFO 11670 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{label}/{name}-{profiles}.yml || /{label}/{name}-{profiles}.yaml],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.lang.String> org.springframework.cloud.config.server.environment.EnvironmentController.labelledYaml(java.lang.String,java.lang.String,java.lang.String,boolean) throws java.lang.Exception
Inorder to get the configuration file (test-profile.yml) which consits
management.baseurl: http://192.168.0.0:8096
Approach :
`(virtual-env) [sample]$ python3.7
Python 3.7.3 (default, Jul 31 2019, 14:24:32)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
from config import spring
con = spring.ConfigServer(url='http://X.X.X.X:8088/api/v1/test-profile.yml')
con.get_config()
Traceback (most recent call last):
File "", line 1, in
File "/home/test/virtual-env/lib/python3.7/site-packages/config/spring.py", line 64, in get_config
ValueError: Response from: http://X.X.X.X:8088/api/v1/test-profile.yml was different than 200.`
May I know what is the actual error message ??
More details on issue please refer : https://stackoverflow.com/questions/57307808/python-client-config-client-0-3-1-to-get-yml-configuration-from-spring-boot-co
I'm testing the client inside a application with Django. My config server does not allow traffic on 80, only 443. When I use this client, I got a error with https. Changed my config-server to allow traffic to http and configured the client to the same protocol, everything works fine.
Is there a option or plans for allowing https?
Thanks.
Hi,
Our spring config server is protected using basic authentication. Is it possible to use config-client to send a basic auth header with the request? If yes, an example would be very helpful.
Thanks!
Add support to Encryption and Decryption feature.
Other
version: <= 1.0.2
First start local development container with:
docker-compose up -d
Second, access/show the config:
python -m config client simpleweb000 --all
โญโโโโโโโโโโโโโโโโโโโโโโโโโโ report for filter: 'all' โโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ { โ
โ "example": [ โ
โ 1, โ
โ 2 โ
โ ], โ
โ "examples": { โ
โ "float": [ โ
โ 1.1, โ
โ 2.2, โ
โ 3.3, โ
โ 4.4 โ
โ ], โ
โ "int": [ โ
โ 1, โ
โ 2 โ
โ ], โ
โ "str": [ โ
โ "example 1", โ
โ "example 2", โ
โ "example 3" โ
โ ] โ
โ }, โ
โ "first": { โ
โ "second_1": [ โ
โ 1, โ
โ 2 โ
โ ], โ
โ "second_2": [ โ
โ 1 โ
โ ], โ
โ "second_3": { โ
โ "third_1": [ โ
โ 1, โ
โ 2 โ
โ ], โ
โ "third_2": [ โ
โ 1, โ
โ 2, โ
โ 3 โ
โ ], โ
โ "third_3": { โ
โ "fourth_1": [ โ
โ 1, โ
โ 2 โ
โ ], โ
โ "fourth_2": [ โ
โ 1 โ
โ ], โ
โ "fourth_3": [ โ
โ 1, โ
โ 2, โ
โ 3 โ
โ ], โ
โ "fourth_4": { โ
โ "fifth_1": [ โ
โ 1, โ
โ 2 โ
โ ], โ
โ "fifth_2": [ โ
โ 1, โ
โ 2, โ
โ 3 โ
โ ] โ
โ } โ
โ } โ
โ } โ
โ }, โ
โ "health": { โ
โ "config": { โ
โ "enabled": false โ
โ } โ
โ }, โ
โ "info": { โ
โ "app": { โ
โ "description": "pws simpleweb000 - development profile", โ
โ "name": "simpleweb000", โ
โ "password": "123" โ
โ } โ
โ }, โ
โ "python": { โ
โ "cache": { โ
โ "timeout": 10, โ
โ "type": "simple" โ
โ } โ
โ }, โ
โ "server": { โ
โ "port": 8080 โ
โ }, โ
โ "spring": { โ
โ "cloud": { โ
โ "consul": { โ
โ "host": "discovery", โ
โ "port": 8500 โ
โ } โ
โ } โ
โ } โ
โ } โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
python -m config client simpleweb000 --all
โญโโโโโโโโโโโโโโโโโโโโโโโโโโ report for filter: 'all' โโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ { โ
โ "example": [ โ
โ 1, โ
โ 2 โ
โ ], โ
โ "examples": { โ
โ "float": [ โ
โ 1.1, โ
โ 2.2, โ
โ 3.3, โ
โ 4.4 โ
โ ], โ
โ "int": [ โ
โ 2 โ
โ ], โ
โ "int[0]": 1, โ
โ "str": [ โ
โ "example 1", โ
โ "example 2", โ
โ "example 3" โ
โ ] โ
โ }, โ
โ "first": { โ
โ "second_1": [ โ
โ 2 โ
โ ], โ
โ "second_1[0]": 1, โ
โ "second_2": [ โ
โ 1 โ
โ ], โ
โ "second_3": { โ
โ "third_1": [ โ
โ 2 โ
โ ], โ
โ "third_1[0]": 1, โ
โ "third_2": [ โ
โ 1, โ
โ 2, โ
โ 3 โ
โ ], โ
โ "third_3": { โ
โ "fourth_1": [ โ
โ 2 โ
โ ], โ
โ "fourth_1[0]": 1, โ
โ "fourth_2": [ โ
โ 1 โ
โ ], โ
โ "fourth_3": [ โ
โ 1, โ
โ 2, โ
โ 3 โ
โ ], โ
โ "fourth_4": { โ
โ "fifth_1": [ โ
โ 2 โ
โ ], โ
โ "fifth_1[0]": 1, โ
โ "fifth_2": [ โ
โ 1, โ
โ 2, โ
โ 3 โ
โ ] โ
โ } โ
โ } โ
โ } โ
โ }, โ
โ "health": { โ
โ "config": { โ
โ "enabled": false โ
โ } โ
โ }, โ
โ "info": { โ
โ "app": { โ
โ "description": "pws simpleweb000 - development profile", โ
โ "name": "simpleweb000", โ
โ "password": "123" โ
โ } โ
โ }, โ
โ "python": { โ
โ "cache": { โ
โ "timeout": 10, โ
โ "type": "simple" โ
โ } โ
โ }, โ
โ "server": { โ
โ "port": 8080 โ
โ }, โ
โ "spring": { โ
โ "cloud": { โ
โ "consul": { โ
โ "host": "discovery", โ
โ "port": 8500 โ
โ } โ
โ } โ
โ } โ
โ } โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
I suggest removing references about asyncio until the client is actually asyncio compliant.
If it were asyncio compliant, the example code would include the await
keyword, like so:
async def start(config_client):
await config_client.get_config()
print(config_client.config)
await start(config_client)
The clarification is important, as applications which regularly call get_config
, expecting it to be async, will block their event loop while the request occurs. Calling get_config
once on application startup is fine for async applications, as is done in the aiohttp extension, because the actual async part of the application isn't running yet. However, the fact that the application is async is irrelevant in that case.
Currently there are no "python_requires" in setup.py so it is possible to install
this package on un-supported python version (for example on python 2.7 as I did).
Also I noticed that on PYPI page supported python versions starts from "Python :: 3.5" but there are f-strings used in code, which were added in python 3.6 (PEP 498), so supported python version should start from python 3.6.
we have implemented our own config server, is there away to override the p-config-server?
default_vcap_services = json.dumps(
{
"p-config-server": [
{
"credentials": {
"uri": "",
"access_token_uri": "",
"client_id": "",
"client_secret": ""
}
}
]
}
)
If I decorate two or more functions, it will call server both times.
It would be great a decorator that return singleton instance.
import logging
from config.spring import config_client
@config_client()
def foo(client):
logging.debug(client.config)
@config_client() # call again
def bar(client):
logging.debug(client.config)
Suggestion
import logging
from config.spring import config_client
@config_client(singleton=True)
def foo(client):
logging.debug(client.config)
@config_client(singleton=True)
def bar(client):
logging.debug(client.config)
Or
import logging
from config.spring import config_client_singleton
@config_client_singleton
def foo(client):
logging.debug(client.config)
@config_client_singleton
def bar(client):
logging.debug(client.config)
We have a Spring Cloud Config that has RabbitMQ binders to propagate changes made to the config server.
Will this library be able to listen to these changes? How will it know when configurations are changed in the server?
At: https://github.com/amenezes/config-client#using-standard-client
It is stated that get_attribute
method can be used:
# option 3: using get_attribute method
config_client.config.get_attribute('spring.cloud.consul.port')
but config_client.config
is a dictionary, and doesn't have that method.
It should be fixed to:
# option 3: using get_attribute method
config_client.get_attribute('spring.cloud.consul.port')
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.