Skip to content

Commit 6322cd7

Browse files
committed
feat: support publiccode.yml 0.8
1 parent 3a4f1d6 commit 6322cd7

7 files changed

Lines changed: 109 additions & 7 deletions

File tree

‎parser.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ func (p *Parser) parseAndValidate(in io.Reader, fileURL *url.URL) (PublicCode, e
336336

337337
var ve ValidationResults
338338

339-
if slices.Contains(SupportedVersions, version) && version != "0" && !strings.HasPrefix(version, "0.7") {
339+
if slices.Contains(SupportedVersions, version) && version != "0" && !strings.HasPrefix(version, "0.8") {
340340
latestVersion := SupportedVersions[len(SupportedVersions)-1]
341341
line, column := getPositionInFile("publiccodeYmlVersion", file)
342342

‎publiccode.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var SupportedVersions = []string{
88
"0.4", "0.4.0",
99
"0.5.0", "0.5",
1010
"0.7.0", "0.7",
11+
"0.8.0", "0.8",
1112
}
1213

1314
type PublicCode interface {
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
publiccodeYmlVersion: "0.8"
2+
3+
name: Medusa
4+
url: "https://github.com/italia/developers.italia.it.git"
5+
6+
platforms:
7+
- web
8+
9+
categories:
10+
- cloud-management
11+
12+
developmentStatus: development
13+
14+
softwareType: "standalone/other"
15+
16+
description:
17+
en-GB:
18+
localisedName: Medusa
19+
shortDescription: >
20+
A rather short description which
21+
is probably useless
22+
longDescription: >
23+
Very long description of this software, also split
24+
on multiple rows. You should note what the software
25+
is and why one should need it. This is 158 characters.
26+
Very long description of this software, also split
27+
on multiple rows. You should note what the software
28+
is and why one should need it. This is 316 characters.
29+
Very long description of this software, also split
30+
on multiple rows. You should note what the software
31+
is and why one should need it. This is 474 characters.
32+
Very long description of this software, also split
33+
on multiple rows. You should note what the software
34+
is and why one should need it. This is 632 characters.
35+
features:
36+
- Just one feature
37+
38+
legal:
39+
license: AGPL-3.0-or-later
40+
41+
maintenance:
42+
type: "community"
43+
44+
contacts:
45+
- name: Francesco Rossi
46+
47+
localisation:
48+
localisationReady: true
49+
availableLanguages:
50+
- en
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
publiccodeYmlVersion: "0.7"
2+
3+
name: Medusa
4+
url: "https://github.com/italia/developers.italia.it.git"
5+
releaseDate: "2017-04-15"
6+
7+
platforms:
8+
- web
9+
10+
developmentStatus: development
11+
12+
softwareType: "standalone/other"
13+
14+
description:
15+
en:
16+
localisedName: Medusa
17+
shortDescription: >
18+
A rather short description which
19+
is probably useless
20+
longDescription: >
21+
Very long description of this software, also split
22+
on multiple rows. You should note what the software
23+
is and why one should need it. This is 158 characters.
24+
Very long description of this software, also split
25+
on multiple rows. You should note what the software
26+
is and why one should need it. This is 316 characters.
27+
Very long description of this software, also split
28+
on multiple rows. You should note what the software
29+
is and why one should need it. This is 474 characters.
30+
Very long description of this software, also split
31+
on multiple rows. You should note what the software
32+
is and why one should need it. This is 632 characters.
33+
features:
34+
- Just one feature
35+
36+
legal:
37+
license: AGPL-3.0-or-later
38+
39+
maintenance:
40+
type: "community"
41+
42+
contacts:
43+
- name: Francesco Rossi
44+
45+
localisation:
46+
localisationReady: true
47+
availableLanguages:
48+
- en

‎v0.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
// PublicCodeV0 defines how a publiccode.yml v0.x is structured.
1111
type PublicCodeV0 struct {
12-
PubliccodeYamlVersion string `json:"publiccodeYmlVersion" validate:"required,oneof=0 0.2 0.2.0 0.2.1 0.2.2 0.3 0.3.0 0.4 0.4.0 0.5 0.5.0 0.7 0.7.0" yaml:"publiccodeYmlVersion"`
12+
PubliccodeYamlVersion string `json:"publiccodeYmlVersion" validate:"required,oneof=0 0.2 0.2.0 0.2.1 0.2.2 0.3 0.3.0 0.4 0.4.0 0.5 0.5.0 0.7 0.7.0 0.8 0.8.0" yaml:"publiccodeYmlVersion"`
1313

1414
Name string `json:"name" validate:"required" yaml:"name"`
1515
ApplicationSuite string `json:"applicationSuite,omitempty" yaml:"applicationSuite,omitempty"`

‎v0_test.go‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func TestInvalidTestcasesV0(t *testing.T) {
116116
ValidationError{
117117
"",
118118
"publiccodeYmlVersion",
119-
"unsupported version: '1'. Supported versions: 0, 0.2, 0.2.0, 0.2.1, 0.2.2, 0.3, 0.3.0, 0.4, 0.4.0, 0.5.0, 0.5, 0.7.0, 0.7",
119+
"unsupported version: '1'. Supported versions: 0, 0.2, 0.2.0, 0.2.1, 0.2.2, 0.3, 0.3.0, 0.4, 0.4.0, 0.5.0, 0.5, 0.7.0, 0.7, 0.8.0, 0.8",
120120
0,
121121
0,
122122
},
@@ -615,13 +615,16 @@ func TestValidWithWarningsTestcasesV0(t *testing.T) {
615615
ValidationWarning{"", "description.en.genericName", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 23, 5},
616616
},
617617
"valid.minimal.v0.2.yml": ValidationResults{
618-
ValidationWarning{"", "publiccodeYmlVersion", "v0.2 is not the latest version, use '0'. Parsing this file as v0.7.", 1, 1},
618+
ValidationWarning{"", "publiccodeYmlVersion", "v0.2 is not the latest version, use '0'. Parsing this file as v0.8.", 1, 1},
619619
},
620620
"valid.minimal.v0.3.yml": ValidationResults{
621-
ValidationWarning{"", "publiccodeYmlVersion", "v0.3 is not the latest version, use '0'. Parsing this file as v0.7.", 1, 1},
621+
ValidationWarning{"", "publiccodeYmlVersion", "v0.3 is not the latest version, use '0'. Parsing this file as v0.8.", 1, 1},
622622
},
623623
"valid.minimal.v0.4.yml": ValidationResults{
624-
ValidationWarning{"", "publiccodeYmlVersion", "v0.4 is not the latest version, use '0'. Parsing this file as v0.7.", 1, 1},
624+
ValidationWarning{"", "publiccodeYmlVersion", "v0.4 is not the latest version, use '0'. Parsing this file as v0.8.", 1, 1},
625+
},
626+
"valid.minimal.v0.7.yml": ValidationResults{
627+
ValidationWarning{"", "publiccodeYmlVersion", "v0.7 is not the latest version, use '0'. Parsing this file as v0.8.", 1, 1},
625628
},
626629
"valid.mime_types.yml": ValidationResults{
627630
ValidationWarning{"", "inputTypes", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 48, 1},

‎v1_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func TestInvalidTestcasesV1(t *testing.T) {
1515
ValidationError{
1616
"",
1717
"publiccodeYmlVersion",
18-
"unsupported version: '1'. Supported versions: 0, 0.2, 0.2.0, 0.2.1, 0.2.2, 0.3, 0.3.0, 0.4, 0.4.0, 0.5.0, 0.5, 0.7.0, 0.7",
18+
"unsupported version: '1'. Supported versions: 0, 0.2, 0.2.0, 0.2.1, 0.2.2, 0.3, 0.3.0, 0.4, 0.4.0, 0.5.0, 0.5, 0.7.0, 0.7, 0.8.0, 0.8",
1919
0,
2020
0,
2121
},

0 commit comments

Comments
 (0)