swagger

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DataDirEnvVar = "KUBECTL_SCHEMA_DATA_DIRECTORY"
)

Variables

View Source
var (
	GithubOpenapiURLTemplate = "https://raw.githubusercontent.com/kubernetes/kubernetes/v%s/api/openapi-spec/swagger.json"

	// LatestKubePatchVersionStrings records the latest known patch versions for each minor version
	//   these version numbers come from https://github.com/kubernetes/kubernetes/tree/master/CHANGELOG
	LatestKubePatchVersionStrings = []string{

		"1.5.8",
		"1.6.13",
		"1.7.16",
		"1.8.15",
		"1.9.11",
		"1.10.13",
		"1.11.10",
		"1.12.10",
		"1.13.12",
		"1.14.10",
		"1.15.12",
		"1.16.15",
		"1.17.17",
		"1.18.20",
		"1.19.16",
		"1.20.15",
		"1.21.14",
		"1.22.17",
		"1.23.17",
		"1.24.17",
		"1.25.13",
		"1.26.8",
		"1.27.5",
		"1.28.1",
	}

	LatestKubePatchVersions = slice.Map(MustVersion, LatestKubePatchVersionStrings)
)
View Source
var (
	CompareKubeVersion = slice.CompareSlicePairwise[string]()
)

Functions

func CompareResolvedResources

func CompareResolvedResources(a *ResolvedType, b *ResolvedType) *diff.JsonDiff

func CompareResolvedResourcesHelper

func CompareResolvedResourcesHelper(a *ResolvedType, b *ResolvedType, pathContext []string, diffs *diff.JsonDiff)

func CondensedResource

func CondensedResource(apiVersion string, resolvedType *ResolvedType, allowPath func([]string) bool) string

func GetSpecsRootDirectory added in v0.0.5

func GetSpecsRootDirectory() string

func IsPrefixOf

func IsPrefixOf[A comparable](xs []A, ys []A) bool

func MakePathFromKubeVersion

func MakePathFromKubeVersion(version KubeVersion) string

func MustDownloadSwaggerSpec

func MustDownloadSwaggerSpec(version KubeVersion) []byte

func ParseRef

func ParseRef(ref string) string

func RunCompareResource

func RunCompareResource(args *CompareResourceArgs)

func RunExplain

func RunExplain(args *ExplainArgs)

func RunRootSchemaCommand

func RunRootSchemaCommand()

func RunShowResources

func RunShowResources(args *ShowResourcesArgs)

func RunVersionCommand

func RunVersionCommand()

func SetupCompareResourceCommand added in v0.0.9

func SetupCompareResourceCommand() *cobra.Command

func SetupConfigCommand added in v0.1.1

func SetupConfigCommand() *cobra.Command

func SetupExplainCommand

func SetupExplainCommand() *cobra.Command

func SetupRootSchemaCommand

func SetupRootSchemaCommand() *cobra.Command

func SetupShowResourcesCommand

func SetupShowResourcesCommand() *cobra.Command

func SetupVersionCommand

func SetupVersionCommand() *cobra.Command

func ShowResources

func ShowResources(groupBy ShowResourcesGroupBy, versions []string, include func(string, string) bool, calculateDiff bool) string

func TableResource

func TableResource(resolvedType *ResolvedType, allowPath func([]string) bool) string

Types

type CompareResourceArgs

type CompareResourceArgs struct {
	KubeVersions []string
	ApiVersions  []string
	Resources    []string
}

type ExplainArgs

type ExplainArgs struct {
	Format       string
	ApiVersions  []string
	Resources    []string
	KubeVersions []string
	Depth        int
	Paths        []string
}

type GVK

type GVK struct {
	Group   string `json:"group"`
	Version string `json:"version"`
	Kind    string `json:"kind"`
}

func ParseGVK

func ParseGVK(gvk string) *GVK

func (*GVK) GroupVersion

func (g *GVK) GroupVersion() string

func (*GVK) ToString

func (g *GVK) ToString() string

type KubeSpec

type KubeSpec struct {
	Definitions map[string]*SpecType `json:"definitions"`
	Info        struct {
		Title   string `json:"title"`
		Version string `json:"version"`
	} `json:"info"`
}

func MustReadSwaggerSpecFromGithub

func MustReadSwaggerSpecFromGithub(version KubeVersion) *KubeSpec

func ReadSwaggerSpecFromGithub

func ReadSwaggerSpecFromGithub(version KubeVersion) (*KubeSpec, error)

