pkg

package
v0.0.0-...-9560c5d Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddListUniqueItems

func AddListUniqueItems(a []string, b []string) []string

Given two lists adds them, but only adds unique items Duplicates are removed, using map

func Conversion

func Conversion(KedgeSpecLocation, KubernetesSchema, OpenShiftSchema string) error

func CreateJSONRef

func CreateJSONRef(ref string) (jsonreference.Ref, error)

Creates a JSON reference type object from normal string

func CreateOpenAPIDefinition

func CreateOpenAPIDefinition(key, desc string, defs spec.Definitions)

Given kedgeSpecKey and description for a struct this adds the entry for that particular key to defs, if not present already

func CreateSchema

func CreateSchema(fieldtype, format, desc, ref string) (spec.Schema, error)

Schema the schema object allows the definition of input and output data types. This will be added to definitions we have

func GetStructFieldType

func GetStructFieldType(g interface{}) (string, string, error)

Returns string form of the struct field type if the type is not recognized then errors out

func InjectKedgeSpec

func InjectKedgeSpec(koDefinitions spec.Definitions, kedgeDefinitions spec.Definitions, mappings []Injection) spec.Definitions

func JSONTagName

func JSONTagName(j string) (string, error)

If given a JSON tag this will extract struct field name out of it. For e.g. if a json tag is like this `json:"persistentVolumes,omitempty"` This function will return 'persistentVolumes'

func LogJson

func LogJson(v interface{})

func MergeDefinitions

func MergeDefinitions(target, src *openapi.OpenAPIDefinition)

func ParseOpenAPIDefinition

func ParseOpenAPIDefinition(filename string) (*openapi.OpenAPIDefinition, error)

func ParseStructComments

func ParseStructComments(cg *ast.CommentGroup) (kedgeSpecKey, desc string)

Parses comments on top of structs and accordingly returns the description of struct and the kedgeSpec key if any provided

func ParseStructFieldComments

func ParseStructFieldComments(cg *ast.CommentGroup) (desc string, ref string, optional bool)

Parses comments on top of struct fields and accordingly returns the description of the field name if any provided, if the field is a reference defined using 'k8s:' or 'ref:' and also returns if the field is optional by looking for line that has '+optional' mentioned

func PrintJSONStdOut

func PrintJSONStdOut(v interface{})

func PrintJson

func PrintJson(v interface{})

func TypeSpecToStruct

func TypeSpecToStruct(t interface{}) (*ast.StructType, bool)

A TypeSpec node represents a type declaration (TypeSpec production). If given the object of that type returns StructType and boolean if the conversion went well

Types

type Injection

type Injection struct {
	Target string
	Source string
}

func GenerateOpenAPIDefinitions

func GenerateOpenAPIDefinitions(filename string) (spec.Definitions, []Injection, error)

given a golang filename this function will parse the file and generate open api definition

func ParseStruct

func ParseStruct(strct *ast.StructType, spc *ast.GenDecl, defs spec.Definitions, fset *token.FileSet) ([]Injection, error)

Parses a struct object and creates a definition which is added with the key as specified in the comments of struct definition, also adds the keys as mentioned identifies the type of the fields and converts them into as needed by openapi

Jump to

Keyboard shortcuts

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