Looking for a way to check if a class parameter is...
# forge-modules
j
Looking for a way to check if a class parameter is explicitly defined or if it's using the default value. Chat-GPT claims the
defined()
function can do this. Is that true? Never used this function before and official documentation doesn't seem to confirm that.
b
why do you need to know that?
j
Writing it out is making me doubt the use-case. But basically, I've got a legacy parameter, and a new parameter configured like this:
Copy code
Optional[String] $location                    = undef,
  Array[String] $uris                           = [$location], # deb822
I'd like to make the module error if both $location and $uris are explicitly defined by the user. But it's perfectly fine for one or the other to be defined by the user. I'm basically trying to ensure backward compatibility while moving from a String type to an Array[String]
b
raise a deprecation notice if
$location
is set?
j
Yeh I might be overthinking this. I might ignore this warning/error handling for now and let module maintainers decide on the correct logic. This is a merge request I'm working on for puppetlabs-apt
b
you can also call `fail()`when both are set
j
Thanks I'll look into this. 👍 Much appreciated
👍 1