Skip to content

Commit 54d0eea

Browse files
committed
(maint) clarify language around composite namevars
1 parent fe5d4ad commit 54d0eea

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

language/resource-api/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ Each resource being managed must be identified by a unique title. Usually this i
7777

7878
If multiple attributes are defined with the `namevar` behaviour, the type SHOULD specify `title_patterns` that will tell Resource API how to get at the attributes from the title. If `title_patterns` is not specified a default pattern is applied, and matches against the first declared `namevar`.
7979

80-
8180
> Note: The order of title_patterns is important. You should declare the most specific pattern first and end with the most generic.
8281
8382
Each title pattern contains the:
@@ -143,6 +142,8 @@ software { php:
143142
}
144143
```
145144

145+
The provider's `get` method should return a single formatted string representing all namevar values in such a way that it matches one of the title patterns as value to the `:title` key for each resource. This allows the runtime environment to present resources in a way familiar to the user.
146+
146147
## Resource implementation ("provider")
147148

148149
To affect changes, a resource requires an implementation that makes the universe's state available to Puppet, and causes the changes to bring reality to whatever state is requested in the catalog. The two fundamental operations to manage resources are reading and writing system state. These operations are implemented as `get` and `set`. The implementation itself is a basic Ruby class in the `Puppet::Provider` namespace, named after the type using CamelCase.
@@ -209,17 +210,17 @@ Once all of that is in place, instead of the `set` method, the provider needs to
209210

210211
* `create(context, name, should)`: This is called when a new resource should be created.
211212
* `context`: provides utilities from the runtime environment, and is described in more detail in its own section below.
212-
* `name`: the name or hash of the new resource.
213+
* `name`: the name (if there is only one namevar) or hash of namevars (if there are multiple) of the new resource.
213214
* `should`: a hash of the attributes for the new instance.
214215

215216
* `update(context, name, should)`: This is called when a resource should be updated.
216217
* `context`: provides utilities from the runtime environment, and is described in more detail in its own section below.
217-
* `name`: the name or hash of the resource to change.
218+
* `name`: the name (if there is only one namevar) or hash of namevars (if there are multiple) of the new resource.
218219
* `should`: a hash of the desired state of the attributes.
219220

220221
* `delete(context, name)`: This is called when a resource should be deleted.
221222
* `context`: provides utilities from the runtime environment, and is described in more detail in its own section below.
222-
* `name`: the name or hash of the resource that should be deleted.
223+
* `name`: the name (if there is only one namevar) or hash of namevars (if there are multiple) of the new resource.
223224

224225
The `SimpleProvider` takes care of basic logging, and error handling.
225226

0 commit comments

Comments
 (0)