generator

package
v0.0.0-...-baa1f0e Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//GraphQL standard data types
	Int     string = "Int"
	Float   string = "Float"
	String  string = "String"
	Boolean string = "Boolean"

	// Custom query
	CustomQuerySchema = `Id: ID
	ParentLabels: Map
`
)

Variables

This section is empty.

Functions

func ConstructType

func ConstructType(aliasNameMap map[string]string, field *ast.Field) string

TODO: https://jira.eng.vmware.com/browse/NPT-296 Support cross-package imports for the following additional types: 1. map[gns.MyStr][]gns.MyStr 2. map[string]map[string]gns.MyStr 3. []map[string]gns.MyStr 4. **gns.MyStr

func ConstructTypeParts

func ConstructTypeParts(aliasNameMap map[string]string, parts []string) []string

func CustomQueryToGraphqlSchema

func CustomQueryToGraphqlSchema(query nexus.GraphQLQuery) string

func GenerateImports

func GenerateImports(p *parser.Package, aliasNameMap map[string]string) []string

func GetNexusSchemaFieldName

func GetNexusSchemaFieldName(GraphQlSpec nexus.GraphQLSpec) string

func GetNodeDetails

func GetNodeDetails(pkgName, typeString string, importMap map[string]string, pkgs parser.Packages, gqlSpecMap map[string]nexus.GraphQLSpec) string

func GetPkg

func GetPkg(pkgs parser.Packages, pkgPath string) parser.Package

func RenderCRDTemplate

func RenderCRDTemplate(baseGroupName, crdModulePath string,
	pkgs parser.Packages, graph map[string]parser.Node,
	outputDir string, httpMethods map[string]nexus.HTTPMethodsResponses,
	httpCodes map[string]nexus.HTTPCodesResponse, nonNexusTypes *parser.NonNexusTypes,
	fileset *token.FileSet, graphqlFiles map[string]string) error

func RenderClient

func RenderClient(baseGroupName, outputDir, crdModulePath string, pkgs parser.Packages, parentsMap map[string]parser.NodeHelper) error

func RenderClientTemplate

func RenderClientTemplate(baseGroupName, crdModulePath string, pkgs parser.Packages, parentsMap map[string]parser.NodeHelper) (*bytes.Buffer, error)

func RenderDocTemplate

func RenderDocTemplate(baseGroupName string, pkg parser.Package) (*bytes.Buffer, error)

func RenderGQLGenTemplate

func RenderGQLGenTemplate(vars GraphDetails, crdModulePath string) (*bytes.Buffer, error)

func RenderGqlServerTemplate

func RenderGqlServerTemplate(vars ServerVars) (*bytes.Buffer, error)

func RenderGqlserver

func RenderGqlserver(outputDir, crdModulePath string) error

func RenderGraphQL

func RenderGraphQL(baseGroupName, outputDir, crdModulePath string, pkgs parser.Packages, parentsMap map[string]parser.NodeHelper, graphqlFiles map[string]string, nonNexusTypes *parser.NonNexusTypes) error

func RenderGraphqlResolverTemplate

func RenderGraphqlResolverTemplate(vars GraphDetails, crdModulePath string) (*bytes.Buffer, error)

func RenderGraphqlSchemaTemplate

func RenderGraphqlSchemaTemplate(vars GraphDetails, crdModulePath string) (*bytes.Buffer, error)

func RenderHelper

func RenderHelper(parentsMap map[string]parser.NodeHelper, outputDir string, crdModulePath string) error

func RenderHelperTemplate

func RenderHelperTemplate(parentsMap map[string]parser.NodeHelper, crdModulePath string) (*bytes.Buffer, error)

func RenderNonNexusTypes

func RenderNonNexusTypes(outputDir string, nonNexusTypes *parser.NonNexusTypes, fileset *token.FileSet) error

func RenderRegisterCRDTemplate

func RenderRegisterCRDTemplate(crdModulePath, baseGroupName string, pkg parser.Package) (*bytes.Buffer, error)

func RenderRegisterGroupTemplate

func RenderRegisterGroupTemplate(baseGroupName string, pkg parser.Package) (*bytes.Buffer, error)

func RenderTypesTemplate

func RenderTypesTemplate(crdModulePath string, pkg parser.Package) (*bytes.Buffer, error)

func SkipSecretSpecAnnotation

func SkipSecretSpecAnnotation(fieldName, nfType string, pkg parser.Package, importMap map[string]string, pkgs map[string]parser.Package) bool

SkipSecretSpecAnnotation checks if the field has nexus secrets annotated on them If yes, the field is skipped in the response.

func ValidateImportPkg

func ValidateImportPkg(pkgName, typeString string, importMap map[string]string, pkgs parser.Packages) (string, string)

