Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Spring Boot Cloud Config #1230

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

lony2003
Copy link

@lony2003 lony2003 commented Mar 4, 2025

Description

A new library that implement a backend of Spring Cloud Config.

Originally from https://github.com/fangkehou-team/dapr-spring, this library created a backend of SpringCloudConfig just like SpringCloudVault.
The original library only uses secret store as config store api is not stable at that time.
As the configuration api is stable now, the config loader using that api would be implemented later.

Not all things have done, will be updated later, please leave this pull request open.

Issue reference

this PR will close: #1225

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

@lony2003 lony2003 requested review from a team as code owners March 4, 2025 02:32
@lony2003 lony2003 force-pushed the development-cloudconfig branch 3 times, most recently from 25b3e33 to 2b4022b Compare March 4, 2025 03:14
lony2003 added 2 commits March 4, 2025 11:14
…dcoded prefix(dapr#1225)

create a public static final value PROPERTY_PREFIX in DaprClientProperties
change the prefix value in the ConfigurationProperties to DaprClientProperties.PROPERTY_PREFIX
Dapr Cloud Config rely on that.

Signed-off-by: lony2003 <zhangke200377@outlook.com>
…of Spring Cloud Config(dapr#1225)

Originally from https://github.com/fangkehou-team/dapr-spring, this library created a backend of SpringCloudConfig just like SpringCloudVault.
The original library only uses secret store as config store api is not stable at that time.
As the configuration api is stable now, the config loader using that api would be implemented later.

Signed-off-by: lony2003 <zhangke200377@outlook.com>
@salaboy
Copy link
Contributor

salaboy commented Mar 4, 2025

@lony2003 first of all, thanks so so much for contributing back with this. This is highly appreciated.. I will start adding comments in the PR with small details that we need to fix and questions about how this would work.

It will be great if you can add as part of this PR an example on the spring-boot-examples/ directory showing how this functionality would work. We probably also need tests inside sdk-tests to demonstrate that this works from a client point of view. You will notice that we are heavily relying on Testcontainers for all of this, so it will be quite cool to see if the testcontainers integration is missing something to support this functionality.

import io.dapr.spring.boot.autoconfigure.client.DaprClientProperties;
import io.dapr.spring.boot.autoconfigure.client.DaprConnectionDetails;

class CloudConfigPropertiesDaprConnectionDetails implements DaprConnectionDetails {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lony2003 do we need to duplicate the DaprConnectionDetails, why are these different for the normal DaprConnectionDetails?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No difference, just because the PropertyDaprConnectionDetails is protected and can't be used in another package.

@lony2003
Copy link
Author

lony2003 commented Mar 4, 2025

@lony2003 first of all, thanks so so much for contributing back with this. This is highly appreciated.. I will start adding comments in the PR with small details that we need to fix and questions about how this would work.

It will be great if you can add as part of this PR an example on the spring-boot-examples/ directory showing how this functionality would work. We probably also need tests inside sdk-tests to demonstrate that this works from a client point of view. You will notice that we are heavily relying on Testcontainers for all of this, so it will be quite cool to see if the testcontainers integration is missing something to support this functionality.

Thanks. the code is not completed currently, I created this pull request is for the problems in issue #1225 , I think we need a schema for cloud config url, and have some other things to be discussed😊😊😊

@lony2003
Copy link
Author

lony2003 commented Mar 5, 2025

Cloud Config Import Schemas

Secret Store Component

url structure

dapr:secret:<store-name>[/<secret-name>][?<paramters>]

paramters

parameter description default available
type value type value value/doc
  • when type = value, if secret-name is specified, will treat secret as the value of property, and secret-name as the key of property; if none secret-name is specified, will get bulk secret and treat every value of secret as the value of property, and every key of secret as the key of property.
  • when type = doc, if secret-name is specified, will treat secret as a bunch of property, and load it with property or yaml loader; if none secret-name is specified, will get bulk secret and and treat every value of secret as bunches of property, and load them with property or yaml loader.
  • secret store with multiValud = true must specify nestedSeparator = ".", and using type = doc is not recommanded

demo

multiValued = false:

store content(file secret store as example)
{
	"dapr.spring.demo-config-secret.singlevalue": "testvalue",
	"multivalue-properties": "dapr.spring.demo-config-secret.multivalue.v1=spring\ndapr.spring.demo-config-secret.multivalue.v2=dapr",
	"multivalue-yaml": "dapr:\n  spring:\n    demo-config-secret:\n      multivalue:\n        v3=cloud"
}
valid demo url
  • dapr:secret:democonfig/multivalue-properties?type=doc
  • dapr:secret:democonfig/multivalue-yaml?type=doc
  • dapr:secret:democonfig/dapr.spring.demo-config.singlevalue?type=value
  • dapr:secret:democonfig?type=value
  • dapr:secret:democonfig?type=doc

multiValued = true, nestedSeparator = ".":

store content(file secret store as example)
{
	"value1": {
		"dapr": {
			"spring": {
				"demo-config-secret": {
					"multivalue": {
						"v4": "config"
					}
				}
			}
		}
	}
}

will be read as

{
	"value1": {
		"dapr.spring.demo-config-secret.multivalue.v4": "config"
	}
}
valid demo url
  • dapr:secret:demo-config-multi/value1?type=value
  • dapr:secret:demo-config-multi?type=value

Configuration Component

url structure

dapr:config:<store-name>[/<key>][?<paramters>]

paramters

parameter description default available
type value type value doc/value
subscribe subscribe this configuration false true/false
  • when subscribe = true, will subscribe update for the configuration.
  • when type = value, if key is specified, will treat config value as the value of property, and key as the key of property; if none key is specified, will get all key and value in the config-name and treat every config value as the value of property, and every key as the key of property.
  • when type = doc, if key is specified, will treat config value as a bunch of property, and load it with property or yaml loader; if none key is specified, will get all key and value in the config-name and treat every config value as bunches of property, and load them with property or yaml loader.

Demo

store content(table as example)

key value
dapr.spring.demo-config-config.singlevalue testvalue
multivalue-properties dapr.spring.demo-config-config.multivalue.v1=spring\ndapr.spring.demo-config-config.multivalue.v2=dapr
multivalue-yaml dapr:\n spring:\n demo-config-config:\n multivalue:\n v3=cloud

valid demo url

  • dapr:config:democonfigconf/dapr.spring.demo-config-config.singlevalue?type=value
  • dapr:config:democonfigconf/multivalue-properties?type=doc
  • dapr:config:democonfigconf/multivalue-yaml?type=doc
  • dapr:config:democonfigconf?type=doc
  • dapr:config:democonfigconf?type=value

lony2003 and others added 4 commits March 5, 2025 18:52
…porter

Implemented the configuration importer using dapr client configuration api
also done a style check

Signed-off-by: lony2003 <zhangke200377@outlook.com>
Signed-off-by: lony2003 <zhangke200377@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A Cloud Config Client for SpringBoot, like Spring Cloud Vault
2 participants