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

Bugfix config & templates #597

Merged
merged 2 commits into from
Aug 28, 2021
Merged

Bugfix config & templates #597

merged 2 commits into from
Aug 28, 2021

Conversation

kellerza
Copy link
Contributor

@kellerza kellerza commented Aug 26, 2021

Small config bugfix

  • integer zeros are also false, so this template test does not execute.

    {{ if .isis_idx }}
    do some isis config
    {{ end }}
    

    "0" would work - this is a string, but the more elegant solution for now is just not to use 0, but 1

    The only long term workaround I can think of at the moment to allow testing for explicit integer zero is to add a new template function... but still need to think this over :-/

  • config template show was switch around -- it always showed variables

  • missed a clab_link_ip rename in the base__vr-sros template

license: ~/license/sros.txt
config:
vars:
isis_iid: 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should use string then here in the examples? To indicate that values for numerical fields are better be provided as strings?

Or do you then need to change some custom templating functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason we need string is for the test if something exist (for optional parts of templates). The difference between "0" and 0 is so subtle it is really difficult to debug this.

I'm leaning toward creating an exists or has template function, so that will return true even if the var contains a 0 or a "0":

Testing for existence {{ if .somevar }} is the only reason we allow missing keys. In other words missing values render to <no value> or <nil>.

With an exists function we should then add Option("missingkey=error"),, which will fail with an errorif a key is missing, which makes finding mistakes (missing/misspelt vars much easier o find!)

So for now, it really does not matter... but a new template func and new render options is a bit more work than a quick bugfix, so don't believe that change should be a 17.1 bugfix candidate,- what do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I am not proposing to add new func in this pr
was just thinking if this "string" notation will stay for a while, then maybe we should use it in the examples

But doesn't really matter much, integer 1 is fine with me

@hellt hellt merged commit 4cfd579 into srl-labs:master Aug 28, 2021
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

Successfully merging this pull request may close these issues.

None yet

2 participants