Skip to content

Commit

Permalink
Merge pull request kubernetes#2425 from justaugustus/refactor-revert
Browse files Browse the repository at this point in the history
Revert "Merge pull request kubernetes#2387 from justaugustus/cleanup"
  • Loading branch information
k8s-ci-robot authored Feb 4, 2021
2 parents 0a495c8 + 0d6484e commit 3e2c87b
Show file tree
Hide file tree
Showing 34 changed files with 375 additions and 869 deletions.
99 changes: 0 additions & 99 deletions api/approval.go

This file was deleted.

76 changes: 0 additions & 76 deletions api/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@ limitations under the License.

package api

import (
"bufio"
"bytes"
"crypto/md5"
"fmt"
"io"
"strings"

"github.com/go-playground/validator/v10"
"github.com/pkg/errors"
"gopkg.in/yaml.v3"
)

type Proposals []*Proposal

func (p *Proposals) AddProposal(proposal *Proposal) {
Expand Down Expand Up @@ -69,65 +56,6 @@ type Proposal struct {
Contents string `json:"markdown" yaml:"-"`
}

func (p *Proposal) Validate() error {
v := validator.New()
if err := v.Struct(p); err != nil {
return errors.Wrap(err, "running validation")
}

return nil
}

type KEPHandler Parser

// TODO(api): Make this a generic parser for all `Document` types
func (k *KEPHandler) Parse(in io.Reader) (*Proposal, error) {
scanner := bufio.NewScanner(in)
count := 0
metadata := []byte{}
var body bytes.Buffer
for scanner.Scan() {
line := scanner.Text() + "\n"
if strings.Contains(line, "---") {
count++
continue
}
if count == 1 {
metadata = append(metadata, []byte(line)...)
} else {
body.WriteString(line)
}
}

kep := &Proposal{
Contents: body.String(),
}

if err := scanner.Err(); err != nil {
return kep, errors.Wrap(err, "reading file")
}

// this file is just the KEP metadata
if count == 0 {
metadata = body.Bytes()
kep.Contents = ""
}

if err := yaml.Unmarshal(metadata, &kep); err != nil {
k.Errors = append(k.Errors, errors.Wrap(err, "error unmarshalling YAML"))
return kep, errors.Wrap(err, "unmarshalling YAML")
}

if valErr := kep.Validate(); valErr != nil {
k.Errors = append(k.Errors, errors.Wrap(valErr, "validating KEP"))
return kep, errors.Wrap(valErr, "validating KEP")
}

kep.ID = hash(kep.OwningSIG + ":" + kep.Title)

return kep, nil
}

type Milestone struct {
Alpha string `json:"alpha" yaml:"alpha"`
Beta string `json:"beta" yaml:"beta"`
Expand All @@ -138,7 +66,3 @@ type FeatureGate struct {
Name string `json:"name" yaml:"name"`
Components []string `json:"components" yaml:"components"`
}

func hash(s string) string {
return fmt.Sprintf("%x", md5.Sum([]byte(s)))
}
106 changes: 0 additions & 106 deletions cmd/kepctl/cmd/create.go

This file was deleted.

72 changes: 0 additions & 72 deletions cmd/kepctl/cmd/promote.go

This file was deleted.

Loading

0 comments on commit 3e2c87b

Please sign in to comment.