Closed zong-zhe closed 2 weeks ago
This PR performs configuration merge in the api ListVariable().
Taking the following base.k and main.k as cases to explain the process of this configuration merge.
base.k
main.k
appConfiguration: AppConfiguration { resource: res.Resource { disk = "35Gi" } }
appConfiguration: AppConfiguration { resource: res.Resource { cpu = "2" memory = "4Gi" } }
Using appConfiguration.resource as the spec, ListVariables() will select two sub-trees in the AST and merge them.
appConfiguration.resource
After base.k and main.k are parsed by the KCL parser, the AST will be as follows:
appConfiguration -> resource -> {cpu="2", memory="4Gi"} -> resource -> {disk = "35Gi"}
api ListVariables() will get the two sub-trees
ListVariables()
appConfiguration -> resource -> {cpu="2", memory="4Gi"} appConfiguration -> resource -> {disk = "35Gi"}
Then merge them:
appConfiguration -> resource -> {cpu="2", memory="4Gi", disk = "35Gi"}
Based on the spec appConfiguration.resource, it returns the corresponding configuration block {cpu="2", memory="4Gi", disk = "35Gi"}.
{cpu="2", memory="4Gi", disk = "35Gi"}
1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):
2. What is the scope of this PR (e.g. component or file name):
3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):
This PR performs configuration merge in the api ListVariable().
Taking the following
base.k
andmain.k
as cases to explain the process of this configuration merge.base.k
main.k
Using
appConfiguration.resource
as the spec, ListVariables() will select two sub-trees in the AST and merge them.After
base.k
andmain.k
are parsed by the KCL parser, the AST will be as follows:api
ListVariables()
will get the two sub-treesThen merge them:
Based on the spec
appConfiguration.resource
, it returns the corresponding configuration block{cpu="2", memory="4Gi", disk = "35Gi"}
.4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):
5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links: