ksonnet

package
v0.0.0-...-6ed7b81 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatKind

func FormatKind(s string) string

FormatKind formats a string in kind format. i.e camel case with jsonnet keywords massaged.

Types

type APIObject

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

APIObject is an API object.

func NewAPIObject

func NewAPIObject(resource Object) *APIObject

NewAPIObject creates an instance of APIObject.

func (*APIObject) Description

func (a *APIObject) Description() string

Description is the description of this API object.

func (*APIObject) Kind

func (a *APIObject) Kind() string

Kind is the kind of api object this is.

func (*APIObject) Node

func (a *APIObject) Node(catalog *Catalog) (*nm.Object, error)

Node returns an AST node for this api object.

type ArrayRenderer

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

ArrayRenderer renders arrays.

func NewArrayRenderer

func NewArrayRenderer(f Property, parent string) *ArrayRenderer

NewArrayRenderer creates an instance of ArrayRenderer.

func (*ArrayRenderer) Render

func (r *ArrayRenderer) Render(container *nm.Object) error

Render renders an item in its parent object.

type Catalog

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

Catalog is a catalog definitions

func NewCatalog

func NewCatalog(apiSpec *spec.Swagger, title string, opts ...CatalogOpt) (*Catalog, error)

NewCatalog creates an instance of Catalog.

func (*Catalog) Checksum

func (c *Catalog) Checksum() string

Checksum returns the checksum of the swagger schema.

func (*Catalog) Field

func (c *Catalog) Field(name string) (*Field, error)

Field returns a field by definition id. If the type cannot be found, it returns an error.

func (*Catalog) Fields

func (c *Catalog) Fields() ([]Field, error)

Fields returns a slice of all fields.

func (*Catalog) Resource

func (c *Catalog) Resource(group, version, kind string) (*Type, error)

Resource returns a resource by group, version, kind. If the field cannot be found, it returns an error

func (*Catalog) TypeByID

func (c *Catalog) TypeByID(id string) (*Type, error)

TypeByID returns a type by identifier.

func (*Catalog) Types

func (c *Catalog) Types() ([]Type, error)

Types returns a slice of all types.

func (*Catalog) TypesWithDescendant

func (c *Catalog) TypesWithDescendant(definition string) ([]Type, error)

TypesWithDescendant returns types who have the specified definition as a descendant. This list does not include List types (e.g. DeploymentList).

func (*Catalog) Version

func (c *Catalog) Version() string

Version returns the Kubernetes API version represented by this Catalog.

type CatalogOpt

type CatalogOpt func(*Catalog)

CatalogOpt is an option for configuring Catalog.

func CatalogOptChecksum

func CatalogOptChecksum(checksum string) CatalogOpt

CatalogOptChecksum is a Catalog option for setting the checksum of the swagger schema.

func CatalogOptExtractProperties

func CatalogOptExtractProperties(fn ExtractFn) CatalogOpt

CatalogOptExtractProperties is a Catalog option for setting the property extractor.

func CatalogOptMaintainer

func CatalogOptMaintainer(maintainer string) CatalogOpt

CatalogOptMaintainer is a Catalog option for setting the maintainer of the swagger schema.

func CatalogOptVersion

func CatalogOptVersion(version string) CatalogOpt

CatalogOptChecksum is a Catalog option for setting the Kubernetes target Version

type Component

type Component struct {
	Group   string
	Kind    string
	Version string
}

Component is resource information provided in the k8s swagger schema which contains the group, kind, and version for a definition.

func NewComponent

func NewComponent(s spec.Schema) (*Component, error)

NewComponent extracts component information from a schema.

func (*Component) String

func (c *Component) String() string

type Description

type Description struct {
	Name     string
	Version  string
	Kind     string
	Group    string
	Codebase string
}

Description is a description of a Kubernetes definition name.

func ParseDescription

func ParseDescription(name string) (*Description, error)

ParseDescription takes a definition name and returns a Description.

func (*Description) Validate

func (d *Description) Validate() error

Validate validates the Description. A description is valid if it has a version.

type Document

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

Document represents a ksonnet lib document.

func NewDocument

func NewDocument(catalog *Catalog) (*Document, error)

NewDocument creates an instance of Document.

func (*Document) Groups

func (d *Document) Groups() ([]Group, error)

