pkg

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

README

Files in this folder

Some of the files in this folder are taken from the following repository verbatim: Kubernetes Extensions api server repository

The following files are copied over:

  • types_jsonschema.go
  • marshal.go
  • marshal_test.go

This is to ensure that we marshal the JSON schema types correctly.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootRequiredFields = []string{"apiVersion", "kind", "spec", "metadata", "status"}

Functions

func Generate

func Generate(crd *SchemaType, w io.WriteCloser, enableComments, minimal, skipRandom bool) (err error)

Generate takes a CRD content and path, and outputs.

func LoadTemplates added in v0.4.0

func LoadTemplates() error

LoadTemplates creates a map of loaded templates that are primed and ready to be rendered.

func RenderContent added in v0.4.0

func RenderContent(w io.WriteCloser, crds []*SchemaType, opts RenderOpts) (err error)

RenderContent creates an HTML website from the CRD content.

Types

type CRDVersion added in v1.0.0

type CRDVersion struct {
	Name   string
	Schema *v1beta1.JSONSchemaProps
}

CRDVersion corresponds to a CRD version.

type Group added in v1.0.3

type Group struct {
	Name string
	Page []ViewPage
}

Group defines a single group with a list of rendered versions.

type GroupPage added in v1.0.3

type GroupPage struct {
	Groups []Group
}

GroupPage will have a list of groups and inside these groups will be a list of page views.

type Index added in v0.10.0

type Index struct {
	Page []ViewPage
}

type Parser added in v0.5.0

type Parser struct {
	// contains filtered or unexported fields
}

func NewParser added in v0.5.0

func NewParser(group, kind string, comments, requiredOnly, skipRandom bool) *Parser

NewParser creates a new parser contains most of the things that do not change over each call.

func (*Parser) ParseProperties added in v0.5.0

func (p *Parser) ParseProperties(version string, file io.Writer, properties map[string]v1beta1.JSONSchemaProps, requiredFields []string) error

ParseProperties takes a writer and puts out any information / properties it encounters during the runs. It will recursively parse every "properties:" and "additionalProperties:". Using the types, it will also output some sample data based on those types.

type Property

type Property struct {
	Name        string
	Description string
	Type        string
	Nullable    bool
	Patterns    string
	Format      string
	Indent      int
	Version     string
	Default     string
	Required    bool
	Properties  []*Property
	Enums       string
}

Property builds up a Tree structure of embedded things.

type RenderOpts added in v1.0.3

type RenderOpts struct {
	Comments bool
	Minimal  bool
	Random   bool
}

type Rendering added in v1.0.3

type Rendering struct {
	// Group defines which group this schema should belong to. If empty
	// the schema's version will be used as grouping information.
	Group string
}

Rendering provides extra rendering information of this schema.

type SchemaType added in v1.0.0

type SchemaType struct {
	Schema     *v1beta1.JSONSchemaProps
	Versions   []*CRDVersion
	Validation *Validation
	Group      string
	Kind       string

	Rendering Rendering
}

SchemaType is a wrapper around any kind of object that provide the following: - kind - group - name - openAPIV3Schema.

func ExtractSchemaType added in v1.0.0

func ExtractSchemaType(obj *unstructured.Unstructured) (*SchemaType, error)

ExtractSchemaType makes sure the following required fields are present in the unstructured data and creates are own internal representation: - spec - spec.names.kind - spec.group either: - versions

  • version.Schema.OpenAPIV3Schema

- validation // if versions is missing

  • validation.OpenAPIV3Schema

type Validation added in v1.0.0

type Validation struct {
	Name   string
	Schema *v1beta1.JSONSchemaProps
}

Validation is a set of validation rules that should be applied to all versions.

type Version

type Version struct {
	Version     string
	Kind        string
	Group       string
	Properties  []*Property
	Description string
	YAML        string
}

Version wraps a top level version resource which contains the underlying openAPIV3Schema.

type ViewPage

type ViewPage struct {
	Title    string
	Versions []Version
}

ViewPage is the template for view.html.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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