-
Notifications
You must be signed in to change notification settings - Fork 273
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
fix(dev): fix reload error when using templates #5329
Merged
+225
−19
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -481,6 +481,17 @@ export function getEnvVarName(identifier: string) { | |
return identifier.replace(/-/g, "_").toUpperCase() | ||
} | ||
|
||
/** | ||
* Removes all keys from `obj` (except those inherited from the object's prototype). | ||
* | ||
* Essentially a vanilla object analog of `map.clear()` for ES5 Maps. | ||
*/ | ||
export function clearObject<T extends object>(obj: T) { | ||
for (const key of Object.getOwnPropertyNames(obj)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question as above. |
||
delete obj[key] | ||
} | ||
} | ||
|
||
/** | ||
* Picks the specified keys from the given object, and throws an error if one or more keys are not found. | ||
*/ | ||
|
9 changes: 9 additions & 0 deletions
9
core/test/data/test-projects/config-template-reloading/actions.garden.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
kind: RenderTemplate | ||
template: combo | ||
name: foo | ||
inputs: | ||
name: test | ||
# Resolvable at parse time | ||
envName: ${environment.name} | ||
# Resolvable later | ||
providerKey: ${providers.test-plugin.outputs.testKey} |
7 changes: 7 additions & 0 deletions
7
core/test/data/test-projects/config-template-reloading/project.garden.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: garden.io/v1 | ||
kind: Project | ||
name: config-templates | ||
environments: | ||
- name: local | ||
providers: | ||
- name: test-plugin |
14 changes: 14 additions & 0 deletions
14
core/test/data/test-projects/config-template-reloading/schema.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"type": "string" | ||
}, | ||
"envName": { | ||
"type": "string" | ||
}, | ||
"providerKey": { | ||
"type": "string" | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
core/test/data/test-projects/config-template-reloading/templates.garden.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
kind: ConfigTemplate | ||
name: combo | ||
inputsSchemaPath: schema.json | ||
configs: | ||
- kind: Build | ||
type: test | ||
name: ${parent.name}-${inputs.name} | ||
include: [] | ||
spec: | ||
command: [echo, "echo-prefix", "${inputs.name}"] | ||
- kind: Deploy | ||
type: test | ||
name: ${parent.name}-${inputs.name} | ||
build: ${parent.name}-${inputs.name} | ||
- kind: Test | ||
type: test | ||
name: ${parent.name}-${inputs.name} | ||
dependencies: ["build.${parent.name}-${inputs.name}"] | ||
spec: | ||
command: [echo, "${inputs.envName}", "${inputs.providerKey}"] | ||
|
||
--- | ||
|
||
kind: ConfigTemplate | ||
name: workflows | ||
configs: | ||
- kind: Workflow | ||
name: ${parent.name}-${inputs.name} | ||
steps: | ||
- script: echo "${inputs.envName}" |
6 changes: 6 additions & 0 deletions
6
core/test/data/test-projects/config-template-reloading/workflows.garden.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: RenderTemplate | ||
template: workflows | ||
name: foo | ||
inputs: | ||
name: test | ||
envName: ${environment.name} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pardon me ignorance but why use
getOwnPropertyNames
instead ofkeys
?