carvel-dev / ytt

YAML templating tool that works on YAML structure instead of text
https://carvel.dev/ytt
Apache License 2.0
1.68k stars 137 forks source link

[Question] Is there a way to force the type of a value using ytt:data? #756

Closed arielly-parussulo closed 2 years ago

arielly-parussulo commented 2 years ago

Context

We use ytt data to handle template to use in our deployment. One of the values that we use in our deployment is the git commit as a tag for our Docker Images. Normally it works fine as YTT identify the git commit as a string and generates the final YAML file like:

parameters:
  app:
    tag: 427d910 # my git commit id

Problem

We are facing an issue with some of our git commits (e.g. 357e009) where YTT identify the value as a the number 3.57e+11 the final YAML becomes something like:

parameters:
  app:
    tag: 3.57e+11

My question is if there is a way to force YTT to understand values like 357e009 as a string.

vmunishwar commented 2 years ago

Hi, Thanks for reaching out! Declaring data values in schema ensures type safety in ytt. Schema supports configuring types of values as well as provide default values, so in this case, it might help declaring tag as a string in a schema file. Please check the example below and let us know if this helps. More information on this can be found here: Writing Schemas

vmunishwar commented 2 years ago
image
arielly-parussulo commented 2 years ago

Hello, @vmunishwar! I was exactly what I was looking for! Thanks!