Jira (PUP-8744) Using a variable in a Type on a parameter results in an error unless the variable was already loaded

4 views
Skip to first unread message

Nick Walker (JIRA)

unread,
May 16, 2018, 3:38:04 PM5/16/18
to puppe...@googlegroups.com
Nick Walker created an issue
 
Puppet / Bug PUP-8744
Using a variable in a Type on a parameter results in an error unless the variable was already loaded
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2018/05/16 12:37 PM
Priority: Normal Normal
Reporter: Nick Walker

The Problem

If you use a variable from say your params class in a type of a parameter then whether or not you can parse that class depends on whether you included a class that loaded params before the class you use the variable in.

Anyway here's an example:

https://github.com/npwalker/regex_variable/blob/master/manifests/profile/test.pp#L8

Suggested solution

Either this should work every time or it should never work. I'd be fine with detection of this behavior and an outright failure.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Nick Walker (JIRA)

unread,
May 16, 2018, 3:39:03 PM5/16/18
to puppe...@googlegroups.com

Henrik Lindberg (JIRA)

unread,
May 17, 2018, 4:36:03 AM5/17/18
to puppe...@googlegroups.com

Thomas Hallgren I think we need to make the type declarations for parameters only accept literal expressions - what do you think?

Thomas Hallgren (JIRA)

unread,
May 17, 2018, 9:14:03 AM5/17/18
to puppe...@googlegroups.com

Yes, I agree with that. The type declaration is a static construct so allowing non-literals is a bug.

Thomas Hallgren (JIRA)

unread,
May 17, 2018, 9:18:02 AM5/17/18
to puppe...@googlegroups.com

If someone would want to do dynamic checking, that is possible, but it must be done in code (of course, since it's dynamic). A type can be parsed from a String.

Example where $myvar is a regexp:

$the_type = Type("Pattern[$myvar]")
$value = $the_type.assert_type($value)

Henrik Lindberg (JIRA)

unread,
May 17, 2018, 10:50:02 AM5/17/18
to puppe...@googlegroups.com

Henrik Lindberg (JIRA)

unread,
May 17, 2018, 10:52:03 AM5/17/18
to puppe...@googlegroups.com

Henrik Lindberg (JIRA)

unread,
May 17, 2018, 10:52:03 AM5/17/18
to puppe...@googlegroups.com
Henrik Lindberg updated an issue
h1. The Problem


If you use a variable from say your params class in a type of a parameter then whether or not you can parse that class depends on whether you included a class that loaded params before the class you use the variable in.  

Anyway here's an example:

https://github.com/npwalker/regex_variable/blob/master/manifests/profile/test.pp#L8

h1.  Suggested solution


Either this should work every time or it should never work.  I'd be fine with detection of this behavior and an outright failure.
     

UPDATE
-----
The data types for parameters must be literal expressions and should error when a variable or function call is used.

Kenn Hussey (JIRA)

unread,
Sep 10, 2018, 9:30:09 AM9/10/18
to puppe...@googlegroups.com

Henrik Lindberg (JIRA)

unread,
Sep 10, 2018, 9:54:04 AM9/10/18
to puppe...@googlegroups.com

Kenn Hussey (JIRA)

unread,
Sep 10, 2018, 1:16:03 PM9/10/18
to puppe...@googlegroups.com

Eric Thompson (JIRA)

unread,
Sep 20, 2018, 4:08:05 PM9/20/18
to puppe...@googlegroups.com

Henrik Lindberg (JIRA)

unread,
Sep 20, 2018, 4:45:04 PM9/20/18
to puppe...@googlegroups.com

Josh Cooper (JIRA)

unread,
Sep 16, 2019, 2:45:06 PM9/16/19
to puppe...@googlegroups.com

David McTavish (Jira)

unread,
Jan 12, 2022, 7:57:01 PM1/12/22
to puppe...@googlegroups.com
David McTavish updated an issue
Change By: David McTavish
Labels: final_triage
This message was sent by Atlassian Jira (v8.20.2#820002-sha1:829506d)
Atlassian logo

Molly Waggett (Jira)

unread,
Feb 22, 2022, 1:51:01 PM2/22/22
to puppe...@googlegroups.com

Molly Waggett (Jira)

unread,
Feb 22, 2022, 1:51:01 PM2/22/22
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages