api

package
v0.0.0-...-2395264 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPRRMilestonesAllEmpty error = errors.New(
		"none of the PRR milestones are populated",
	)

	ErrPRRMilestoneIsNil error = errors.New(
		"the selected PRR milestone stage is not populated",
	)

	ErrPRRApproverUnknown error = errors.New(
		"an unknown error occurred while trying to determine a PRR approver",
	)
)
View Source
var ValidStages = []Stage{
	AlphaStage,
	BetaStage,
	StableStage,
}

Functions

func IsOneOf

func IsOneOf(check string, slice []string) bool

TODO: Can we come up with a better name/location for this?

Types

type Document

type Document interface {
	Validate() error
}

Document is an interface satisfied by the following types: - `Proposal` (KEP) - `PRRApproval` - `Receipt` (coming soon) TODO(api): Populate interface and regenerate mocks

type FeatureGate

type FeatureGate struct {
	Name       string   `json:"name" yaml:"name"`
	Components []string `json:"components" yaml:"components"`
}

type File

type File interface {
	Parse(io.Reader) (Document, error)
}

TODO(api): Populate interface and regenerate mocks

type GroupFetcher

type GroupFetcher interface {
	// FetchGroups returns the list of valid Kubernetes Community groups
	// e.g. (SIGs, WGs, UGs, Committees)
	FetchGroups() ([]string, error)
	// FetchPRRApprovers returns the list of valid PRR Approvers
	FetchPRRApprovers() ([]string, error)
}

GroupFetcher is responsible for getting informationg about groups in the Kubernetes Community

func DefaultGroupFetcher

func DefaultGroupFetcher() GroupFetcher

DefaultGroupFetcher returns the default GroupFetcher, which depends on GitHub

func NewMockGroupFetcher

func NewMockGroupFetcher(groups, prrApprovers []string) GroupFetcher

type KEPHandler

type KEPHandler Parser

func (*KEPHandler) Parse

func (k *KEPHandler) Parse(in io.Reader) (*Proposal, error)

TODO(api): Make this a generic parser for all `Document` types

func (*KEPHandler) Validate

func (k *KEPHandler) Validate(p *Proposal) []error

Validate returns errors for each reason the given proposal is invalid, or nil if it is valid

type Milestone

type Milestone struct {
	Alpha      string `json:"alpha" yaml:"alpha"`
	Beta       string `json:"beta" yaml:"beta"`
	Stable     string `json:"stable" yaml:"stable"`
	Deprecated string `json:"deprecated" yaml:"deprecated,omitempty"`
	Removed    string `json:"removed" yaml:"removed,omitempty"`
}

type MockGroupFetcher

type MockGroupFetcher struct {
	Groups       []string
	PRRApprovers []string
}

MockGroupFetcher returns the given Groups and PRR Approvers

func (*MockGroupFetcher) FetchGroups

func (f *MockGroupFetcher) FetchGroups() ([]string, error)

func (*MockGroupFetcher) FetchPRRApprovers

func (f *MockGroupFetcher) FetchPRRApprovers() ([]string, error)

type PRRApproval

type PRRApproval struct {
	Number string `json:"kepNumber" yaml:"kep-number" validate:"required"`

	// TODO: Need to validate these milestone pointers are not nil
	Alpha      *PRRMilestone `json:"alpha" yaml:"alpha,omitempty"`
	Beta       *PRRMilestone `json:"beta" yaml:"beta,omitempty"`
	Stable     *PRRMilestone `json:"stable" yaml:"stable,omitempty"`
	Deprecated *PRRMilestone `json:"deprecated" yaml:"deprecated,omitempty"`
	Removed    *PRRMilestone `json:"removed", yaml:"removed,omitempty"`

	// TODO(api): Move to separate struct for handling document parsing
	Error error `json:"-" yaml:"-"`
}

func (*PRRApproval) ApproverForStage

func (prr *PRRApproval) ApproverForStage(stage Stage) (string, error)

func (*PRRApproval) Validate

func (prr *PRRApproval) Validate() error

type PRRApprovals

type PRRApprovals []*PRRApproval

func (*PRRApprovals) AddPRRApproval

func (p *PRRApprovals) AddPRRApproval(prrApproval *PRRApproval)

type PRRHandler

type PRRHandler Parser

func (*PRRHandler) Parse

func (p *PRRHandler) Parse(in io.Reader) (*PRRApproval, error)

