Hi,

I should have payed much more attention in the programming lessons, or maybe it is because I took them too long ago ...

I'm trying to write a custom type, and I started with writing the rspec first, then the type definition, and somewhere in the future, i will have to write the providers.

I'm currently struggling with the following property : (it is openldap related)

I want to manage the configuration settings : 'olcAllow' witch contains a space separated list of keywords like "bind_v2 bind_anon_cred"

in the manifest it should say :

class myldap {

ldapconfig { 'config0':
  allow => ['bind_v2', 'bind_anon_cred'],
  ...
}

In the rspec file, i defined :

    it "should accept property allow" do
@test = Puppet::Type.type(:ldapconfig).new(:name => 'config', property => ['bind_v2', 'bind_anon_cred'] )
      @test[property].should == ['bind_v2', 'bind_anon_cred']
    end

And in the type code :

  newproperty(:allows, :array_matching => :all) do
    desc "Specify a set of features to be allowed."
newvalues(:bind_v2, :bind_anon_cred, :bind_anon_dn, :update_anon, :none)
    defaultto(:none)
    .....
  end


Running the unit test in this case will fail, because the array strings are converted to labels.

My question now, what is the proper way to solve this ?

a: the rspec should test for the array with labels, and postpone conversion to the provider code. b. Already translate the value provided in the manifest to the final required output, in this case, the array will be converted to a sorted string of space separated allowed keyboards.

I'm leaning towards b. This gives the possibility to do more accurate value checking of the parameters, and error will be catched during catalog compilation. On the other hand, the provider could validate the values using in this case the installed ldap utilities for testing, and errors will generate a runtime error when executing the catalog on the client. But i don't like the possibility to misconfigure, and break the ldap configuration by a puppet run.

I still have not a clue what should go in the provider code, and what should be handled by the type definition. But it feels right to me too do all validation and data transformation.

Grts

johan

--
Johan De Wit

Open Source Consultant

Red Hat Certified Engineer         (805008667232363)
Puppet Certified Professional 2013 (PCP0000006)
_________________________________________________________
Open-Future Phone +32 (0)2/255 70 70
Zavelstraat 72              Fax       +32 (0)2/255 70 71
3071 KORTENBERG             Mobile    +32 (0)474/42 40 73
BELGIUM                     http://www.open-future.be
_________________________________________________________
Next Events:
Puppet Advanced Training | 
https://www.open-future.be/puppet-advanced-training-12-till-14th-november
Zabbix Certified Training | 
http://www.open-future.be/zabbix-certified-training-18-till-20th-november
Zabbix Large Environments Training | 
http://www.open-future.be/zabbix-large-environments-training-21-till-22nd-november
Puppet Fundamentals Training | 
http://www.open-future.be/puppet-fundamentals-training-10-till-12th-december
Subscribe to our newsletter | http://eepurl.com/BUG8H

--
You received this message because you are subscribed to the Google Groups "Puppet 
Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/528B38F3.7060200%40open-future.be.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to