Skip to content

Commit bbd5676

Browse files
authored
Merge pull request #105 from glennsarti/add-schema-validator
(GH-52) Add JSON schema for metadata.json
2 parents 27fa6a2 + be7f6e4 commit bbd5676

File tree

4 files changed

+205
-1
lines changed

4 files changed

+205
-1
lines changed

client/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ This extension provides full Puppet Language support for [Visual Studio Code](ht
2020
- [Syntax highlighting](#Syntax_Highlighting)
2121
- [Code snippets](#Code_snippets)
2222
- IntelliSense for resources, parameters and more
23+
- Validation of `metadata.json` files
2324
- Import from `puppet resource` directly into manifests
2425
- Node graph preview
2526

@@ -42,6 +43,7 @@ Syntax highlighting uses [puppet-lint](https://github.com/rodjek/puppet-lint) an
4243

4344
- Puppet DSL
4445
- Puppet Grammar
46+
- Module metadata files
4547

4648
### Code Snippets
4749

client/package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"categories": [
2626
"Linters",
2727
"Languages",
28-
"Snippets"
28+
"Snippets",
29+
"Formatters"
2930
],
3031
"keywords": [
3132
"puppet",
@@ -57,6 +58,10 @@
5758
"configuration": "./languages/puppet.configuration.json"
5859
}
5960
],
61+
"jsonValidation": [{
62+
"fileMatch": "metadata.json",
63+
"url": "./src/metadata-json-schema.json"
64+
}],
6065
"grammars": [
6166
{
6267
"language": "puppet",
@@ -68,6 +73,10 @@
6873
{
6974
"language": "puppet",
7075
"path": "./snippets/keywords.snippets.json"
76+
},
77+
{
78+
"language": "json",
79+
"path": "./snippets/metadata.snippets.json"
7180
}
7281
],
7382
"commands": [
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"blank metadata.json": {
3+
"prefix": "metadata.json",
4+
"body": [
5+
"{",
6+
" \"name\": \"${1:author}-${2:module_name}\",",
7+
" \"version\": \"0.1.0\",",
8+
" \"author\": \"$1\",",
9+
" \"summary\": \"${3:brief summary}\",",
10+
" \"license\": \"Apache-2.0\",",
11+
" \"source\": \"${4:source location of the module}\",",
12+
" \"dependencies\": [",
13+
" {\"name\":\"puppetlabs-stdlib\",\"version_requirement\":\">= 1.0.0\"}",
14+
" ]",
15+
"}",
16+
""
17+
],
18+
"description": "Empty metadata.json file"
19+
}
20+
}
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"title": "puppet-module-metadata",
4+
"type": "object",
5+
"description": "Puppet Module metadata.json Schema https://docs.puppet.com/puppet/latest/modules_metadata.html",
6+
"properties": {
7+
"name": {
8+
"description": "The full name of your module, including the Puppet Forge username",
9+
"type": "string",
10+
"minLength": 1,
11+
"pattern": "^[a-zA-Z0-9]+[-][a-z][a-z0-9_]*$"
12+
},
13+
"version": {
14+
"description": "The current version of your module. This should follow semantic versioning",
15+
"type": "string",
16+
"pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(-(0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(\\.(0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\\+[0-9a-zA-Z-]+(\\.[0-9a-zA-Z-]+)*)?$"
17+
},
18+
"author": {
19+
"description": "The person who gets credit for creating the module",
20+
"type": "string",
21+
"minLength": 1,
22+
"pattern": "[a-zA-Z0-9]+"
23+
},
24+
"license": {
25+
"description": "The license under which your module is made available. License metadata should match an identifier provided by SPDX",
26+
"type": "string",
27+
"enum": [
28+
"Glide","Abstyles","AFL-1.1","AFL-1.2",
29+
"AFL-2.0","AFL-2.1","AFL-3.0","AMPAS","APL-1.0","Adobe-Glyph","APAFML","Adobe-2006","AGPL-1.0","Afmparse","Aladdin","ADSL","AMDPLPA","ANTLR-PD","Apache-1.0","Apache-1.1","Apache-2.0","AML","APSL-1.0",
30+
"APSL-1.1","APSL-1.2","APSL-2.0","Artistic-1.0","Artistic-1.0-Perl","Artistic-1.0-cl8","Artistic-2.0","AAL","Bahyph","Barr","Beerware","BitTorrent-1.0","BitTorrent-1.1","BSL-1.0","Borceux","BSD-2-Clause",
31+
"BSD-2-Clause-FreeBSD","BSD-2-Clause-NetBSD","BSD-3-Clause","BSD-3-Clause-Clear","BSD-3-Clause-No-Nuclear-License","BSD-3-Clause-No-Nuclear-License-2014","BSD-3-Clause-No-Nuclear-Warranty",
32+
"BSD-4-Clause","BSD-Protection","BSD-Source-Code","BSD-3-Clause-Attribution","0BSD","BSD-4-Clause-UC","bzip2-1.0.5","bzip2-1.0.6","Caldera","CECILL-1.0","CECILL-1.1","CECILL-2.0","CECILL-2.1","CECILL-B",
33+
"CECILL-C","ClArtistic","MIT-CMU","CNRI-Jython","CNRI-Python","CNRI-Python-GPL-Compatible","CPOL-1.02","CDDL-1.0","CDDL-1.1","CPAL-1.0","CPL-1.0","CATOSL-1.1","Condor-1.1","CC-BY-1.0","CC-BY-2.0",
34+
"CC-BY-2.5","CC-BY-3.0","CC-BY-4.0","CC-BY-ND-1.0","CC-BY-ND-2.0","CC-BY-ND-2.5","CC-BY-ND-3.0","CC-BY-ND-4.0","CC-BY-NC-1.0","CC-BY-NC-2.0","CC-BY-NC-2.5","CC-BY-NC-3.0","CC-BY-NC-4.0","CC-BY-NC-ND-1.0",
35+
"CC-BY-NC-ND-2.0","CC-BY-NC-ND-2.5","CC-BY-NC-ND-3.0","CC-BY-NC-ND-4.0","CC-BY-NC-SA-1.0","CC-BY-NC-SA-2.0","CC-BY-NC-SA-2.5","CC-BY-NC-SA-3.0","CC-BY-NC-SA-4.0","CC-BY-SA-1.0","CC-BY-SA-2.0","CC-BY-SA-2.5",
36+
"CC-BY-SA-3.0","CC-BY-SA-4.0","CC0-1.0","Crossword","CrystalStacker","CUA-OPL-1.0","Cube","curl","D-FSL-1.0","diffmark","WTFPL","DOC","Dotseqn","DSDP","dvipdfm","EPL-1.0","ECL-1.0","ECL-2.0","eGenix",
37+
"EFL-1.0","EFL-2.0","MIT-advertising","MIT-enna","Entessa","ErlPL-1.1","EUDatagrid","EUPL-1.0","EUPL-1.1","Eurosym","Fair","MIT-feh","Frameworx-1.0","FreeImage","FTL","FSFAP","FSFUL","FSFULLR","Giftware",
38+
"GL2PS","Glulxe","AGPL-3.0","GFDL-1.1","GFDL-1.2","GFDL-1.3","GPL-1.0","GPL-2.0","GPL-3.0","LGPL-2.1","LGPL-3.0","LGPL-2.0","gnuplot","gSOAP-1.3b","HaskellReport","HPND","IBM-pibs","IPL-1.0","ICU",
39+
"ImageMagick","iMatix","Imlib2","IJG","Info-ZIP","Intel-ACPI","Intel","Interbase-1.0","IPA","ISC","JasPer-2.0","JSON","LPPL-1.0","LPPL-1.1","LPPL-1.2","LPPL-1.3a","LPPL-1.3c","Latex2e","BSD-3-Clause-LBNL",
40+
"Leptonica","LGPLLR","Libpng","libtiff","LAL-1.2","LAL-1.3","LiLiQ-P-1.1","LiLiQ-Rplus-1.1","LiLiQ-R-1.1","LPL-1.02","LPL-1.0","MakeIndex","MTLL","MS-PL","MS-RL","MirOS","MITNFA","MIT","Motosoto",
41+
"MPL-1.0","MPL-1.1","MPL-2.0","MPL-2.0-no-copyleft-exception","mpich2","Multics","Mup","NASA-1.3","Naumen","NBPL-1.0","Net-SNMP","NetCDF","NGPL","NOSL","NPL-1.0","NPL-1.1","Newsletr","NLPL","Nokia",
42+
"NPOSL-3.0","NLOD-1.0","Noweb","NRL","NTP","Nunit","OCLC-2.0","ODbL-1.0","proprietary","PDDL-1.0","OCCT-PL","OGTSL","OLDAP-2.2.2","OLDAP-1.1","OLDAP-1.2","OLDAP-1.3","OLDAP-1.4","OLDAP-2.0","OLDAP-2.0.1","OLDAP-2.1",
43+
"OLDAP-2.2","OLDAP-2.2.1","OLDAP-2.3","OLDAP-2.4","OLDAP-2.5","OLDAP-2.6","OLDAP-2.7","OLDAP-2.8","OML","OPL-1.0","OSL-1.0","OSL-1.1","OSL-2.0","OSL-2.1","OSL-3.0","OpenSSL","OSET-PL-2.1",
44+
"PHP-3.0","PHP-3.01","Plexus","PostgreSQL","psfrag","psutils","Python-2.0","QPL-1.0","Qhull","Rdisc","RPSL-1.0","RPL-1.1","RPL-1.5","RHeCos-1.1","RSCPL","RSA-MD","Ruby","SAX-PD","Saxpath","SCEA","SWL",
45+
"SMPPL","Sendmail","SGI-B-1.0","SGI-B-1.1","SGI-B-2.0","OFL-1.0","OFL-1.1","SimPL-2.0","Sleepycat","SNIA","Spencer-86","Spencer-94","Spencer-99","SMLNJ","SugarCRM-1.1.3","SISSL","SISSL-1.2","SPL-1.0",
46+
"Watcom-1.0","TCL","TCP-wrappers","Unlicense","TMate","TORQUE-1.1","TOSL","Unicode-DFS-2015","Unicode-DFS-2016","Unicode-TOU","UPL-1.0","NCSA","Vim","VOSTROM","VSL-1.0","W3C-20150513","W3C-19980720",
47+
"W3C","Wsuipa","Xnet","X11","Xerox","XFree86-1.1","xinetd","xpp","XSkat","YPL-1.0","YPL-1.1","Zed","Zend-2.0","Zimbra-1.3","Zimbra-1.4","Zlib","zlib-acknowledgement","ZPL-1.1","ZPL-2.0","ZPL-2.1"
48+
],
49+
"default": "Apache-2.0"
50+
},
51+
"summary": {
52+
"description": "A one-line description of your module",
53+
"type": "string",
54+
"minLength": 1
55+
},
56+
"source": {
57+
"description": "The source repository for your module",
58+
"type": "string",
59+
"minLength": 1
60+
},
61+
"dependencies": {
62+
"description": "A list of modules that this module depends on",
63+
"type": "array",
64+
"items": {
65+
"$ref": "#/definitions/module_dependency"
66+
},
67+
"uniqueItems": true
68+
},
69+
"requirements": {
70+
"description": "A list of requirements that this module needs",
71+
"type": "array",
72+
"items": {
73+
"$ref": "#/definitions/module_requirement"
74+
},
75+
"uniqueItems": true
76+
},
77+
"project_page": {
78+
"description": "A link to your module's website to be included on the Forge",
79+
"type": "string",
80+
"format": "uri"
81+
},
82+
"issues_url": {
83+
"description": "A link to your module's issue tracker",
84+
"type": "string",
85+
"format": "uri"
86+
},
87+
"operatingsystem_support": {
88+
"description": "A list of operating systems that this module supports",
89+
"type": "array",
90+
"items": {
91+
"$ref": "#/definitions/module_operating_system"
92+
},
93+
"uniqueItems": true
94+
},
95+
"tags": {
96+
"description": "A list of tags that would categorize this module",
97+
"type": "array",
98+
"items": {
99+
"type": "string",
100+
"minLength": 1
101+
},
102+
"minItems": 1,
103+
"uniqueItems": true
104+
}
105+
},
106+
"required": [
107+
"name",
108+
"version",
109+
"author",
110+
"license",
111+
"summary",
112+
"source",
113+
"dependencies"
114+
],
115+
"additionalProperties": false,
116+
117+
"definitions": {
118+
"module_dependency": {
119+
"properties": {
120+
"name": {
121+
"description": "Name of the dependent module",
122+
"type":"string",
123+
"minLength": 1
124+
},
125+
"version_requirement": {
126+
"description": "Version specification for the dependent module",
127+
"type":"string",
128+
"minLength": 1
129+
}
130+
},
131+
"required": ["name","version_requirement"],
132+
"additionalProperties": false
133+
},
134+
"module_requirement": {
135+
"properties": {
136+
"name": {
137+
"description": "Name of the requirement. 'pe' is deprecated ",
138+
"type":"string",
139+
"minLength": 1,
140+
"pattern": "^((?!^pe$).)*$"
141+
},
142+
"version_requirement": {
143+
"description": "Version specification for the requirement",
144+
"type":"string",
145+
"minLength": 1
146+
}
147+
},
148+
"required": ["name","version_requirement"],
149+
"additionalProperties": false
150+
},
151+
"module_operating_system": {
152+
"properties": {
153+
"operatingsystem": {
154+
"description": "Name of the operating system family, for example 'redhat' or 'windows'",
155+
"type":"string",
156+
"minLength": 1
157+
},
158+
"operatingsystemrelease": {
159+
"description": "Version specification for the dependent module",
160+
"type": "array",
161+
"items": {
162+
"type": "string",
163+
"minLength": 1
164+
},
165+
"minItems": 1,
166+
"uniqueItems": true
167+
}
168+
},
169+
"required": ["operatingsystem"],
170+
"additionalProperties": false
171+
}
172+
}
173+
}

0 commit comments

Comments
 (0)