func (*KubeSpec) MustGetDefinition

func (s *KubeSpec) MustGetDefinition(name string) *SpecType

func (*KubeSpec) ResolveStructure

func (s *KubeSpec) ResolveStructure() map[string]map[string]*ResolvedType

func (*KubeSpec) Visit

func (s *KubeSpec) Visit(visit func(path Path, resolved *ResolvedType, circular string)) (map[string]*ResolvedType, map[string]map[string]*ResolvedType)

func (*KubeSpec) VisitSpecType

func (s *KubeSpec) VisitSpecType(resolvedTypes map[string]*ResolvedType, path Path, specType *SpecType, visit func(path Path, resolved *ResolvedType, circular string)) *ResolvedType

type KubeVersion

type KubeVersion []string

func MustVersion

func MustVersion(v string) KubeVersion

func NewVersion

func NewVersion(v string) (KubeVersion, error)

func (KubeVersion) Compare

func (v KubeVersion) Compare(b KubeVersion) base.Ordering

func (KubeVersion) SwaggerSpecURL

func (v KubeVersion) SwaggerSpecURL() string

func (KubeVersion) ToString

func (v KubeVersion) ToString() string

type Path

type Path []SpecPath

func (Path) Append

func (p Path) Append(piece SpecPath) Path

func (Path) ToStringPieces

func (p Path) ToStringPieces() []string

type PivotTable

type PivotTable struct {
	FirstColumnHeader string
	Rows              map[string]map[string][]string
	Columns           []string
	// contains filtered or unexported fields
}

func NewPivotTable

func NewPivotTable(firstColumn string, restColumns []string) *PivotTable

func (*PivotTable) Add

func (e *PivotTable) Add(rowKey string, columnKey string, value string)

func (*PivotTable) FormattedTable

func (e *PivotTable) FormattedTable(formatRow func(rowKey string, values [][]string) []string) string

type ResolvedObject

type ResolvedObject struct {
	Properties           map[string]*ResolvedType
	AdditionalProperties *ResolvedType
}

type ResolvedType

type ResolvedType struct {
	Empty     bool
	Primitive string
	Array     *ResolvedType
	Object    *ResolvedObject
	Circular  string
}

func (*ResolvedType) Paths

func (r *ResolvedType) Paths(pathContext []string) []*base.Pair[[]string, string]

type RootSchemaFlags

type RootSchemaFlags struct {
	Verbosity string
}

type ShowResourcesArgs

type ShowResourcesArgs struct {
	GroupBy      string
	KubeVersions []string
	ApiVersions  []string
	Resources    []string
	Diff         bool
}

func (*ShowResourcesArgs) GetGroupBy

func (s *ShowResourcesArgs) GetGroupBy() ShowResourcesGroupBy

type ShowResourcesGroupBy

type ShowResourcesGroupBy string
const (
	ShowResourcesGroupByResource   ShowResourcesGroupBy = "ShowResourcesGroupByResource"
	ShowResourcesGroupByApiVersion ShowResourcesGroupBy = "ShowResourcesGroupByApiVersion"
)

func (ShowResourcesGroupBy) Header

func (s ShowResourcesGroupBy) Header() string

type SpecPath

type SpecPath struct {
	FieldAccess    string
	Ref            bool
	ObjectProperty bool
	Array          bool
}

type SpecType

type SpecType struct {
	AdditionalProperties        *SpecType                `json:"additionalProperties,omitempty"`
	Description                 string                   `json:"description,omitempty"`
	Format                      string                   `json:"format,omitempty"`
	Items                       *SpecType                `json:"items,omitempty"`
	Properties                  map[string]*SpecType     `json:"properties,omitempty"`
	Ref                         string                   `json:"$ref,omitempty"`
	Required                    []string                 `json:"required,omitempty"`
	Type                        string                   `json:"type,omitempty"`
	XKubernetesListMapKeys      []string                 `json:"x-kubernetes-list-map-keys,omitempty"`
	XKubernetesListType         string                   `json:"x-kubernetes-list-type,omitempty"`
	XKubernetesPatchMergeKey    string                   `json:"x-kubernetes-patch-merge-key,omitempty"`
	XKubernetesPatchStrategy    string                   `json:"x-kubernetes-patch-strategy,omitempty"`
	XKubernetesGroupVersionKind []*GVK                   `json:"x-kubernetes-group-version-kind,omitempty"`
	XKubernetesUnions           []map[string]interface{} `json:"x-kubernetes-unions,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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