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

Force string variable in form of a number in scientific notation to remain string #381

Open
MichalChromcak opened this issue Aug 21, 2024 · 1 comment

Comments

@MichalChromcak
Copy link

MichalChromcak commented Aug 21, 2024

Issue

Hello,

Today I bumped into an interesting issue - having a variable (commit hash), that is in form of number in scientific notation (2445e120) being interpreted by spruce as a number instead of keeping is as a string.

I could not find a way how to force spruce to keep it as string.

Can you guide me on what is the best way to achieve the expected output?

Fix trials

Using grab

Content of test.yaml

image:
  tag: (( grab $CI_COMMIT_SHORT_SHA ))

Command

export CI_COMMIT_SHORT_SHA=2445e120
spruce merge test.yaml

Output

image:
  tag: .inf

Expected Output

image:
  tag: 2445e120

Using concat

Content of test.yaml

image:
  tag: (( concat "" $CI_COMMIT_SHORT_SHA ))

Command

export CI_COMMIT_SHORT_SHA=2445e120
spruce merge test.yaml

Output

image:
  tag: "2.445e+123"

Expected Output

image:
  tag: 2445e120

Context

Spruce version: v1.31.0

@geofffranks
Copy link
Owner

Looks like this was previously reported in #266, but has no fix. Feel free to PR a solution though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants