Documentation ¶
Index ¶
- Variables
- func AddRelationship(resourceA, resourceB interface{}, relationshipType string)
- func AddRelationshipRule(rule RelationshipRule)
- func GetRelationships() map[string][]string
- func InitGVRCache(p provider.Provider) error
- func InitResourceSpecs(p provider.Provider) error
- func InitializeRelationships(resourceSpecs map[string][]string, provider provider.Provider)
- type Clause
- type ComparisonType
- type CreateClause
- type DefaultProp
- type DeleteClause
- type Direction
- type Edge
- type Expression
- type Graph
- type KeyValuePair
- type Lexer
- type MatchClause
- type MatchCriterion
- type Node
- type NodePattern
- type NodeRelationshipList
- type Parser
- type Properties
- type Property
- type QueryExecutor
- func (q *QueryExecutor) Execute(ast *Expression, namespace string) (QueryResult, error)
- func (q *QueryExecutor) ExecuteSingleQuery(ast *Expression, namespace string) (QueryResult, error)
- func (q *QueryExecutor) GetOpenAPIResourceSpecs() (map[string][]string, error)
- func (q *QueryExecutor) PatchK8sResource(resource map[string]interface{}, patchJSON []byte) error
- func (q *QueryExecutor) Provider() provider.Provider
- type QueryResult
- type Relationship
- type RelationshipRule
- type RelationshipType
- type ResourceProperties
- type ResourceRelationship
- type ReturnClause
- type ReturnItem
- type SetClause
- type Token
- type TokenType
Constants ¶
This section is empty.
Variables ¶
var ( Namespace string LogLevel string OutputFormat string AllNamespaces bool CleanOutput bool NoColor bool )
var ( GvrCache map[string]schema.GroupVersionResource ResourceSpecs map[string][]string )
Add these variables at the top with the other vars
Functions ¶
func AddRelationship ¶
func AddRelationship(resourceA, resourceB interface{}, relationshipType string)
func AddRelationshipRule ¶
func AddRelationshipRule(rule RelationshipRule)
func GetRelationships ¶
func InitResourceSpecs ¶
Types ¶
type Clause ¶
type Clause interface {
// contains filtered or unexported methods
}
Clause is an interface implemented by all clause types
type ComparisonType ¶
type ComparisonType string
const ( ExactMatch ComparisonType = "ExactMatch" ContainsAll ComparisonType = "ContainsAll" StringContains ComparisonType = "StringContains" )
type CreateClause ¶
type CreateClause struct { Nodes []*NodePattern Relationships []*Relationship }
CreateClause represents a CREATE clause
type DefaultProp ¶
type DeleteClause ¶
type DeleteClause struct {
NodeIds []string
}
DeleteClause represents a DELETE clause
type Expression ¶
Expression represents a complete Cyphernetes query
func ParseQuery ¶
func ParseQuery(query string) (*Expression, error)
ParseQuery is the main entry point for parsing Cyphernetes queries
type KeyValuePair ¶
KeyValuePair represents a key-value pair with an operator
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
func (*Lexer) SetParsingContexts ¶
Add method to set context parsing state
func (*Lexer) SetParsingJsonData ¶ added in v0.15.2
Add method to set JSON data parsing state
type MatchClause ¶
type MatchClause struct { Nodes []*NodePattern Relationships []*Relationship ExtraFilters []*KeyValuePair }
MatchClause represents a MATCH clause
type MatchCriterion ¶
type MatchCriterion struct { FieldA string `yaml:"fieldA"` FieldB string `yaml:"fieldB"` ComparisonType ComparisonType `yaml:"comparisonType"` DefaultProps []DefaultProp `yaml:"defaultProps,omitempty"` }
type NodePattern ¶
type NodePattern struct {
ResourceProperties *ResourceProperties
}
NodePattern represents a node pattern in a query
type NodeRelationshipList ¶
type NodeRelationshipList struct { Nodes []*NodePattern Relationships []*Relationship }
NodeRelationshipList represents a list of nodes and relationships
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func NewRecursiveParser ¶
func (*Parser) Parse ¶
func (p *Parser) Parse() (*Expression, error)
Parse is the entry point for parsing a Cyphernetes query
type Properties ¶
type Properties struct {
PropertyList []*Property
}
Properties represents a collection of properties
type Property ¶
type Property struct { Key string Value interface{} }
Property represents a key-value property
type QueryExecutor ¶
type QueryExecutor struct {
// contains filtered or unexported fields
}
func GetContextQueryExecutor ¶
func GetContextQueryExecutor(context string) (*QueryExecutor, error)
func GetQueryExecutorInstance ¶
func GetQueryExecutorInstance(p provider.Provider) *QueryExecutor
func NewQueryExecutor ¶
func NewQueryExecutor(p provider.Provider) (*QueryExecutor, error)
func (*QueryExecutor) Execute ¶
func (q *QueryExecutor) Execute(ast *Expression, namespace string) (QueryResult, error)
func (*QueryExecutor) ExecuteSingleQuery ¶
func (q *QueryExecutor) ExecuteSingleQuery(ast *Expression, namespace string) (QueryResult, error)
func (*QueryExecutor) GetOpenAPIResourceSpecs ¶
func (q *QueryExecutor) GetOpenAPIResourceSpecs() (map[string][]string, error)
func (*QueryExecutor) PatchK8sResource ¶
func (q *QueryExecutor) PatchK8sResource(resource map[string]interface{}, patchJSON []byte) error
func (*QueryExecutor) Provider ¶
func (q *QueryExecutor) Provider() provider.Provider
type QueryResult ¶
func ExecuteMultiContextQuery ¶
func ExecuteMultiContextQuery(ast *Expression, namespace string) (QueryResult, error)
type Relationship ¶
type Relationship struct { ResourceProperties *ResourceProperties Direction Direction LeftNode *NodePattern RightNode *NodePattern }
Relationship represents a relationship between nodes
type RelationshipRule ¶
type RelationshipRule struct { KindA string `yaml:"kindA"` KindB string `yaml:"kindB"` Relationship RelationshipType `yaml:"relationship"` MatchCriteria []MatchCriterion `yaml:"matchCriteria"` }
func GetRelationshipRules ¶
func GetRelationshipRules() []RelationshipRule
type RelationshipType ¶
type RelationshipType string
const ( DeploymentOwnReplicaset RelationshipType = "DEPLOYMENT_OWN_REPLICASET" ReplicasetOwnPod RelationshipType = "REPLICASET_OWN_POD" StatefulsetOwnPod RelationshipType = "STATEFULSET_OWN_POD" DaemonsetOwnPod RelationshipType = "DAEMONSET_OWN_POD" JobOwnPod RelationshipType = "JOB_OWN_POD" ServiceExposePod RelationshipType = "SERVICE_EXPOSE_POD" ServiceExposeDeployment RelationshipType = "SERVICE_EXPOSE_DEPLOYMENT" ServiceExposeStatefulset RelationshipType = "SERVICE_EXPOSE_STATEFULSET" ServiceExposeDaemonset RelationshipType = "SERVICE_EXPOSE_DAEMONSET" ServiceExposeReplicaset RelationshipType = "SERVICE_EXPOSE_REPLICASET" CronJobOwnPod RelationshipType = "CRONJOB_OWN_POD" CronJobOwnJob RelationshipType = "CRONJOB_OWN_JOB" ServiceHasEndpoints RelationshipType = "SERVICE_HAS_ENDPOINTS" NetworkPolicyApplyPod RelationshipType = "NETWORKPOLICY_APPLY_POD" HPAScaleDeployment RelationshipType = "HPA_SCALE_DEPLOYMENT" RoleBindingReferenceRole RelationshipType = "ROLEBINDING_REFERENCE_ROLE" MutatingWebhookTargetService RelationshipType = "MUTATINGWEBHOOK_TARGET_SERVICE" ValidatingWebhookTargetService RelationshipType = "VALIDATINGWEBHOOK_TARGET_SERVICE" PDBProtectPod RelationshipType = "PDB_PROTECT_POD" // ingresses to services Route RelationshipType = "ROUTE" // special relationships NamespaceHasResource RelationshipType = "NAMESPACE_HAS_RESOURCE" )
type ResourceProperties ¶
type ResourceProperties struct { Name string Kind string Properties *Properties JsonData string }
ResourceProperties represents the properties of a resource
type ResourceRelationship ¶
type ResourceRelationship struct { FromKind string ToKind string Type RelationshipType }
type ReturnClause ¶
type ReturnClause struct {
Items []*ReturnItem
}
ReturnClause represents a RETURN clause
type ReturnItem ¶
ReturnItem represents an item in a RETURN clause
type SetClause ¶
type SetClause struct {
KeyValuePairs []*KeyValuePair
}
SetClause represents a SET clause
type TokenType ¶
type TokenType int
TokenType represents the type of a lexical token
const ( ILLEGAL TokenType = iota EOF NULL // Keywords MATCH CREATE WHERE SET DELETE RETURN IN AS // Identifiers and literals IDENT STRING INT NUMBER BOOLEAN JSONPATH JSONDATA // Delimiters LPAREN // ( RPAREN // ) LBRACE // { RBRACE // } LBRACKET // [ RBRACKET // ] COLON // : COMMA // , DOT // . // Operators EQUALS NOT_EQUALS GREATER_THAN LESS_THAN GREATER_THAN_EQUALS LESS_THAN_EQUALS CONTAINS REGEX_COMPARE // Relationship tokens REL_NOPROPS_RIGHT REL_NOPROPS_LEFT REL_NOPROPS_BOTH REL_NOPROPS_NONE REL_BEGINPROPS_LEFT REL_BEGINPROPS_NONE REL_ENDPROPS_RIGHT REL_ENDPROPS_NONE // Aggregation functions COUNT SUM )