@@ -16,19 +16,6 @@ limitations under the License.
16
16
17
17
package api
18
18
19
- import (
20
- "bufio"
21
- "bytes"
22
- "crypto/md5"
23
- "fmt"
24
- "io"
25
- "strings"
26
-
27
- "github.com/go-playground/validator/v10"
28
- "github.com/pkg/errors"
29
- "gopkg.in/yaml.v3"
30
- )
31
-
32
19
type Proposals []* Proposal
33
20
34
21
func (p * Proposals ) AddProposal (proposal * Proposal ) {
@@ -69,65 +56,6 @@ type Proposal struct {
69
56
Contents string `json:"markdown" yaml:"-"`
70
57
}
71
58
72
- func (p * Proposal ) Validate () error {
73
- v := validator .New ()
74
- if err := v .Struct (p ); err != nil {
75
- return errors .Wrap (err , "running validation" )
76
- }
77
-
78
- return nil
79
- }
80
-
81
- type KEPHandler Parser
82
-
83
- // TODO(api): Make this a generic parser for all `Document` types
84
- func (k * KEPHandler ) Parse (in io.Reader ) (* Proposal , error ) {
85
- scanner := bufio .NewScanner (in )
86
- count := 0
87
- metadata := []byte {}
88
- var body bytes.Buffer
89
- for scanner .Scan () {
90
- line := scanner .Text () + "\n "
91
- if strings .Contains (line , "---" ) {
92
- count ++
93
- continue
94
- }
95
- if count == 1 {
96
- metadata = append (metadata , []byte (line )... )
97
- } else {
98
- body .WriteString (line )
99
- }
100
- }
101
-
102
- kep := & Proposal {
103
- Contents : body .String (),
104
- }
105
-
106
- if err := scanner .Err (); err != nil {
107
- return kep , errors .Wrap (err , "reading file" )
108
- }
109
-
110
- // this file is just the KEP metadata
111
- if count == 0 {
112
- metadata = body .Bytes ()
113
- kep .Contents = ""
114
- }
115
-
116
- if err := yaml .Unmarshal (metadata , & kep ); err != nil {
117
- k .Errors = append (k .Errors , errors .Wrap (err , "error unmarshalling YAML" ))
118
- return kep , errors .Wrap (err , "unmarshalling YAML" )
119
- }
120
-
121
- if valErr := kep .Validate (); valErr != nil {
122
- k .Errors = append (k .Errors , errors .Wrap (valErr , "validating KEP" ))
123
- return kep , errors .Wrap (valErr , "validating KEP" )
124
- }
125
-
126
- kep .ID = hash (kep .OwningSIG + ":" + kep .Title )
127
-
128
- return kep , nil
129
- }
130
-
131
59
type Milestone struct {
132
60
Alpha string `json:"alpha" yaml:"alpha"`
133
61
Beta string `json:"beta" yaml:"beta"`
@@ -138,7 +66,3 @@ type FeatureGate struct {
138
66
Name string `json:"name" yaml:"name"`
139
67
Components []string `json:"components" yaml:"components"`
140
68
}
141
-
142
- func hash (s string ) string {
143
- return fmt .Sprintf ("%x" , md5 .Sum ([]byte (s )))
144
- }
0 commit comments