Code Monkey home page Code Monkey logo

Comments (12)

danielcoman avatar danielcoman commented on August 25, 2024 2

@ecojan Well... it's not implemented. Quotation is only used as an example.

I've only used quotes as an example on escaping values. Wanted to use something else but thought quotation would be more familiar and easy to visualize.

Conclusions from this thread is that the feature needed is not a flag or a list of keys to ignore in interpolation validation, but proper escaping for values.

from himl.

amuraru avatar amuraru commented on August 25, 2024 1

I think we can use a similar escape sequence as in go templates:

{{`this is a {{value}} that should not be interpolated`}}

/cc @costimuraru

from himl.

danielcoman avatar danielcoman commented on August 25, 2024

I can see this as a valid use case resolved right now by the flag you mentioned 'skip_interpolation_validation=True'.
Also, excluse will completely remove the key before any interpolation. I'm thinking you want something that will not do validation on specified keys. This has the potential to be missused or get cumbersome with more than a few keys that you need to keep track of.

Can you elaborate more on your use case and why just disabling validation doesn't work?

from himl.

ecojan avatar ecojan commented on August 25, 2024

Can you elaborate more on your use case and why just disabling validation doesn't work?

I see the validation as a safety net, something that must be interpolated but doesn't get interpolated due to an error should come up when running himl. On the other hand if there are some keys that you specifically don't want to interpolate (leave them as they are), here is where I would see the advantage of having an option to exclude the aforementioned key from the interpolation process.

WDYT?

from himl.

danielcoman avatar danielcoman commented on August 25, 2024

Yes, validation good.
Still interested in your use case, if you can elaborate on that.
At first glance seems you are trying to use hiera as a template engine to template a template and I don't think this is a good use case.

from himl.

ecojan avatar ecojan commented on August 25, 2024

Yes, validation good.
Still interested in your use case, if you can elaborate on that.
At first glance seems you are trying to use hiera as a template engine to template a template and I don't think this is a good use case.

I'm not sure what you are referring to or how hiera is tied in here.
My use case is as follow:

I have the following yaml file in one of the subdirectories traversed by himl

slack_configs:
- channel: my-channel
   text: '{{ template "__slack_text" . }}'

I'm just trying to ignore the text key during interpolation here as it would crash the himl processing without disabling validation. The value for the text key ( '{{ template "__slack_text" . }}' ) is gonna be used later in the obtained output by something independent of himl (again just trying to ignore a key).

from himl.

ecojan avatar ecojan commented on August 25, 2024

The issue is when using himl on a configuration that needs to be passed to a different application that is using the same format "{{"and "}}"

from himl.

danielcoman avatar danielcoman commented on August 25, 2024

Seems that what you need is to escape the key value. For example, using double quotes in key: "{{ val }}" resolves the interpolation, but using single quotes key: '{{ val }}' results in the literal {{ val }} string. I think instead of manually ignoring some keys it would be better to support escaping interpolation on values. Would this fit your use case?

from himl.

amuraru avatar amuraru commented on August 25, 2024

Escaping interpolation is the keyword here, yes.

Double quote vs single quote seems weak though.
The himl user should be able to explicitly turn off interpolation within a value.
And it may not be possible to implement, when parsing value in https://github.com/adobe/himl/blob/master/himl/interpolation.py#L17

key: "value", key: 'value' and key: value are equivalent in yaml parser. you get the value string

from himl.

danielcoman avatar danielcoman commented on August 25, 2024

I've only used quotes as an example on escaping values. Wanted to use something else but thought quotation would be more familiar and easy to visualize.

from himl.

amuraru avatar amuraru commented on August 25, 2024

Cool - makes sense

from himl.

ecojan avatar ecojan commented on August 25, 2024

@danielcoman I tried escaping via single quotes vs double quotes.
None of them have worked, they both are equivalent as @amuraru said.
One option that can actually make it work is "--skip-interpolation-resolving" but this is not actual escaping and is turning off other features.

from himl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.