https://www.puppet.com/community logo
Join Slack
Powered by
# voxpupuli
  • y

    Yury Bushmelev

    07/14/2023, 6:06 PM
    yeah, I’d do the same as @smortex suggested.. but we have to deal with legacy here..
  • v

    VoxBot

    07/14/2023, 6:06 PM
    actually when the EPP has Variant[String, Array[String]] $raw_append = [] I think that the epp() method can use undef
  • s

    smortex

    07/14/2023, 6:06 PM
    This clearly breaks backwards compatibility, but makes the templates much more straightforward to process (in my brain, I think my computer does not see a difference)
  • v

    VoxBot

    07/14/2023, 6:06 PM
    it'll use the default value from the EPP in that case, which is an empty array
  • y

    Yury Bushmelev

    07/14/2023, 6:07 PM
    hm.. btw, yes.. can try to use Undef + [] as default in EPP.. let me try
  • y

    Yury Bushmelev

    07/14/2023, 6:08 PM
    but again if $raw_append is String it’ll pass the string into $raw_append.each
  • y

    Yury Bushmelev

    07/14/2023, 6:09 PM
    so either it should be preconverted to an array or we may need the magic in the template
  • v

    VoxBot

    07/14/2023, 6:09 PM
    another solution is epp('file.pp', { 'raw_append' => pick($raw_append, []) })
  • v

    VoxBot

    07/14/2023, 6:10 PM
    but I'd even argue that
    Optional[Variant[Array, String]] $raw_append = undef
    to
    Variant[String, Array[String]] $raw_append = []
    is non-breaking because you can't really pass in undef (technically you can via Hiera, but that's a bit of an edge case IMHO)
  • y

    Yury Bushmelev

    07/14/2023, 6:23 PM
    agree.. let’s switch from undef to [] and drop Optional
    👍 1
  • b

    bastelfreak

    07/14/2023, 6:43 PM
    @Yury Bushmelev thats what our style guide recommends anyways
    👍🏻 1
  • y

    Yury Bushmelev

    07/14/2023, 6:47 PM
    it fixes the issue, thank you for all the suggestions!
  • y

    Yury Bushmelev

    07/14/2023, 6:52 PM
    I guess I can do the same for
    Optional[Hash] $mailhost_cfg_prepend           = undef,
    which is Variant of 2 Hash-es actually
  • y

    Yury Bushmelev

    07/14/2023, 6:52 PM
    I’ll make it
    {}
    by default
  • s

    smortex

    07/14/2023, 6:52 PM
    👍
  • y

    Yury Bushmelev

    07/14/2023, 6:54 PM
    omg.. according to tests it’s not that easy.. there are some String variants too..
  • y

    Yury Bushmelev

    07/14/2023, 6:57 PM
    can I do Hash[Variant[…]] or it should be Variant[Hash[…], Hash[…]]?
  • y

    Yury Bushmelev

    07/14/2023, 6:58 PM
    ah, well.. I can do Hash[Variant[], Variant[]] I guess..
    🤢 1
  • s

    smortex

    07/14/2023, 7:02 PM
    If you can,
    Hash[String[1], Variant[...]]
    is probably the easiest first move
  • s

    smortex

    07/14/2023, 7:03 PM
    Then
    Struct[]
    can allow awesome things, but it can only be a long-term plan given the current state of the module.
  • y

    Yury Bushmelev

    07/14/2023, 7:04 PM
    Copy code
    Hash[String, Variant[
          Hash[String, Array[String]],
          Array[String],
          String,
      ]] $mailhost_cfg_append                        = {},
  • y

    Yury Bushmelev

    07/14/2023, 7:05 PM
    this is the current definition matching the unit tests 😕
    😭 1
  • y

    Yury Bushmelev

    07/14/2023, 7:12 PM
    I bet Hiera did this 🙂
  • y

    Yury Bushmelev

    07/14/2023, 7:13 PM
    did you know that the Hash above is sorted by keys in the templates? 🙂
  • v

    vchepkov

    07/14/2023, 7:14 PM
    At this point you can just use
    Data
    🙂
  • y

    Yury Bushmelev

    07/14/2023, 7:14 PM
    weirdest thing out there is that someone made some smart tricks and all their configs are based on playing with that badly 😞
  • y

    Yury Bushmelev

    07/14/2023, 7:15 PM
    I’m 99% sure there is at least one such setup
  • v

    VoxBot

    07/14/2023, 7:21 PM
    one thing to consider is that you can use Puppet functions to transform data as well - perhaps some private helpers to normalize it would be beneficial?
  • v

    VoxBot

    07/14/2023, 7:23 PM
    no idea if it helps here, but throwing it out there as an option
  • y

    Yury Bushmelev

    07/14/2023, 7:26 PM
    ty, I’ll think about.. I just realised I missed few more variants in the definition above.. nested Hash can have String, String variant too
1...555556557...648Latest