-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: validate secrets before action resolution (#6822)
* fix: validate secrets before action resolution Validate missing secrets when instantiating a `ResolveActionTask` , rather than when adding configs. This would ensure we only get the error when missing secrets would actually cause a failure for the given command, while still failing relatively early even if the action happens to use another action’s outputs. * test: ensure that `ResolveActionTask` constructor throws correct error if action references missing secrets when user is not logged in * test: ensure that `scanAndAddConfigs` does not throw if an action references missing secrets The missing secrets check was moved to `ResolveActionTask` constructor. * test: ensure that `scanAndAddConfigs` does not throw if an action references missing secrets The missing secrets check was moved to `ResolveActionTask` constructor. * test: ensure that `scanAndAddConfigs` does not throw if a module references missing secrets * test: ensure that `scanAndAddConfigs` does not throw if a workflow references missing secrets * test: remove unused directory * test: rename test projects * test: create surrounding context for missing secrets in "scanAndAddConfig" tests suite * fix: fail-fast before workflow execution if any step references missing secrets * test: restore the state of the shared test data after the secrets test * test: add assertions for Garden state * Not logged in * Has no secrets * refactor: extract helper function to compose error message * chore: fix lint error * refactor: convert positional args to param object in `throwOnMissingSecretKeys` * refactor: convert positional args to param object in `detectMissingSecretKeys` * refactor: extract function to create error message footer * chore: make function `throwOnMissingSecretKeys` aware of the login state * test: fix test to expect an error * chore: more informative error message footer on missing secrets The error message depends on the login status to be less confusing. * test: ensure that `ResolveActionTask` constructor throws correct error if module references missing secrets * fix: skip `${secrets.*}` references evaluation in `ModuleResolver` Some secrets might be missing and not resolvable now, because the missing secrets check was moved to `ResolveActionTask` constructor. * chore: add a link to the secrets guide in the error message * improvement: better error message if the secrets have not been fetched * test: re-work negative tests a bit
- Loading branch information
1 parent
cd0fbcd
commit 55e7308
Showing
14 changed files
with
337 additions
and
89 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: garden.io/v1 | ||
kind: Project | ||
name: test-project-missing-secrets-in-action | ||
environments: | ||
- name: local | ||
providers: | ||
- name: local-kubernetes | ||
environments: [ local ] |
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: Run | ||
name: run-with-missing-secrets | ||
type: exec | ||
description: This should not fail while config scan | ||
spec: | ||
command: [ "echo", "${secrets.missing}" ] |
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
17 changes: 0 additions & 17 deletions
17
core/test/data/missing-secrets/workflow/module-a/garden.yml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.