forked from devfile/library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse.go
89 lines (75 loc) · 2.32 KB
/
parse.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package devfile
import (
"github.com/maysunfaisal/parser/pkg/devfile/parser"
"github.com/maysunfaisal/parser/pkg/devfile/validate"
)
// ParseFromURLAndValidate func parses the devfile data from the url
// and validates the devfile integrity with the schema
// and validates the devfile data.
// Creates devfile context and runtime objects.
// Deprecated, use ParseDevfileAndValidate() instead
func ParseFromURLAndValidate(url string) (d parser.DevfileObj, err error) {
// read and parse devfile from the given URL
d, err = parser.ParseFromURL(url)
if err != nil {
return d, err
}
// generic validation on devfile content
err = validate.ValidateDevfileData(d.Data)
if err != nil {
return d, err
}
return d, err
}
// ParseFromDataAndValidate func parses the devfile data
// and validates the devfile integrity with the schema
// and validates the devfile data.
// Creates devfile context and runtime objects.
// Deprecated, use ParseDevfileAndValidate() instead
func ParseFromDataAndValidate(data []byte) (d parser.DevfileObj, err error) {
// read and parse devfile from the given bytes
d, err = parser.ParseFromData(data)
if err != nil {
return d, err
}
// generic validation on devfile content
err = validate.ValidateDevfileData(d.Data)
if err != nil {
return d, err
}
return d, err
}
// ParseAndValidate func parses the devfile data
// and validates the devfile integrity with the schema
// and validates the devfile data.
// Creates devfile context and runtime objects.
// Deprecated, use ParseDevfileAndValidate() instead
func ParseAndValidate(path string) (d parser.DevfileObj, err error) {
// read and parse devfile from given path
d, err = parser.Parse(path)
if err != nil {
return d, err
}
// generic validation on devfile content
err = validate.ValidateDevfileData(d.Data)
if err != nil {
return d, err
}
return d, err
}
// ParseDevfileAndValidate func parses the devfile data
// and validates the devfile integrity with the schema
// and validates the devfile data.
// Creates devfile context and runtime objects.
func ParseDevfileAndValidate(args parser.ParserArgs) (d parser.DevfileObj, err error) {
d, err = parser.ParseDevfile(args)
if err != nil {
return d, err
}
// generic validation on devfile content
err = validate.ValidateDevfileData(d.Data)
if err != nil {
return d, err
}
return d, err
}