Hi Ben, to avoid having server-side code, the Resource API doesn't have a way to validate complex restrictions like this at compile time. You can either collapse this into a single attribute of type `Variant[Boolean, String]` or adding the validation in the provider at the time `set`/`create`/`update`/`delete` get called. throwing an exception from those methods will tell puppet that the resource application failed and present the exception message to the user.
Regards, David On Wed, 4 Dec 2019 at 16:34, Benjamin Ridley <[email protected]> wrote: > Hi all, > > I'm developing a resource that allows the declaration of keys in the Etcd > key value store. > > My type looks like this: > > Puppet::ResourceApi.register_type( > name: 'etcd_key', > docs: 'This type allows the management of etcd keys as Puppet > resources.', > attributes: { > ensure: { > type: 'Enum[present, absent]', > desc: 'Whether the key should be present in the etcd structure.', > default: 'present', > }, > path: { > type: 'String', > desc: 'The path of the key you want to manage in the etcd > structure.', > behaviour: :namevar, > }, > directory: { > type: 'Boolean', > desc: 'Whether this key is a directory or not.', > default: false, > }, > value: { > type: 'String', > desc: 'The value of the key. Mutually exclusive if with > is_directory => true.', > }, > }, > ) > > > What I want to be able to do is make the value/directory parameters > mutually exclusive as a directory does not have a 'value' in etcd, and > similarly a key with a value cannot be a directory. Currently though, > Puppet complains that I'm excluding required parameters when I declare them. > > Is this possible with the resource API or do I need to use the low level > provider implementation? > > Thanks! Ben > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" 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-users/5bb1535f-0c14-4aee-98f6-91fd7d68c4f7%40googlegroups.com > <https://groups.google.com/d/msgid/puppet-users/5bb1535f-0c14-4aee-98f6-91fd7d68c4f7%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Puppet Users" 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-users/CALF7fHabirW2qbHF%3DdVWytoyrcvyhNjJXt2jim3d17ndqjqrWw%40mail.gmail.com.
