Skip to content

Commit cc7ffae

Browse files
committed
(maint) add new resource api output for json_spec
1 parent 1316975 commit cc7ffae

2 files changed

Lines changed: 83 additions & 0 deletions

File tree

spec/fixtures/unit/json/output.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,49 @@
8181
}
8282
],
8383
"resource_types": [
84+
{
85+
"name": "apt_key",
86+
"file": "(stdin)",
87+
"line": 92,
88+
"docstring": {
89+
"text": "This type provides Puppet with the capabilities to manage GPG keys needed\nby apt to perform package validation. Apt has it's own GPG keyring that can\nbe manipulated through the `apt-key` command.\n**Autorequires**:\nIf Puppet is given the location of a key file which looks like an absolute\npath this type will autorequire that file.",
90+
"tags": [
91+
{
92+
"tag_name": "summary",
93+
"text": "Example resource type using the new API."
94+
},
95+
{
96+
"tag_name": "raise",
97+
"text": "SomeError"
98+
},
99+
{
100+
"tag_name": "example",
101+
"text": "apt_key { '6F6B15509CF8E59E6E469F327F438280EF8D349F':\n source => 'http://apt.puppetlabs.com/pubkey.gpg'\n}",
102+
"name": "here's an example"
103+
}
104+
]
105+
},
106+
"properties": [
107+
{
108+
"name": "ensure",
109+
"description": "Whether this apt key should be present or absent on the target system.",
110+
"data_type": "Enum[present, absent]"
111+
},
112+
{
113+
"name": "created",
114+
"description": "Date the key was created, in ISO format.",
115+
"data_type": "String"
116+
}
117+
],
118+
"parameters": [
119+
{
120+
"name": "id",
121+
"description": "The ID of the key you want to manage.",
122+
"data_type": "Variant[Pattern[/A(0x)?[0-9a-fA-F]{8}Z/], Pattern[/A(0x)?[0-9a-fA-F]{16}Z/], Pattern[/A(0x)?[0-9a-fA-F]{40}Z/]]",
123+
"isnamevar": true
124+
}
125+
]
126+
},
84127
{
85128
"name": "database",
86129
"file": "(stdin)",

spec/unit/puppet-strings/json_spec.rb

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,46 @@ class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar {
123123
defaultto 'warn'
124124
end
125125
end
126+
127+
Puppet::ResourceApi.register_type(
128+
name: 'apt_key',
129+
desc: <<-EOS,
130+
@summary Example resource type using the new API.
131+
@raise SomeError
132+
This type provides Puppet with the capabilities to manage GPG keys needed
133+
by apt to perform package validation. Apt has it's own GPG keyring that can
134+
be manipulated through the `apt-key` command.
135+
@example here's an example
136+
apt_key { '6F6B15509CF8E59E6E469F327F438280EF8D349F':
137+
source => 'http://apt.puppetlabs.com/pubkey.gpg'
138+
}
139+
140+
**Autorequires**:
141+
If Puppet is given the location of a key file which looks like an absolute
142+
path this type will autorequire that file.
143+
EOS
144+
attributes: {
145+
ensure: {
146+
type: 'Enum[present, absent]',
147+
desc: 'Whether this apt key should be present or absent on the target system.'
148+
},
149+
id: {
150+
type: 'Variant[Pattern[/\A(0x)?[0-9a-fA-F]{8}\Z/], Pattern[/\A(0x)?[0-9a-fA-F]{16}\Z/], Pattern[/\A(0x)?[0-9a-fA-F]{40}\Z/]]',
151+
behaviour: :namevar,
152+
desc: 'The ID of the key you want to manage.',
153+
},
154+
# ...
155+
created: {
156+
type: 'String',
157+
behaviour: :read_only,
158+
desc: 'Date the key was created, in ISO format.',
159+
},
160+
},
161+
autorequires: {
162+
file: '$source', # will evaluate to the value of the `source` attribute
163+
package: 'apt',
164+
},
165+
)
126166
SOURCE
127167
end
128168

0 commit comments

Comments
 (0)