Documentation
¶
Index ¶
- func AddListUniqueItems(a []string, b []string) []string
- func Conversion(KedgeSpecLocation, KubernetesSchema, OpenShiftSchema string) error
- func CreateJSONRef(ref string) (jsonreference.Ref, error)
- func CreateOpenAPIDefinition(key, desc string, defs spec.Definitions)
- func CreateSchema(fieldtype, format, desc, ref string) (spec.Schema, error)
- func GetStructFieldType(g interface{}) (string, string, error)
- func InjectKedgeSpec(koDefinitions spec.Definitions, kedgeDefinitions spec.Definitions, ...) spec.Definitions
- func JSONTagName(j string) (string, error)
- func LogJson(v interface{})
- func MergeDefinitions(target, src *openapi.OpenAPIDefinition)
- func ParseOpenAPIDefinition(filename string) (*openapi.OpenAPIDefinition, error)
- func ParseStructComments(cg *ast.CommentGroup) (kedgeSpecKey, desc string)
- func ParseStructFieldComments(cg *ast.CommentGroup) (desc string, ref string, optional bool)
- func PrintJSONStdOut(v interface{})
- func PrintJson(v interface{})
- func TypeSpecToStruct(t interface{}) (*ast.StructType, bool)
- type Injection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddListUniqueItems ¶
Given two lists adds them, but only adds unique items Duplicates are removed, using map
func Conversion ¶
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 ¶
Schema the schema object allows the definition of input and output data types. This will be added to definitions we have
func GetStructFieldType ¶
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 ¶
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 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 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 ¶
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