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

dasel put --type string not working when converting to yaml #344

Closed
DeluxeOwl opened this issue Jul 13, 2023 · 5 comments · Fixed by #353
Closed

dasel put --type string not working when converting to yaml #344

DeluxeOwl opened this issue Jul 13, 2023 · 5 comments · Fixed by #353
Labels
bug Something isn't working

Comments

@DeluxeOwl
Copy link

Describe the bug
When I'm doing this:

dasel put --type string --file values.dev.yaml --selector "annotations.previousShortSHA" -v 1615

the value comes out as a number

annotations:
    branch: main
    previousShortSHA: 1615

Expected behavior
previousShortSHA should be "1615"

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS] ubuntu, manjaro
  • Version [e.g. 22] (dasel --version): 2.3.4

Additional context
I'm using ArgoCD for kubernetes and I was bitten by this when doing the following:

dasel put -t string --file "values.dev.yaml" --selector "annotations.previousShortSHA" -v "$(git rev-parse --short HEAD)"

and it so happened that "$(git rev-parse --short HEAD)" returned a number:
image

and ArgoCD threw an error because it expected a string

@DeluxeOwl DeluxeOwl added the bug Something isn't working label Jul 13, 2023
@TomWright
Copy link
Owner

I think this is a quoting issue. I'll take a look and potentially add some more flags to enable/disable string quoting when writing values.

@Argelbargel
Copy link

Hi. I've got a similar problem. I'm modifying an existing YAML file adding some keys. After writing it out as YAML empty string are converted to nil/null instead of empty strings. So this:

empty_value: ""

is converted to

empty_value:

which ist okay most of the time - except when the code reading the YAML checks explicitly for the empty string. So keeping the type/quoting empty values would be a great option

@TomWright
Copy link
Owner

I've been on holiday but will try to add the flag mentioned above once I've caught up with work

@TomWright
Copy link
Owner

I've added a fix in a way that avoids the need for a new flag. This will be released in the next version.

@TomWright
Copy link
Owner

tom ~ $ dasel -v
dasel version 2.3.5
tom ~ $ echo 'annotations:
  previousShortSHA: old' | dasel put -r yaml -t string -v '1615' 'annotations.previousShortSHA'
annotations:
    previousShortSHA: "1615"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants