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

    Alex Fisher

    06/08/2022, 2:07 PM
    Something other than https://github.com/puppetlabs/puppet/blob/ac45fe2b783708f64cb3a28f21ee92673e1f3216/lib/puppet/parser/functions.rb#L161 ???
  • a

    Alex Fisher

    06/08/2022, 2:07 PM
    Something other than https://github.com/puppetlabs/puppet/blob/ac45fe2b783708f64cb3a28f21ee92673e1f3216/lib/puppet/parser/functions.rb#L161 ???
  • a

    Alex Fisher

    06/08/2022, 2:29 PM
    @ewoud Found it! https://github.com/puppetlabs/puppet/blob/ac45fe2b783708f64cb3a28f21ee92673e1f3216/lib/puppet/pops/model/factory.rb#L969
  • a

    Alex Fisher

    06/08/2022, 2:29 PM
    @ewoud Found it! https://github.com/puppetlabs/puppet/blob/ac45fe2b783708f64cb3a28f21ee92673e1f3216/lib/puppet/pops/model/factory.rb#L969
  • v

    VoxBot

    06/08/2022, 2:30 PM
    ah, interesting
  • v

    VoxBot

    06/08/2022, 2:30 PM
    what kind of odd archeology lesson are we listening to today?
  • v

    VoxBot

    06/08/2022, 2:31 PM
    so the whole statement option to newfunction() does nothing?
  • a

    Alex Fisher

    06/08/2022, 2:32 PM
    I'm pleased I didn't have to resort to getting @josh or @helindbe here to explain it to us! 🙂
  • v

    VoxBot

    06/08/2022, 2:32 PM
    or only signify that it has no return value, but puppet-strings doesn't understand that?
  • a

    Alex Fisher

    06/08/2022, 2:33 PM
    Maybe he is needed after all! Why was the idea of having a function that explicitly never returned anything left out of the 4x api spec.
  • a

    Alex Fisher

    06/08/2022, 2:35 PM
    anyway... I don't think converting ensure_packages to a 4x function is breaking because of this. One possible reason it could be though is if there are any 3x functions calling it internally. Since this is a module, and not core puppet, I think I can live with that.
  • v

    VoxBot

    06/08/2022, 2:35 PM
    perhaps you can end with nil and add a return_type Undef?
  • a

    Alex Fisher

    06/08/2022, 2:37 PM
    yeah, suppose so. I could also add a 3x shim with deprecation notice.
  • a

    Alex Fisher

    06/08/2022, 2:37 PM
    like is done in eg. https://github.com/puppetlabs/puppet/blob/ac45fe2b783708f64cb3a28f21ee92673e1f3216/lib/puppet/parser/functions/contain.rb#L27
  • a

    Alex Fisher

    06/08/2022, 2:37 PM
    like is done in eg. https://github.com/puppetlabs/puppet/blob/ac45fe2b783708f64cb3a28f21ee92673e1f3216/lib/puppet/parser/functions/contain.rb#L27
  • a

    Alex Fisher

    06/08/2022, 3:16 PM
    @ewoud Done. Do you know if it's possible to get puppet strings to ignore a file?
  • a

    Alex Fisher

    06/08/2022, 3:17 PM
    I don't think it is. a
    @ignore_me
    tag would be nice!
  • h

    helindbe

    06/08/2022, 4:57 PM
    @Alex Fisher you mentioned me, and I did see some questions - are there things you want to know more about?
  • v

    VoxBot

    06/08/2022, 5:04 PM
    the question was about statement functions in the v3 functions api and what the v4 equivalent would be
  • v

    VoxBot

    06/08/2022, 5:04 PM
    or really, a function without a return value
  • h

    helindbe

    06/08/2022, 5:04 PM
    The history lesson here is that some things that were thought of as statements in puppet were implemented as functions and it was possible to call any function without parentheses. This did however create a horrible grammar with lots of issues (i.e all the WAT up util puppet 4).
  • h

    helindbe

    06/08/2022, 5:05 PM
    All functions in puppet 4 have a return value - just use nil in Ruby, i.e. undef in puppet.
  • h

    helindbe

    06/08/2022, 5:05 PM
    The 3x distinction between functions with/without rvalue is no longer applicable.
  • v

    VoxBot

    06/08/2022, 5:05 PM
    that sounds like what I was also suggesting, thanks for confirming
  • h

    helindbe

    06/08/2022, 5:07 PM
    The only thing the “non r-value” marker did was to make sure nil was returned instead of the value from the 3x function. This may still be the case for 3x functions as some of them were poorly written and they could return something that the puppet language cannot deal with - i.e. a value that is a of a Ruby data type that will make things go bad later.
  • v

    VoxBot

    06/08/2022, 5:10 PM
    the function in question was ensure_packages() from stdlib, which calls ensure_resource
  • h

    helindbe

    06/08/2022, 5:10 PM
    There are some other distinctions regarding functions - some functions need to pass the caller’s context on to a function it calls - if you look at the specification of 4x functions you see there is something called a “system function” which has an API with more functionality.
  • v

    VoxBot

    06/08/2022, 5:10 PM
    I'm not sure what the return type should be, nil/undef sounds safest to me
  • h

    helindbe

    06/08/2022, 5:11 PM
    that is a good choice, unless there is something else that is meaningful to return - which there may not be.
  • h

    helindbe

    06/08/2022, 5:12 PM
    Does the
    ensure_resource
    function need to get the context of the caller to
    ensure_packages
    ?
1...616263...648Latest