Skip to content

Commit 0e78730

Browse files
committed
api: Add Document interface and PRR approval types
Signed-off-by: Stephen Augustus <[email protected]>
1 parent 322997e commit 0e78730

File tree

3 files changed

+61
-21
lines changed

3 files changed

+61
-21
lines changed

api/approval.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Copyright 2021 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package api
18+
19+
type PRRApprovals []*PRRApproval
20+
21+
func (p *PRRApprovals) AddPRRApproval(prrApproval *PRRApproval) {
22+
*p = append(*p, prrApproval)
23+
}
24+
25+
type PRRApproval struct {
26+
Number string `json:"kep-number" yaml:"kep-number"`
27+
Alpha PRRMilestone `json:"alpha" yaml:"alpha,omitempty"`
28+
Beta PRRMilestone `json:"beta" yaml:"beta,omitempty"`
29+
Stable PRRMilestone `json:"stable" yaml:"stable,omitempty"`
30+
31+
Error error `json:"-" yaml:"-"`
32+
}
33+
34+
// TODO(api): Can we refactor the proposal `Milestone` to retrieve this?
35+
type PRRMilestone struct {
36+
Approver string `json:"approver" yaml:"approver"`
37+
}

api/document.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
Copyright 2021 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package api
18+
19+
// TODO(api): Populate interface
20+
// TODO(api): Mock interface
21+
type Document interface{}

pkg/kepval/prrs/approvals.go

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,39 +24,21 @@ import (
2424
"github.com/pkg/errors"
2525
"gopkg.in/yaml.v3"
2626

27+
"k8s.io/enhancements/api"
2728
"k8s.io/enhancements/pkg/kepval/prrs/validations"
2829
)
2930

30-
type Approvals []*Approval
31-
32-
func (a *Approvals) AddApproval(approval *Approval) {
33-
*a = append(*a, approval)
34-
}
35-
36-
type Milestone struct {
37-
Approver string `json:"approver" yaml:"approver"`
38-
}
39-
40-
type Approval struct {
41-
Number string `json:"kep-number" yaml:"kep-number"`
42-
Alpha Milestone `json:"alpha" yaml:"alpha"`
43-
Beta Milestone `json:"beta" yaml:"beta"`
44-
Stable Milestone `json:"stable" yaml:"stable"`
45-
46-
Error error `json:"-" yaml:"-"`
47-
}
48-
4931
type Parser struct{}
5032

51-
func (p *Parser) Parse(in io.Reader) *Approval {
33+
func (p *Parser) Parse(in io.Reader) *api.PRRApproval {
5234
scanner := bufio.NewScanner(in)
5335
var body bytes.Buffer
5436
for scanner.Scan() {
5537
line := scanner.Text() + "\n"
5638
body.WriteString(line)
5739
}
5840

59-
approval := &Approval{}
41+
approval := &api.PRRApproval{}
6042
if err := scanner.Err(); err != nil {
6143
approval.Error = errors.Wrap(err, "error reading file")
6244
return approval

0 commit comments

Comments
 (0)