GithubHelp home page GithubHelp logo

Deprecation Request about puppet-boolean HOT 13 CLOSED

voxpupuli avatar voxpupuli commented on July 20, 2024
Deprecation Request

from puppet-boolean.

Comments (13)

alexjfisher avatar alexjfisher commented on July 20, 2024 1

I don't see how this module provides any benefit over what's now been in core puppet for years. https://github.com/puppetlabs/puppet/blob/e257636f1f3a7024593e33571d7eb5e2686744fc/lib/puppet/coercion.rb

However, I still think both implementations are broken for properties.

FWIW, subscription-manager doesn't use this anymore. waveclaw/puppet-subscription_manager@2c71a37#diff-490694a9db8f7a371538da1abe484314

from puppet-boolean.

waveclaw avatar waveclaw commented on July 20, 2024 1

I dropped boolean support completely in favor of treating the values as enumerations with exclusive dual values. The core feature is unusable and puppet-boolean has challenges in Puppet 6.

My decision for supporting my modules should not affect your decisions on support of your code. I picked a pragmatic solution that supported external and internal customers of my code. Treating boolean logic as a special cased enumeration is not ideal but functional.

from puppet-boolean.

bastelfreak avatar bastelfreak commented on July 20, 2024

I'm not sure how this boolean magic works, but if those files can replace this repo, than +1 for deprecation

from puppet-boolean.

ekohl avatar ekohl commented on July 20, 2024

I recall that @alexjfisher discovered those built in types are unusable due to bugs but it might be good to ensure the built in types do work and we can deprecate this repo.

from puppet-boolean.

TraGicCode avatar TraGicCode commented on July 20, 2024

At first glance and when accompanied with basic tests of a custom type i'm working on it seems to be working as i would expect.

require 'puppet/parameter/boolean'

Puppet::Type.newtype(:wsusserver_approvalrule) do
    
   newproperty(:enabled, :parent => Puppet::Property::Boolean) do
        desc 'Specifies whether the rule is enabled or disabled.'
    end

end

Matcher to check for boolean type

RSpec::Matchers.define :be_boolean do
    match do |value|
      [true, false].include? value
    end
  end
  

Test verifies things get munged to booleans

    [true, false, 'yes', 'no'].each do |value|
        it "should accept #{value} as a value for :enabled" do
            expect(type_class.new(name: 'test', ensure: :present, enabled: value))
        end

        it "should be munge #{value} to true or false" do
            expect(type_class.new(name: 'test', ensure: :present, enabled: value)[:enabled]).to be_boolean
        end
    end

    it "should convert yes to true" do
        expect(type_class.new(name: 'test', ensure: :present, enabled: 'yes')[:enabled]).to be true
    end

    it "should convert no to false" do
        expect(type_class.new(name: 'test', ensure: :present, enabled: 'no')[:enabled]).to be false
    end

from puppet-boolean.

ekohl avatar ekohl commented on July 20, 2024

At first glance it appears to work but theforeman/puppet-pulp#284 showed there were edge cases where it didn't. Maybe I shouldn't have included defaults when I refactored and I haven't had time to properly review it.

from puppet-boolean.

alexjfisher avatar alexjfisher commented on July 20, 2024

@TraGicCode Try updating a boolean property from true to false...

from puppet-boolean.

alexjfisher avatar alexjfisher commented on July 20, 2024

https://tickets.puppetlabs.com/browse/PUP-2368

from puppet-boolean.

alexjfisher avatar alexjfisher commented on July 20, 2024

Having said that, I can't see why this module is any better. However you munge to false, if param.should will always be false and it's still not possible to sync the property from true to false.
https://github.com/puppetlabs/puppet/blob/77017e41a1fbea88abc0d59b29d24fc8a292299c/lib/puppet/transaction/resource_harness.rb#L123

The fix is probably

unless param.nil? && !param.safe_insync?(current_value)

from puppet-boolean.

TraGicCode avatar TraGicCode commented on July 20, 2024

Thanks for the input @alexjfisher . Strange this has been around so long. Reminds me of the isrequired method still left behind on the type on the Puppet::Type class

from puppet-boolean.

wyardley avatar wyardley commented on July 20, 2024

I've mentioned this elsewhere, I think, but I find it kind of odd that the desired behavior for booleans with types / providers is to allow true, false, "true", "false", "yes", etc., when the Puppet language types only allow true / false. Am I the only one who finds this a little inconsistent?

Assuming you just want to allow those, wouldn't something like this work?
https://github.com/voxpupuli/puppet-rabbitmq/blob/master/lib/puppet/type/rabbitmq_erlang_cookie.rb#L24-L27

from puppet-boolean.

waveclaw avatar waveclaw commented on July 20, 2024

I have to use this or Adrien Thebo's version because I'm munging 1's and 0's to true and false on some of the parameters for the subscription-manager module.

It is really unpleasant but a user visible issue with the underlying system Puppet is abstracting. As a bonus, outputting the wrong entry in a property breaks the commands underlying the provider. Some can silently take the string true, others must be 1 or 0.

Likewise, letting the property take on 1, 0, true, false or string equivalents means I'm letting a user direct mapping the expected resource appearance into Puppet. No need to explain that what is a true (takes 1 or 0) property or a regular boolean (takes true or false). The resource statement can be written to look like the actual on disk config. And I munge the values back to true or false correctly.

from puppet-boolean.

bastelfreak avatar bastelfreak commented on July 20, 2024

I will proceed and archive the module.

from puppet-boolean.

Related Issues (8)

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.