Groups returns an alphabetically sorted list of groups.

func (*Document) HiddenGroups

func (d *Document) HiddenGroups() ([]Group, error)

HiddenGroups returns an alphabetically sorted list of hidden groups.

func (*Document) Nodes

func (d *Document) Nodes(meta Metadata) (map[string]nm.Noder, error)

Node converts a document to a node.

type Extension

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

Extension represents a ksonnet lib extension document.

func NewExtension

func NewExtension(catalog *Catalog) *Extension

NewExtension creates an an instance of Extension.

func (*Extension) Node

func (e *Extension) Node() (nm.Noder, error)

Node converts an extension to a node.

type ExtractFn

type ExtractFn func(*Catalog, map[string]spec.Schema, []string) (map[string]Property, error)

ExtractFn is a function which extracts properties from a schema.

type Field

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

Field is a Kubernetes field.

func NewField

func NewField(id, desc, codebase, group, ver, kind string, props map[string]Property) *Field

NewField creates an instance of Field.

func (*Field) Codebase

func (f *Field) Codebase() string

Codebase is the codebase for this field.

func (*Field) Description

func (f *Field) Description() string

Description is the description for this field.

func (*Field) Group

func (f *Field) Group() string

Group is the group for this field.

func (*Field) Identifier

func (f *Field) Identifier() string

Identifier is the identifier for this field.

func (*Field) IsType

func (f *Field) IsType() bool

IsType returns if this item is a type. It always returns false.

func (*Field) Kind

func (f *Field) Kind() string

Kind is the kind for this field.

func (*Field) Properties

func (f *Field) Properties() map[string]Property

Properties are the properties for this field.

func (*Field) QualifiedGroup

func (f *Field) QualifiedGroup() string

QualifiedGroup is the group for this field.

func (*Field) Version

func (f *Field) Version() string

Version is the version for this field.

type GenOpts

type GenOpts struct {
	Metadata

	// OpenAPI (swagger.json) spec of the API
	OpenAPI string

	// Optional regexp to only generate specific apiGroups
	Target *regexp.Regexp

	// Name of the generated library (e.g. Kubernetes, cert-manager, etc)
	Name string
	// Version of the targeted software (e.g. 1.17, 0.1, etc.)
	Version string
	// Maintainer of the generated library
	Maintainer string
}

type Group

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

Group is group of definitions.

func NewGroup

func NewGroup(name string) *Group

NewGroup creates an instance of Group.

func (*Group) AddResource

func (g *Group) AddResource(r Object)

AddResource adds a resource to a version.

func (*Group) Name

func (g *Group) Name() string

Name is the name of the group.

func (*Group) Node

func (g *Group) Node() *nm.Object

Node returns an ast node for this group.

func (*Group) Versions

func (g *Group) Versions() []Version

Versions returns the versions available for this group.

type ItemRenderer

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

ItemRenderer renders items.

func NewItemRenderer

func NewItemRenderer(f Property, parent string) *ItemRenderer

NewItemRenderer creates an instance of ItemRenderer.

func (*ItemRenderer) Render

func (r *ItemRenderer) Render(parent *nm.Object) error

Render renders an item in its parent object.

type Lib

type Lib struct {
	K8s        map[string][]byte
	Extensions []byte
	Version    string
}

Lib is a ksonnet lib.

func GenerateLib

func GenerateLib(opts GenOpts) (*Lib, error)

GenerateLib generates ksonnet lib.

type LiteralField

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

LiteralField is a literal field. (e.g. string, number, int, array)

func NewLiteralField

func NewLiteralField(name, fieldType, description, ref string) *LiteralField

NewLiteralField creates an instance of LiteralField.

func (*LiteralField) Description

func (f *LiteralField) Description() string

Description returns the description of the LiteralField.

func (*LiteralField) FieldType

func (f *LiteralField) FieldType() string

FieldType returns the field type of the LiteralField.

func (*LiteralField) Name

func (f *LiteralField) Name() string

Name returns the name of the LiteralField.

func (*LiteralField) Ref

func (f *LiteralField) Ref() string

Ref returns the ref of the LiteralField.

type LiteralFieldRenderer

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

LiteralFieldRenderer renders a literal field.

func NewLiteralFieldRenderer

