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

fix(yaml,file) fail validation when the file does not exist #401

Merged
merged 2 commits into from
Nov 28, 2021

Conversation

dduportal
Copy link
Contributor

@dduportal dduportal commented Nov 26, 2021

This PR follows up #398 and adds a validation for the resources yaml and file.

It fails the validation if the specified file does not exist: it helps end user when they have a typo...

Example of output:

CONDITIONS:
===========

checkUsernameYaml
-----------------
ERROR: Validation error: the provided manifest configuration had the following validation errors:
Invalid spec for yaml resource: the file "toto;yaml" does not exist.

checkUsernameFile
-----------------
ERROR: Validation error: the provided manifest configuration had the following validation errors:
Invalid spec for yaml resource: the file "toto;yaml" does not exist.

Test

To test this pull request, you can run the following commands:

  • Nominal case (non regression):
go build -o dist/updatecli && ./dist/updatecli --config ./examples/updatecli.generic/yaml.yaml diff && ./dist/updatecli --config ./examples/updatecli.generic/file.yaml diff
  • Check the new validation failure:
# failing.yaml
sources:
  parentSource:
    kind: shell
    spec:
      command: echo olblak
conditions:
  checkUsernameFile:
    kind: file
    spec:
      file: toto;yaml
  checkUsernameFileEmpty:
    kind: file
    spec:
      file:
  checkUsernameYaml:
    kind: yaml
    spec:
      file: toto;yaml
      key: github.username
go build -o dist/updatecli && ./dist/updatecli --config ./failing.yaml

Additional Information

Tradeoff

Potential improvement

Signed-off-by: Damien Duportal <damien.duportal@gmail.com>
@dduportal dduportal marked this pull request as ready for review November 26, 2021 13:45
@dduportal dduportal added bug Something isn't working resource-file Resource of kind File resource-yaml Resource of kind YAML labels Nov 26, 2021
@dduportal dduportal added this to the 0.16.1 milestone Nov 26, 2021
@dduportal
Copy link
Contributor Author

@olblak I've added this (patch) PR to the 0.16.1. Sounds good to you?

@olblak olblak merged commit f9d55c3 into updatecli:main Nov 28, 2021
@dduportal dduportal deleted the fix/yaml-file-validation branch November 28, 2021 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resource-file Resource of kind File resource-yaml Resource of kind YAML
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants