Jira (FACT-239) Expose different resolution types in DSL

2023-06-21 Thread 'Claudia Petty (Jira)' via Puppet Bugs
Title: Message Title


 
 
 
 

 
 
 

 
   
 Claudia Petty updated an issue  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
 Facter /  FACT-239  
 
 
  Expose different resolution types in DSL   
 

  
 
 
 
 

 
Change By: 
 Claudia Petty  
 
 
Labels: 
 new-feature  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian Jira (v8.20.21#820021-sha1:38274c8)  
 
 

 
   
 

  
 

  
 

   





-- 
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 view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.24112.1390337199000.1936.1687351382410%40Atlassian.JIRA.


Jira (FACT-239) Expose different resolution types in DSL

2014-02-28 Thread Adrien Thebo (JIRA)
Title: Message Title










 

 Adrien Thebo commented on an issue


















  Re: Expose different resolution types in DSL 










Merged into facter-2 in 619df15.












   

 Add Comment

























 Facter /  FACT-239



  Expose different resolution types in DSL 







 Adding multiple resolution types to Facter means that the DSL will have to take this into account. The DSL needs to take the following into account:   Resolutions need to be able to declare their type upon creation. This should just be a simple matter of taking :type = :something when the resolution is initially created.   Resolutions may also need to...















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
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 http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.


Jira (FACT-239) Expose different resolution types in DSL

2014-02-27 Thread Adrien Thebo (JIRA)
Title: Message Title










 

 Adrien Thebo commented on an issue


















  Re: Expose different resolution types in DSL 










I've added documentation for named resolutions and how they work at https://github.com/puppetlabs/pre-docs/blob/master/facter/facter-2.0.1/named-resolutions.md .
In short, here's the expected behavior for named resolutions:



Facter.add(:myfact) do
  setcode { foo }
end

Facter.add(:myfact) do
  setcode { bar }
end



This declares two anonymous resolutions, which can happily coexist. There's not a lot we can do to change this behavior since it's the only way to currently declare facts.



Facter.define_fact(:myfact) do
  define_resolution(:myres) do
setcode { foo }
  end
end



This declares a named simple resolution, which is all fine and dandy. However, following that with this:



Facter.define_fact(:myfact) do
  define_resolution(:myres) do
setcode { bar }
  end
end



Will emit a warning (https://github.com/puppetlabs/facter/blob/facter-2/lib/facter/util/resolution.rb#L70-L74) because reopening a simple resolution is pretty nonsensical.
Doing this:



Facter.define_fact(:myfact) do
  define_resolution(:myres, :type = :aggregate) do
# Will never be reached
  end
end



Will raise an error since :myres has already been defined and is a simple resolution, and it's not meaningful to reopen a resolution with a different type.












   

 Add Comment

























  

Jira (FACT-239) Expose different resolution types in DSL

2014-02-27 Thread Adrien Thebo (JIRA)
Title: Message Title










 

 Adrien Thebo commented on an issue


















  Re: Expose different resolution types in DSL 










And now for more API stuff:



$ cat lib/facter/reopened_aggregate.rb
Facter.add(reopened_aggregate, :type = :aggregate) do
  setcode do
'one'
  end
end

Facter.add(reopened_aggregate, :type = :aggregate) do
  setcode do
'two'
  end
end
$ be facter reopened_aggregate
Unable to add resolve nil for fact reopened_aggregate: undefined method `setcode' for #Facter::Core::Aggregate:0x007f8ee598ec90
Unable to add resolve nil for fact reopened_aggregate: undefined method `setcode' for #Facter::Core::Aggregate:0x007f8ee598de58



We could explicitly raise a NotImplementedError for setcode to explain what's going on here, do you expect this to be prevalent enough to add that in?



$ cat lib/facter/reopened_aggregate.rb
Facter.add(reopened_aggregate, :type = :aggregate) do
  chunk(:one) do
'one'
  end
  chunk(:two) do
'two'
  end
end
$ be facter reopened_aggregate
Could not retrieve fact='reopened_aggregate', resolution='anonymous': No aggregate block specified and could not deep merge all chunks, either specify an aggregate block or ensure that all chunks return deep mergable structures. (Original error: Cannot merge one:String and two:String)



I was hoping that the error message indicated that but it doesn't read very clearly, how would you like to see that worded?












   

 Add Comment

























 Facter /  FACT-239



  Expose different resolution types in DSL 







 Adding 

Jira (FACT-239) Expose different resolution types in DSL

2014-02-27 Thread Adrien Thebo (JIRA)
Title: Message Title










 

 Adrien Thebo commented on an issue


















  Re: Expose different resolution types in DSL 










For the last example I think there was an issue with the hash object not having a key/value pair:



└ cat lib/facter/mismatch.rb 
Facter.add(mismatch, :type = :aggregate) do
  chunk(:one) do
['one']
  end
  chunk(:two) do
{'two' = 'three'}
  end
end
└ bexec facter mismatch 
Could not retrieve fact='mismatch', resolution='anonymous': No aggregate block specified and could not deep merge all chunks, either specify an aggregate block or ensure that all chunks return deep mergable structures. (Original error: Cannot merge [one]:Array and {two=three}:Hash)
















   

 Add Comment

























 Facter /  FACT-239



  Expose different resolution types in DSL 







 Adding multiple resolution types to Facter means that the DSL will have to take this into account. The DSL needs to take the following into account:   Resolutions need to be able to declare their type upon creation. This should just be a simple matter of taking :type = :something when the resolution is initially created.   Resolutions may also need to...















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 
  

Jira (FACT-239) Expose different resolution types in DSL

2014-02-27 Thread Adrien Thebo (JIRA)
Title: Message Title










 

 Adrien Thebo commented on an issue


















  Re: Expose different resolution types in DSL 










So lastly I realize that the behavior of this is a little complex depending on if a resolution is named or anonymous, if it's simple or aggregate, and if we're reopening a resolution. I tried to make this a bit more simple and clear but I couldn't figure out much on how to have named resolutions and aggregate resolutions. Does anyone have suggestions on how this could be simplified?












   

 Add Comment

























 Facter /  FACT-239



  Expose different resolution types in DSL 







 Adding multiple resolution types to Facter means that the DSL will have to take this into account. The DSL needs to take the following into account:   Resolutions need to be able to declare their type upon creation. This should just be a simple matter of taking :type = :something when the resolution is initially created.   Resolutions may also need to...















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
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 

Jira (FACT-239) Expose different resolution types in DSL

2014-02-27 Thread Joshua Cooper (JIRA)
Title: Message Title










 

 Joshua Cooper commented on an issue


















  Re: Expose different resolution types in DSL 










Adrien Thebo and I talked this over and it would be good to clarify in the docs Nicholas Fagerlund that setcode is a simple fact thing and chunk is an aggregate fact thing, so



Facter.add(mismatch, :type = :aggregate) do
  setcode { 'whatever' }
end



is not valid. 
The other issue about merging chunks, perhaps we can change the error message to say that only hashes or arrays are mergeable.












   

 Add Comment

























 Facter /  FACT-239



  Expose different resolution types in DSL 







 Adding multiple resolution types to Facter means that the DSL will have to take this into account. The DSL needs to take the following into account:   Resolutions need to be able to declare their type upon creation. This should just be a simple matter of taking :type = :something when the resolution is initially created.   Resolutions may also need to...















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 


 

Jira (FACT-239) Expose different resolution types in DSL

2014-02-27 Thread Kylo Ginsberg (JIRA)
Title: Message Title










 

 Kylo Ginsberg commented on an issue


















  Re: Expose different resolution types in DSL 










Adrien Thebo can you go through these review comments and make recommendations on fix vs document?












   

 Add Comment

























 Facter /  FACT-239



  Expose different resolution types in DSL 







 Adding multiple resolution types to Facter means that the DSL will have to take this into account. The DSL needs to take the following into account:   Resolutions need to be able to declare their type upon creation. This should just be a simple matter of taking :type = :something when the resolution is initially created.   Resolutions may also need to...















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
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 http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.


Jira (FACT-239) Expose different resolution types in DSL

2014-02-27 Thread Adrien Thebo (JIRA)
Title: Message Title










 

 Adrien Thebo assigned an issue to Adrien Thebo


















 Facter /  FACT-239



  Expose different resolution types in DSL 










Change By:

 Adrien Thebo




Assignee:

 AdrienThebo












   

 Add Comment






















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
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 http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.


Jira (FACT-239) Expose different resolution types in DSL

2014-02-26 Thread Joshua Cooper (JIRA)
Title: Message Title










 

 Joshua Cooper assigned an issue to Joshua Cooper


















 Facter /  FACT-239



  Expose different resolution types in DSL 










Change By:

 Joshua Cooper




Assignee:

 JoshuaCooper












   

 Add Comment






















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
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 http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.


Jira (FACT-239) Expose different resolution types in DSL

2014-02-26 Thread Joshua Cooper (JIRA)
Title: Message Title










 

 Joshua Cooper commented on an issue


















  Re: Expose different resolution types in DSL 










Should this raise an error?



$ cat lib/facter/reopened.rb
Facter.add(reopened, :type = :simple) do
  setcode do
'one'
  end
end

Facter.add(reopened, :type = :simple) do
  setcode do
'two'
  end
end
$ be facter reopened
one



Should this be an error? Or will facter always pick the first resolution in parse order?












   

 Add Comment

























 Facter /  FACT-239



  Expose different resolution types in DSL 







 Adding multiple resolution types to Facter means that the DSL will have to take this into account. The DSL needs to take the following into account:   Resolutions need to be able to declare their type upon creation. This should just be a simple matter of taking :type = :something when the resolution is initially created.   Resolutions may also need to...















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 







   

Jira (FACT-239) Expose different resolution types in DSL

2014-02-26 Thread Joshua Cooper (JIRA)
Title: Message Title










 

 Joshua Cooper commented on an issue


















  Re: Expose different resolution types in DSL 










Should facter raise an error when using setcode with an aggregate fact?



$ cat lib/facter/reopened_aggregate.rb
Facter.add(reopened_aggregate, :type = :aggregate) do
  setcode do
'one'
  end
end

Facter.add(reopened_aggregate, :type = :aggregate) do
  setcode do
'two'
  end
end
$ be facter reopened_aggregate
Unable to add resolve nil for fact reopened_aggregate: undefined method `setcode' for #Facter::Core::Aggregate:0x007f8ee598ec90
Unable to add resolve nil for fact reopened_aggregate: undefined method `setcode' for #Facter::Core::Aggregate:0x007f8ee598de58















   

 Add Comment

























 Facter /  FACT-239



  Expose different resolution types in DSL 







 Adding multiple resolution types to Facter means that the DSL will have to take this into account. The DSL needs to take the following into account:   Resolutions need to be able to declare their type upon creation. This should just be a simple matter of taking :type = :something when the resolution is initially created.   Resolutions may also need to...















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 
 

Jira (FACT-239) Expose different resolution types in DSL

2014-02-26 Thread Joshua Cooper (JIRA)
Title: Message Title










 

 Joshua Cooper commented on an issue


















  Re: Expose different resolution types in DSL 










Think we should mention that aggregate fact chunks need to return aggregate-able data. For example, if each chunk returns a string, I get an error:



$ cat lib/facter/reopened_aggregate.rb
Facter.add(reopened_aggregate, :type = :aggregate) do
  chunk(:one) do
'one'
  end
  chunk(:two) do
'two'
  end
end
$ be facter reopened_aggregate
Could not retrieve fact='reopened_aggregate', resolution='anonymous': No aggregate block specified and could not deep merge all chunks, either specify an aggregate block or ensure that all chunks return deep mergable structures. (Original error: Cannot merge one:String and two:String)



If I change the return values to ['one'] and ['two'], then they are merged as expected.












   

 Add Comment

























 Facter /  FACT-239



  Expose different resolution types in DSL 







 Adding multiple resolution types to Facter means that the DSL will have to take this into account. The DSL needs to take the following into account:   Resolutions need to be able to declare their type upon creation. This should just be a simple matter of taking :type = :something when the resolution is initially created.   Resolutions may also need to...















 This message was sent by Atlassian JIRA 

Jira (FACT-239) Expose different resolution types in DSL

2014-02-26 Thread Joshua Cooper (JIRA)
Title: Message Title










 

 Joshua Cooper commented on an issue


















  Re: Expose different resolution types in DSL 










Facter doesn't gracefully handle mixing chunk datatypes.



$ cat lib/facter/mismatch.rb
Facter.add(mismatch, :type = :aggregate) do
  chunk(:one) do
['one']
  end
  chunk(:two) do
{'two'}
  end
end
$ be facter mismatch
Error loading fact /Users/josh/work/facter/lib/facter/mismatch.rb /Users/josh/work/facter/lib/facter/mismatch.rb:6: syntax error, unexpected '}', expecting tASSOC
Error loading fact /Users/josh/work/facter/lib/facter/mismatch.rb /Users/josh/work/facter/lib/facter/mismatch.rb:6: syntax error, unexpected '}', expecting tASSOC















   

 Add Comment

























 Facter /  FACT-239



  Expose different resolution types in DSL 







 Adding multiple resolution types to Facter means that the DSL will have to take this into account. The DSL needs to take the following into account:   Resolutions need to be able to declare their type upon creation. This should just be a simple matter of taking :type = :something when the resolution is initially created.   Resolutions may also need to...















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 
   

Jira (FACT-239) Expose different resolution types in DSL

2014-02-26 Thread Joshua Cooper (JIRA)
Title: Message Title










 

 Joshua Cooper assigned an issue to Unassigned


















 Facter /  FACT-239



  Expose different resolution types in DSL 










Change By:

 Joshua Cooper




Assignee:

 JoshuaCooper












   

 Add Comment






















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
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 http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.


Jira (FACT-239) Expose different resolution types in DSL

2014-02-14 Thread Kurt Wall (JIRA)
Title: Message Title










 

 Kurt Wall updated an issue


















 Facter /  FACT-239



  Expose different resolution types in DSL 










Change By:

 Kurt Wall




Assignee:

 EricSorenson












   

 Add Comment






















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
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 http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.


Jira (FACT-239) Expose different resolution types in DSL

2014-02-13 Thread Kurt Wall (JIRA)
Title: Message Title










 

 Kurt Wall assigned an issue to Eric Sorenson


















 Facter /  FACT-239



  Expose different resolution types in DSL 










Change By:

 Kurt Wall




Assignee:

 KurtWall EricSorenson












   

 Add Comment






















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
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 http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.


Jira (FACT-239) Expose different resolution types in DSL

2014-02-12 Thread Michelle Johansen (JIRA)
Title: Message Title










 

 Michelle Johansen updated an issue


















 Facter /  FACT-239



  Expose different resolution types in DSL 










Change By:

 Michelle Johansen




Sprint:

 Week2014-1-29to2014-2-05,Week2014-2-5to2014-2-12 ,Week2014-2-12to2014-2-19












   

 Add Comment






















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
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 http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.


Jira (FACT-239) Expose different resolution types in DSL

2014-01-28 Thread Kylo Ginsberg (JIRA)
Title: Message Title










 

 Kylo Ginsberg updated an issue


















 Facter /  FACT-239



  Expose different resolution types in DSL 










Change By:

 Kylo Ginsberg




Sprint:

 Week2014-1-29to2014-2-05












   

 Add Comment






















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
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 http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.


Jira (FACT-239) Expose different resolution types in DSL

2014-01-21 Thread Adrien Thebo (JIRA)
Title: Message Title










 

 Adrien Thebo created an issue


















 Facter /  FACT-239



  Expose different resolution types in DSL 










Issue Type:

  New Feature




Assignee:

 Eric Sorenson




Created:


 21/Jan/14 12:46 PM




Priority:

  Normal




Reporter:

 Adrien Thebo










Adding multiple resolution types to Facter means that the DSL will have to take this into account. The DSL needs to take the following into account:
Resolutions need to be able to declare their type upon creation. This should just be a simple matter of taking :type = :something when the resolution is initially created.
Resolutions may also need to be reopened, depending on the type. It's expected that users will reopen aggregate resolutions, but reopening simple resolutions is ill defined.
If a resolution is reopened, the reopened type should match the type specified in the reopen call. If there's a mismatch an error should be raised; if no type was specified we should possibly emit a warning. Alternately, we can implement something different besides allowing resolutions to be reopened.












   

 Add Comment











 

Jira (FACT-239) Expose different resolution types in DSL

2014-01-21 Thread Adrien Thebo (JIRA)
Title: Message Title










 

 Adrien Thebo assigned an issue to Adrien Thebo


















 Facter /  FACT-239



  Expose different resolution types in DSL 










Change By:

 Adrien Thebo




Assignee:

 EricSorenson AdrienThebo












   

 Add Comment






















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
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 http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.


Jira (FACT-239) Expose different resolution types in DSL

2014-01-21 Thread Adrien Thebo (JIRA)
Title: Message Title










 

 Adrien Thebo updated an issue


















 Facter /  FACT-239



  Expose different resolution types in DSL 










Change By:

 Adrien Thebo




Story Points:

 2












   

 Add Comment






















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
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 http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.


Jira (FACT-239) Expose different resolution types in DSL

2014-01-21 Thread Adrien Thebo (JIRA)
Title: Message Title










 

 Adrien Thebo updated an issue


















 Facter /  FACT-239



  Expose different resolution types in DSL 










Change By:

 Adrien Thebo




Fix Version/s:

 2.0












   

 Add Comment






















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
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 http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.