kube-openapi: k8s.io/kube-openapi/pkg/generators/rules Index | Files

package rules

import "k8s.io/kube-openapi/pkg/generators/rules"

Package rules contains API rules that are enforced in OpenAPI spec generation as part of the machinery. Files under this package implement APIRule interface which evaluates Go type and produces list of API rule violations.

Implementations of APIRule should be added to API linter under openAPIGen code- generator to get integrated in the generation process.

Index

Package Files

doc.go idl_tag.go names_match.go omitempty_match_case.go

Constants

const ListTypeIDLTag = "listType"

type ListTypeMissing Uses

type ListTypeMissing struct{}

ListTypeMissing implements APIRule interface. A list type is required for inlined list.

func (*ListTypeMissing) Name Uses

func (l *ListTypeMissing) Name() string

Name returns the name of APIRule

func (*ListTypeMissing) Validate Uses

func (l *ListTypeMissing) Validate(t *types.Type) ([]string, error)

Validate evaluates API rule on type t and returns a list of field names in the type that violate the rule. Empty field name [""] implies the entire type violates the rule.

type NamesMatch Uses

type NamesMatch struct{}

NamesMatch implements APIRule interface. Go field names must be CamelCase. JSON field names must be camelCase. Other than capitalization of the initial letter, the two should almost always match. No underscores nor dashes in either. This rule verifies the convention "Other than capitalization of the initial letter, the two should almost always match." Examples (also in unit test):

Go name      | JSON name    | match
               podSpec        false
PodSpec        podSpec        true
PodSpec        PodSpec        false
podSpec        podSpec        false
PodSpec        spec           false
Spec           podSpec        false
JSONSpec       jsonSpec       true
JSONSpec       jsonspec       false
HTTPJSONSpec   httpJSONSpec   true

NOTE: this validator cannot tell two sequential all-capital words from one word, therefore the case below is also considered matched.

HTTPJSONSpec   httpjsonSpec   true

NOTE: JSON names in jsonNameBlacklist should skip evaluation

                              true
podSpec                       true
podSpec        -              true
podSpec        metadata       true

func (*NamesMatch) Name Uses

func (n *NamesMatch) Name() string

Name returns the name of APIRule

func (*NamesMatch) Validate Uses

func (n *NamesMatch) Validate(t *types.Type) ([]string, error)

Validate evaluates API rule on type t and returns a list of field names in the type that violate the rule. Empty field name [""] implies the entire type violates the rule.

type OmitEmptyMatchCase Uses

type OmitEmptyMatchCase struct{}

OmitEmptyMatchCase implements APIRule interface. "omitempty" must appear verbatim (no case variants).

func (*OmitEmptyMatchCase) Name Uses

func (n *OmitEmptyMatchCase) Name() string

func (*OmitEmptyMatchCase) Validate Uses

func (n *OmitEmptyMatchCase) Validate(t *types.Type) ([]string, error)

Package rules imports 4 packages (graph) and is imported by 2 packages. Updated 2019-05-12. Refresh now. Tools for package owners.