listing datatypes

12 views
Skip to first unread message

Corey Osman

unread,
Mar 30, 2017, 9:19:30 PM3/30/17
to Puppet Dev
Hi,

I have found a way to list datatypes for the puppet-debugger (https://github.com/nwops/puppet-debugger) but my approach seems hackish.  Additionally my approach only seems to pick up the core datatypes and not 3rd party types loaded from stdlib puppet module and such.


Is there a better way than this?



Corey

Thomas Hallgren

unread,
Mar 31, 2017, 1:21:12 AM3/31/17
to puppe...@googlegroups.com
Hi Corey,

Yes, your solution is indeed hackish as it performs surgery on undocumented implementation internals that might change without notice :-). Please don't do that.

We currently have no way of presenting a full list. In order to do that, we must implement new functionality on the Puppet::Pops::Loaders::Loader. The loaders form a directed acyclic graph where the leafs are the private loaders of each module. Different loaders see different things. Code loaded from one module will not automatically see all things loaded from other modules. It will just see modules that it is immediately dependent on. This is probably something that the debugger needs to be aware of.

I would envision that the debugger would obtain the loader by doing Puppet::Pops::Loaders.find_loader(<a module name>) or by asking what loader that is attached to the current AST using the Puppet::Pops::Adapters::LoaderAdapter.loader_for_model_object method. It would then obtain the list from there. The list will vary depending on loader.

A complicating factor might be that most types are loaded on demand. I.e. the loader doesn't know about them until the type is referenced loaded (or missing) as a response to that reference. Perhaps we'll need to design something that loads everything eagerly.

In any case, please enter a ticket (or tickets) where you explain what the debugger would need. I think we'll need to work together on this to create a good solution.

Short term, for the statically loaded things, take a look at Puppet::Pops::Types::TypeFactory.type_map. It's "@api private" but it's not likely to change any time soon.

- thomas


--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/D35D28B2-7D65-47C9-8A1A-D1E1C2278AD1%40nwops.io.
For more options, visit https://groups.google.com/d/optout.

Corey Osman

unread,
Mar 31, 2017, 2:06:23 PM3/31/17
to Puppet Developers
Thanks for the reply.  

The debugger doesn't need the types loaded in order to use them since it passes that work down to puppet when evaluating code.   The only thing I want to do here is just present a list so the user knows what types and dataypes are available to them.  

I am going to play around with your suggestions to see what I can come up with.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.

Thomas Hallgren

unread,
Mar 31, 2017, 4:50:02 PM3/31/17
to puppe...@googlegroups.com
The problem is that there is no known list. Loaders builds their set of type (the list) in response to the types being referenced during evaluation. Different loaders will have different set of types. So what list is it you want to present to the user? At what time?

- thomas

To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/9a02b21a-6e0a-478a-adca-9117df9ae129%40googlegroups.com.

Henrik Lindberg

unread,
Apr 3, 2017, 6:05:27 PM4/3/17
to puppe...@googlegroups.com
On 31/03/17 22:49, Thomas Hallgren wrote:
> The problem is that there is no known list. Loaders builds their set of
> type (the list) in response to the types being referenced during
> evaluation. Different loaders will have different set of types. So what
> list is it you want to present to the user? At what time?
>
I think that would be "the name of every type in every module and in the
environment".

- henrik

> - thomas
>
> On Fri, Mar 31, 2017 at 8:06 PM, Corey Osman <co...@logicminds.biz
> <mailto:co...@logicminds.biz>> wrote:
>
> Thanks for the reply.
>
> The debugger doesn't need the types loaded in order to use them
> since it passes that work down to puppet when evaluating code. The
> only thing I want to do here is just present a list so the user
> knows what types and dataypes are available to them.
>
>
> /I am going to play around with your suggestions to see what I can
> come up with./
> <https://github.com/nwops/puppet-debugger>) but my approach
> seems hackish. Additionally my approach only seems to pick
> up the core datatypes and not 3rd party types loaded from
> stdlib puppet module and such.
>
>
> Is there a better way than this?
>
> https://gist.github.com/logicminds/2a7bf4124f3bdb01f1a77d0bb521dffc
> <https://gist.github.com/logicminds/2a7bf4124f3bdb01f1a77d0bb521dffc>
>
>
> Corey
>
> --
> You received this message because you are subscribed to the
> Google Groups "Puppet Developers" group.
> To unsubscribe from this group and stop receiving emails
> from it, send an email to puppet-dev+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-dev/D35D28B2-7D65-47C9-8A1A-D1E1C2278AD1%40nwops.io
> <https://groups.google.com/d/msgid/puppet-dev/D35D28B2-7D65-47C9-8A1A-D1E1C2278AD1%40nwops.io?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Puppet Developers" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to puppet-dev+...@googlegroups.com
> <mailto:puppet-dev+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-dev/9a02b21a-6e0a-478a-adca-9117df9ae129%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-dev/9a02b21a-6e0a-478a-adca-9117df9ae129%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Puppet Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to puppet-dev+...@googlegroups.com
> <mailto:puppet-dev+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-dev/CAO5TtCszLEw6HuGbtpkh2NbMPUXVq-hDOkTt2F5iCPy_S8th7g%40mail.gmail.com
> <https://groups.google.com/d/msgid/puppet-dev/CAO5TtCszLEw6HuGbtpkh2NbMPUXVq-hDOkTt2F5iCPy_S8th7g%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.


--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

Reply all
Reply to author
Forward
0 new messages