Types

type ApiGroupsVars

type ApiGroupsVars struct {
	InitApiGroups             string
	ClientsetApiGroups        string
	ClientsetsApiGroupMethods string
	SimpleGroupTypeName       string
	GroupTypeName             string
	GroupResourcesInit        string
	GroupResources            string
	GroupResourcesDefs        string
}

type CommonVars

type CommonVars struct {
	Types string
}

type CrdBaseFile

type CrdBaseFile struct {
	Name string
	File *bytes.Buffer
}

func RenderCRDBaseTemplate

func RenderCRDBaseTemplate(baseGroupName string, pkg parser.Package, parentsMap map[string]parser.NodeHelper,
	httpMethods map[string]nexus.HTTPMethodsResponses, httpCodes map[string]nexus.HTTPCodesResponse) ([]CrdBaseFile, error)

type FieldProperty

type FieldProperty struct {
	IsResolver              bool
	IsNexusTypeField        bool
	IsNexusOrSingletonField bool
	IsChildOrLink           bool
	IsChildrenOrLinks       bool
	IsMapTypeField          bool
	IsArrayTypeField        bool
	IsStdTypeField          bool
	IsCustomTypeField       bool
	IsPointerTypeField      bool
	IsStringType            bool
	IsArrayStdType          bool
	IsSingleton             bool
	PkgName                 string
	NodeName                string
	FieldName               string
	FieldType               string
	FieldTypePkgPath        string
	ModelType               string
	SchemaFieldName         string
	SchemaTypeName          string
	BaseTypeName            string
	Alias                   string
	ReturnType              string
	FieldCount              int
	CRDName                 string
	ChainAPI                string
	LinkAPI                 string
}

type GraphDetails

type GraphDetails struct {
	BaseImportPath string
	Nodes          []NodeProperty
	GraphQlFiles   map[string]string
}

type GraphQLSchemaType

type GraphQLSchemaType int
const (
	Standard GraphQLSchemaType = iota
	Array
	JsonMarshal
	Child
	Link
	NamedChild
	NamedLink
	AliasType
)

type NexusAnnotation

type NexusAnnotation struct {
	Name            string                            `json:"name,omitempty"`
	Hierarchy       []string                          `json:"hierarchy,omitempty"`
	Children        map[string]parser.NodeHelperChild `json:"children,omitempty"`
	Links           map[string]parser.NodeHelperChild `json:"links,omitempty"`
	IsSingleton     bool                              `json:"is_singleton"`
	NexusRestAPIGen nexus.RestAPISpec                 `json:"nexus-rest-api-gen,omitempty"`
	Description     string                            `json:"description,omitempty"`
}

type NodeProperty

type NodeProperty struct {
	IsParentNode           bool
	HasParent              bool
	IsSingletonNode        bool
	IsNexusNode            bool
	BaseImportPath         string
	CrdName                string
	ResolverCount          int
	PkgName                string
	NodeName               string
	SchemaName             string
	Alias                  string
	ReturnType             string
	GroupResourceNameTitle string
	GroupName              string
	Singular               string
	Kind                   string
	ResourceName           string
	ResourceVersion        string
	Singleton              string
	ChildFields            []FieldProperty
	LinkFields             []FieldProperty
	ChildrenFields         []FieldProperty
	LinksFields            []FieldProperty
	ArrayFields            []FieldProperty
	CustomFields           []FieldProperty
	NonStructFields        []FieldProperty
	GraphqlSchemaFields    []FieldProperty
	ResolverFields         map[string][]FieldProperty
	CustomQueries          []nexus.GraphQLQuery
	GraphQlSpec            nexus.GraphQLSpec
}

func GenerateGraphqlResolverVars

func GenerateGraphqlResolverVars(baseGroupName, crdModulePath string, pkgs parser.Packages, parentsMap map[string]parser.NodeHelper) ([]NodeProperty, error)

GenerateGraphqlResolverVars populates the node and its field properties required to generate graphql resolver

func GenerateTsmGraphqlSchemaVars

func GenerateTsmGraphqlSchemaVars(baseGroupName, crdModulePath string, pkgs parser.Packages, parentsMap map[string]parser.NodeHelper, nonNexusTypes *parser.NonNexusTypes) ([]NodeProperty, error)

GenerateTsmGraphqlSchemaVars populates the node and its field properties required to generate graphql resolver

type ReturnStatement

type ReturnStatement struct {
	Alias       string
	ReturnType  string
	FieldCount  int
	CRDName     string
	ChainAPI    string
	IsSingleton bool
}

type ServerVars

type ServerVars struct {
	BaseImportPath string
}

Jump to

Keyboard shortcuts

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