Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Eric Thompson updated an issue Puppet / PUP-5903 4.x function api should contain way to add type aliases Change By: Eric Thompson QA Highest Test Level: Unit Add Comment This message was sent by Atlassian JIRA (v6.4.13#64028-sha1:b7939e9) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Eric Thompson updated an issue Puppet / PUP-5903 4.x function api should contain way to add type aliases Change By: Eric Thompson QA Status: Reviewed Add Comment This message was sent by Atlassian JIRA (v6.4.13#64028-sha1:b7939e9) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Eric Thompson updated an issue Puppet / PUP-5903 4.x function api should contain way to add type aliases Change By: Eric Thompson QA Risk Assessment: Medium Add Comment This message was sent by Atlassian JIRA (v6.4.13#64028-sha1:b7939e9) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Eric Thompson commented on PUP-5903 Re: 4.x function api should contain way to add type aliases validated against master puppet-agent SHA: 521fab6a0ee6642f0bf31bd3abfc41b7b52d098e on ubuntu1404: ruby function: root@ejf1yhwiakr47u6:/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/functions# cat local_types.rb Puppet::Functions.create_function(:local_types) do local_types do type 'PartColor = Enum[blue, red, green, mauve, teal, white, pine]' type 'Part = Enum[cubicle_wall, chair, wall, desk, carpet]' type 'PartToColorMap = Hash[Part, PartColor]' end dispatch :define_colors do param 'PartToColorMap', :part_color_map end
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Sean Griffin assigned an issue to qa Puppet / PUP-5903 4.x function api should contain way to add type aliases Change By: Sean Griffin Status: Ready for CI Test Assignee: qa Add Comment This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Eric Thompson assigned an issue to qa Puppet / PUP-5903 4.x function api should contain way to add type aliases Change By: Eric Thompson Assignee: Eric Thompson qa Add Comment This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Eric Thompson updated an issue Puppet / PUP-5903 4.x function api should contain way to add type aliases Change By: Eric Thompson For complex function parameters it is difficult to write the type signatures in a 4.x function API.As an example look at the 4.x function {{lookup()}}. In that function string variables and interpolation is used to define the the types of parameters in string form.It would be very useful if a function could add type aliases to the type system and then use those in the dispatcher.Tools like Puppet String would then be able to find them (it cannot understand the string interpolations. Users would also be helped, when the they get an error also be helped , by the name of the type (along with an expanded details mis - match). it It should be easy to come up with a type alias API, but a more difficult question is how to name these type aliases. A function in a module would naturally place the types in the module's name space. But what about an environment? Or in puppet? (which uses the global namespace).Somehow, it seems appropriate if the aliases, if being specific to a single function (and hence defined there) would use a name related to the function. If the types are more general, the they should naturally not be introduced in a function.This leads to a couple of design decisions:* What is the namespace of type aliases in puppet itself ?* 4.x function API for type aliases for parameters* In a Puppet Function, should we allow it to introduce type aliases as well as defining the function? (Now that is not allowed).* Where do we place general type aliases in Puppet ?Example{code:ruby}#... in a 4.x functionlocal_types { type 'MyModule::PullSled::OhDeer = 'Enum[...]'}dispatch :some_method { param 'MyModule::PullSled::OhDeer' :a_deer}#... etc{code}} Add Comment This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc)
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Eric Thompson assigned an issue to Eric Thompson Puppet / PUP-5903 4.x function api should contain way to add type aliases Change By: Eric Thompson Assignee: qa Eric Thompson Add Comment This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Thomas Hallgren commented on PUP-5903 Re: 4.x function api should contain way to add type aliases PR-68 merged to puppet-specifications master at afe942d. Add Comment This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Henrik Lindberg assigned an issue to Unassigned Puppet / PUP-5903 4.x function api should contain way to add type aliases Change By: Henrik Lindberg Assignee: Thomas Hallgren Add Comment This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Henrik Lindberg updated an issue Puppet / PUP-5903 4.x function api should contain way to add type aliases Change By: Henrik Lindberg For complex function parameters it is difficult to write the type signatures in a 4.x function API.As an example look at the 4.x function {{lookup()}}. In that function string variables and interpolation is used to define the the types of parameters in string form.It would be very useful if a function could add type aliases to the type system and then use those in the dispatcher.Tools like Puppet String would then be able to find them (it cannot understand the string interpolations. Users would when the get an error also be helped by the name of the type (along with an expanded details mis match).it should be easy to come up with a type alias API, but a more difficult question is how to name these type aliases. A function in a module would naturally place the types in the module's name space. But what about an environment? Or in puppet? (which uses the global namespace).Somehow, it seems appropriate if the aliases, if being specific to a single function (and hence defined there) would use a name related to the function. If the types are more general, the should naturally not be introduced in a function.This leads to a couple of design decisions:* What is the namespace of type aliases in puppet itself ?* 4.x function API for type aliases for parameters* In a Puppet Function, should we allow it to introduce type aliases as well as defining the function? (Now that is not allowed).* Where do we place general type aliases in Puppet ?Example{code:ruby}#... in a 4.x function type_aliases local_types { type 'MyModule::PullSled::OhDeer ' = > 'Enum[...]'}dispatch :some_method { param 'MyModule::PullSled::OhDeer' :a_deer}#... etc{code}} Add Comment This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc)
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Thomas Hallgren commented on PUP-5903 Re: 4.x function api should contain way to add type aliases Merged to master at 197c396. Add Comment This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Henrik Lindberg assigned an issue to Thomas Hallgren Puppet / PUP-5903 4.x function api should contain way to add type aliases Change By: Henrik Lindberg Assignee: Thomas Hallgren Add Comment This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Henrik Lindberg updated an issue Puppet / PUP-5903 4.x function api should contain way to add type aliases Change By: Henrik Lindberg Release Notes Summary: The 4.x Function API for Ruby functions now has a mechanism that allows defining local complex types. This avoids long strings and repetition when specifying the data types of function parameters. Sprint: Language Triage 2016-03-23 Release Notes: New Feature Fix Version/s: PUP 4.x Fix Version/s: PUP 4.5.0 Add Comment This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc)
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Henrik Lindberg assigned an issue to Henrik Lindberg Puppet / PUP-5903 4.x function api should contain way to add type aliases Change By: Henrik Lindberg Assignee: Henrik Lindberg Add Comment This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Henrik Lindberg commented on PUP-5903 Re: 4.x function api should contain way to add type aliases Suggest we handle the fancier cases in a separate ticket (local type aliases for puppet functions - not sure it is even going to be needed). We need a resolution for complex types inside of 4.x ruby functions as the current form of using string variables screws up Puppet Strings. Add Comment This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Henrik Lindberg commented on PUP-5903 Re: 4.x function api should contain way to add type aliases Using type inside function and type makes them look like local types, and that is odd because they are used before they are defined. Your questions It looks like the types are defined in a global scope and it will be somewhat surprising that they are not. For function (and type) yes, agree. Will try with another proposal. How would you do this if you declare a function in, say, init.pp? We do not really care - that just defines the type/function class etc. This use case is mainly for writing examples, testing, experimenting, debugging etc. Should we have this ability when we declare types as well? Types can consist of other fairly complex types. If we do allow this for types as well, how do we differentiate between the global type and the types local to the type definition? Add Comment This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Thomas Hallgren commented on PUP-5903 Re: 4.x function api should contain way to add type aliases The last comment about allowing the same for a puppet function definition. I see some problems with that. It looks like the types are defined in a global scope and it will be somewhat surprising that they are not. How would you do this if you declare a function in, say, init.pp? Should we have this ability when we declare types as well? Types can consist of other fairly complex types. If we do allow this for types as well, how do we differentiate between the global type and the types local to the type definition? All in all, I think we need to have a syntax to describe the closure where the loader is local and not just say that this closure is implicit since it's contained in a file under the functions directory, i.e. { type PartColor = Enum[blue, red, green, mauve, teal, white, pine] type Part = Enum[cubicle_wall, chair, wall, desk, carpet] type 'PartToColorMap = Hash[Part, PartColor] }.definition_closure { function mymodule::define_colors(MyModule::PartToColorMap $part_color_map) {
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Henrik Lindberg commented on PUP-5903 Re: 4.x function api should contain way to add type aliases Ping Thomas Hallgren - thoughts ? Add Comment This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Henrik Lindberg commented on PUP-5903 Re: 4.x function api should contain way to add type aliases We can allow the same for a puppet function definition - what is needed here is that the type aliases end up in the function's local loader, type PartColor = Enum[blue, red, green, mauve, teal, white, pine] type Part = Enum[cubicle_wall, chair, wall, desk, carpet] type 'PartToColorMap = Hash[Part, PartColor] function mymodule::define_colors(MyModule::PartToColorMap $part_color_map) { # etc } For this to work, the puppet function instantiator must also allow type aliases to be present. Add Comment
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Henrik Lindberg updated an issue Puppet / PUP-5903 4.x function api should contain way to add type aliases Change By: Henrik Lindberg Fix Version/s: PUP 4.x Add Comment This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Henrik Lindberg commented on PUP-5903 Re: 4.x function api should contain way to add type aliases We should create a Local Loader (we probably already have one that can work in this capacity). A Ruby Function instantiator should create an instance of a Local Loader, set its parent to the module's private loader (the loader that is now set as the loader of the function), and then the local loader should be set as the function's loader. This means that a function, when defined can store local type aliases in this loader, and use them in subsequent types. These types will be completely invisible to anything outside. The logic that calls the function must use the loader associated with the function (it probably does already, I have not checked) in order to find the correct types. Since a user cannot find a definition of type aliases inside of a function easily (have to look at source), it is important that these types show up in the documentation of the function. (A PDOC ticket is needed to make this fully supported in generated documentation). Also, the text in the function must include a description of the local types. The types will automatically be named with module and function name to ensure they do not clash. Implementors are encouraged to use descriptive names that are meaningful to users . These names should be given as Strings and use CamelCase. The type aliasing must be done before the dispatch section. The small internal DSL for this in the 4.x function API should look like this: local_types do type 'AliasName', 'type definition' type ... end (This mimics the type syntax in puppet). Here is an example:
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Henrik Lindberg commented on PUP-5903 Re: 4.x function api should contain way to add type aliases As we need that, isn't that the same thing as a private loader? (i.e. one that has content that is not visible outside of its domain (which is something we want to have for modules etc. anyway. We could just have a private one for puppet, etc. rather than one per function). Add Comment This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Thomas Hallgren commented on PUP-5903 Re: 4.x function api should contain way to add type aliases Yes, a local loader stacked on top of the loader that is otherwise used will be necessary to enable self referencing types. Add Comment This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Henrik Lindberg commented on PUP-5903 Re: 4.x function api should contain way to add type aliases Yes, that works better - if you want a shared type alias it should not be there. The local type alias would be just that - the types are not propagated to the real loader. Maybe use a local loader instance? Add Comment This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Thomas Hallgren commented on PUP-5903 Re: 4.x function api should contain way to add type aliases If the main driving force for this is to be able to ease the task of write dispatchers, then I would suggest that we introduce a local alias that's only visible to the dispatchers (and the return value). I'd consider it bad practice to declare shared aliases inside of, or as part of, the declaration of one of the places (i.e. a function) where it might be used. Add Comment This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Thomas Hallgren commented on PUP-5903 Re: 4.x function api should contain way to add type aliases How would the autoloader find an alias declared this way? Add Comment This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5903) 4.x function api should contain way to add type aliases
Title: Message Title Henrik Lindberg created an issue Puppet / PUP-5903 4.x function api should contain way to add type aliases Issue Type: Improvement Assignee: Unassigned Created: 2016/02/15 6:36 AM Priority: Normal Reporter: Henrik Lindberg For complex function parameters it is difficult to write the type signatures in a 4.x function API. As an example look at the 4.x function lookup(). In that function string variables and interpolation is used to define the the types of parameters in string form. It would be very useful if a function could add type aliases to the type system and then use those in the dispatcher. Tools like Puppet String would then be able to find them (it cannot understand the string interpolations. Users would when the get an error also be helped by the name of the type (along with an expanded details mis match). it should be easy to come up with a type alias API, but a more difficult question is how to name these type aliases. A function in a module would naturally place the types in the module's name space. But what about an environment? Or in puppet? (which uses the global namespace). Somehow, it seems appropriate if the aliases, if being specific to a single function (and hence defined there) would use a name related to the function. If the types are more general, the should naturally not be introduced in a function. This leads to a couple of design decisions: What is the namespace of type aliases in puppet itself ? 4.x function API for type aliases