TODO(api): Make this a generic parser for all `Document` types

type PRRMilestone

type PRRMilestone struct {
	Approver string `json:"approver" yaml:"approver" validate:"required"`
}

TODO(api): Can we refactor the proposal `Milestone` to retrieve this?

type Parser

type Parser struct {
	Groups       []string
	PRRApprovers []string

	Errors []error
}

type Proposal

type Proposal struct {
	ID       string `json:"id"`
	PRNumber string `json:"prNumber,omitempty"`
	Name     string `json:"name,omitempty"`

	Title             string   `json:"title" yaml:"title" validate:"required"`
	Number            string   `json:"kepNumber" yaml:"kep-number" validate:"required"`
	Authors           []string `json:"authors" yaml:",flow" validate:"required"`
	OwningSIG         string   `json:"owningSig" yaml:"owning-sig" validate:"required"`
	ParticipatingSIGs []string `json:"participatingSigs" yaml:"participating-sigs,flow,omitempty"`
	Reviewers         []string `json:"reviewers" yaml:",flow"`
	Approvers         []string `json:"approvers" yaml:",flow" validate:"required"`
	Editor            string   `json:"editor" yaml:"editor,omitempty"`
	CreationDate      string   `json:"creationDate" yaml:"creation-date"`
	LastUpdated       string   `json:"lastUpdated" yaml:"last-updated"`
	Status            Status   `json:"status" yaml:"status" validate:"required"`
	SeeAlso           []string `json:"seeAlso" yaml:"see-also,omitempty"`
	Replaces          []string `json:"replaces" yaml:"replaces,omitempty"`
	SupersededBy      []string `json:"supersededBy" yaml:"superseded-by,omitempty"`

	Stage           Stage     `json:"stage" yaml:"stage"`
	LatestMilestone string    `json:"latestMilestone" yaml:"latest-milestone"`
	Milestone       Milestone `json:"milestone" yaml:"milestone"`

	FeatureGates     []FeatureGate `json:"featureGates" yaml:"feature-gates"`
	DisableSupported bool          `json:"disableSupported" yaml:"disable-supported"`
	Metrics          []string      `json:"metrics" yaml:"metrics"`

	Filename string `json:"-" yaml:"-"`
	Error    error  `json:"-" yaml:"-"`
	Contents string `json:"markdown" yaml:"-"`
}

TODO(api): json fields are not using consistent casing

func (*Proposal) IsMissingMilestone

func (p *Proposal) IsMissingMilestone() bool

func (*Proposal) IsMissingStage

func (p *Proposal) IsMissingStage() bool

type Proposals

type Proposals []*Proposal

func (*Proposals) AddProposal

func (p *Proposals) AddProposal(proposal *Proposal)

type RemoteGroupFetcher

type RemoteGroupFetcher struct {
	// Basically kubernetes/community/sigs.yaml
	GroupsListURL string
	// Basically kubernetes/enhancements/OWNERS_ALIASES
	OwnersAliasesURL string
	// The alias name to look for PRR approvers in OWNERS_ALIASES
	PRRApproversAlias string
	// The alias name to look for emeritus PRR approvers in OWNERS_ALIASES
	PRRApproversEmeritusAlias string
}

RemoteGroupFetcher returns Groups and PRR Approvers from remote sources

func (*RemoteGroupFetcher) FetchGroups

func (f *RemoteGroupFetcher) FetchGroups() ([]string, error)

FetchGroups returns the list of valid Kubernetes Community groups as fetched from a remote source

func (*RemoteGroupFetcher) FetchPRRApprovers

func (f *RemoteGroupFetcher) FetchPRRApprovers() ([]string, error)

FetchPRRApprovers returns a list of PRR approvers.

type Stage

type Stage string
const (
	AlphaStage  Stage = "alpha"
	BetaStage   Stage = "beta"
	StableStage Stage = "stable"
)

func (Stage) IsValid

func (s Stage) IsValid() error

type Status

type Status string
const (
	ProvisionalStatus   Status = "provisional"
	ImplementableStatus Status = "implementable"
	ImplementedStatus   Status = "implemented"
	DeferredStatus      Status = "deferred"
	RejectedStatus      Status = "rejected"
	WithdrawnStatus     Status = "withdrawn"
	ReplacedStatus      Status = "replaced"
)

func (Status) IsValid

func (s Status) IsValid() error

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL