Jira (BOLT-1363) Singular version of TargetSpec data type

0 views
Skip to first unread message

Reid Vandewiele (JIRA)

unread,
Jun 4, 2019, 5:53:04 PM6/4/19
to puppe...@googlegroups.com
Reid Vandewiele created an issue
 
Puppet Task Runner / Improvement BOLT-1363
Singular version of TargetSpec data type
Issue Type: Improvement Improvement
Assignee: Unassigned
Created: 2019/06/04 2:52 PM
Priority: Normal Normal
Reporter: Reid Vandewiele

TargetSpec accepts a single Variant[String, Target] OR an Array of the same, and is understood to best be treated as if it could refer to multiple endpoints.

Sometimes a plan (or task) parameter should accept a single target only. At present, there is no built-in data type to support that.

Create and provide such a data type.

SingleTargetSpec ?

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

Alex Dreyer (JIRA)

unread,
Jun 4, 2019, 6:17:02 PM6/4/19
to puppe...@googlegroups.com
Alex Dreyer commented on Improvement BOLT-1363
 
Re: Singular version of TargetSpec data type

We can't use a simple type alias for this since a single string may refer to a group that represents multiple targets.

For now the best workaround is to call `get_targets` at the top of the plan and verify that it returns a single result.

In the future the best solution is for the cli call `get_targets` when a string is passed from the CLI to a `Target` parameter to solve this problem.
A `get_target` function that ensures a string refers to a single target may make this easier to use in subplans.

Henrik Lindberg (JIRA)

unread,
Jun 5, 2019, 4:36:03 AM6/5/19
to puppe...@googlegroups.com

Maybe it would be possible to use a constraint to TargetSpec on the number of targets the data type represents, like for Array and Hash data types? IIRC we did add support for type parameters for Object types which is required in order to be able to state something like TargetSpec[1] (exactly one target in the spec) - then if wanted, an alias type `SingleTarget` could be created for that. You still need to call get_targets, but no need to assert the count.

Alex Dreyer (JIRA)

unread,
Jun 5, 2019, 11:10:04 AM6/5/19
to puppe...@googlegroups.com
Alex Dreyer commented on Improvement BOLT-1363

Henrik Lindberg Without fundamentally changing how we interact with targets it's not possible. If I pass in a string 'foo' to a TargetSpec get_targets} could resolve that string to a single target in inventory, a group with any number of targets or a target that is not part of the inventory. We could validate what it resolves to before the plan is called but that plan could update the inventory for example by adding targets to an empty group.

Reply all
Reply to author
Forward
0 new messages