func NewLiteralFieldRenderer(lf *LiteralField, parentName string) *LiteralFieldRenderer

NewLiteralFieldRenderer creates an instance of LiteralField.

func (*LiteralFieldRenderer) Render

func (r *LiteralFieldRenderer) Render(container *nm.Object) error

Render renders the literal field in the container.

type Metadata

type Metadata struct {
	// Vendor of this build
	Vendor string

	// Version of the generator
	Version string
}

Metadata holds meta information about the generator used for the build

type Object

type Object interface {
	Kind() string
	Description() string
	IsType() bool
	Properties() map[string]Property
	Version() string
	Group() string
	Codebase() string
	QualifiedGroup() string
	Identifier() string
}

Object is an object that can be turned into a node by APIObject.

type ObjectRenderer

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

ObjectRenderer renders an object field.

func NewObjectRenderer

func NewObjectRenderer(field Property, parent string) *ObjectRenderer

NewObjectRenderer creates an instance of ObjectRenderer

func (*ObjectRenderer) Render

func (r *ObjectRenderer) Render(container *nm.Object) error

Render renders the object field in the container.

type Property

type Property interface {
	Description() string
	Name() string
	Ref() string
}

Property is a field in a resource

type ReferenceField

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

ReferenceField is a reference field.

func NewReferenceField

func NewReferenceField(name, description, ref string) *ReferenceField

NewReferenceField creates an instance of ReferenceField.

func (*ReferenceField) Description

func (f *ReferenceField) Description() string

Description returns the description of the ReferenceField.

func (*ReferenceField) Name

func (f *ReferenceField) Name() string

Name returns the name of the ReferenceField.

func (*ReferenceField) Ref

func (f *ReferenceField) Ref() string

Ref returns the defintion this ReferenceField represents.

type ReferenceRenderer

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

ReferenceRenderer renders a reference field.

func NewReferenceRenderer

func NewReferenceRenderer(rf *ReferenceField, tl typeLookup, parent string) *ReferenceRenderer

NewReferenceRenderer creates an instance of ReferenceRenderer.

func (*ReferenceRenderer) Render

func (r *ReferenceRenderer) Render(container *nm.Object) error

Render renders the reference in the container.

type Type

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

Type is a Kubernetes kind.

func NewType

func NewType(identifier, description, codebase, group string, component Component, props map[string]Property) Type

NewType creates an instance of Type.

func (*Type) Codebase

func (t *Type) Codebase() string

Codebase is the codebase for this field.

func (*Type) Description

func (t *Type) Description() string

Description is description for this type

func (*Type) Group

func (t *Type) Group() string

Group is the group for this type

func (*Type) Identifier

func (t *Type) Identifier() string

Identifier is identifier for this type

func (*Type) IsType

func (t *Type) IsType() bool

IsType returns if this item is a type. It always returns true.

func (*Type) Kind

func (t *Type) Kind() string

Kind is the kind for this type

func (*Type) Properties

func (t *Type) Properties() map[string]Property

Properties are the properties for this type.

func (*Type) QualifiedGroup

func (t *Type) QualifiedGroup() string

QualifiedGroup is the group for this type

func (*Type) Version

func (t *Type) Version() string

Version is the version for this type

type UnknownDefinitionError

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

UnknownDefinitionError is an error signifying an unknown definition.

func NewUnknownDefinitionError

func NewUnknownDefinitionError(name string) *UnknownDefinitionError

NewUnknownDefinitionError creates an instance of UnknownDefinitionError.

func (*UnknownDefinitionError) Error

func (e *UnknownDefinitionError) Error() string

type Version

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

Version is an API version.

func NewVersion

func NewVersion(name, group string) *Version

NewVersion creates an instance of Version.

func (*Version) APIObjects

func (v *Version) APIObjects() []APIObject

APIObjects returns a slice of APIObjects sorted by name.

func (*Version) APIVersion

func (v *Version) APIVersion() string

APIVersion returns the version.

func (*Version) AddResource

func (v *Version) AddResource(resource Object)

AddResource adds a resource to the version.

func (*Version) Name

func (v *Version) Name() string

Name is the name of the version.

func (*Version) Node

func (v *Version) Node() *nm.Object

Node returns an ast node for this version.

Jump to

Keyboard shortcuts

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