Giter Club home page Giter Club logo

Comments (6)

solarkennedy avatar solarkennedy commented on May 24, 2024

Yea, we explicitly try to "cast" these into ints for service:
https://github.com/solarkennedy/puppet-consul/blob/master/manifests/service.pp#L49

Then we do it on a bit more keys here:
https://github.com/solarkennedy/puppet-consul/blob/master/manifests/config.pp#L82-L98

I'm... up for suggestions?

We could take a advantage of the fact that we have a custom function to write the json down:
https://github.com/solarkennedy/puppet-consul/blob/master/lib/puppet/parser/functions/consul_sorted_json.rb

In ruby we could look at each key, and if it looks like an int, make it an int?
Seems a little dangerous, but a tad better than whitelisting keys?

from puppet-consul.

aj-jester avatar aj-jester commented on May 24, 2024

Something like this?

irb(main):001:0> iffy_integers = [-1, '+1', '-goats', 'moats-', '8500', '2+3', '-3454', '-this is A-']
=> [-1, "+1", "-goats", "moats-", "8500", "2+3", "-3454", "-this is A-"]

irb(main):002:0> iffy_integers.map { |i| (i.kind_of?(String) and i.match(/\A[-]?[0-9]+\z/)) ? i.to_i : i }
=> [-1, "+1", "-goats", "moats-", 8500, "2+3", -3454, "-this is A-"]

from puppet-consul.

solarkennedy avatar solarkennedy commented on May 24, 2024

Yea, that looks like it achieves the desired effect.
@aj-jester want me to whip that into a PR or did you want to?

from puppet-consul.

aj-jester avatar aj-jester commented on May 24, 2024

@solarkennedy #156

from puppet-consul.

solarkennedy avatar solarkennedy commented on May 24, 2024

@weitzj this should be fixed on the latest master thanks to @aj-jester

from puppet-consul.

weitzj avatar weitzj commented on May 24, 2024

Thank you. :)

from puppet-consul.

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.