query

package
v1.12.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProviderName is provider name for install.
	ProviderName = "query"
	// HelmReleaseKind is the kind of HelmRelease
	HelmReleaseKind = "HelmRelease"
)
View Source
const (
	// DefaultMaxDepth is the default max depth for query iterator
	// check maxDepth function to get the customized val for max depth
	DefaultMaxDepth = 5
)

Variables

This section is empty.

Functions

func CheckResourceStatus

func CheckResourceStatus(obj unstructured.Unstructured) (*types.HealthStatus, error)

CheckResourceStatus return object status data

func GetProviders

func GetProviders() map[string]cuexruntime.ProviderFn

GetProviders returns the cue providers.

func GetTemplate

func GetTemplate() string

GetTemplate returns the cue template.

func ServiceEndpointsOf

func ServiceEndpointsOf(ctx context.Context, cli client.Client, resources []querytypes.AppliedResource) []querytypes.ServiceEndpoint

ServiceEndpointsOf derives the access endpoints of resources an Application manages, walking each resource's tree when it has one. It reads the Services, Ingresses, HTTPRoutes and SeldonDeployments it finds through cli, plus the nodes of a cluster for a NodePort address, the Gateways a route attaches to, and a SeldonDeployment's Ambassador Service.

Types

type AppCollector

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

AppCollector collect resource created by application

func NewAppCollector

func NewAppCollector(cli client.Client, opt Option) *AppCollector

NewAppCollector create a app collector

func (*AppCollector) CollectResourceFromApp

func (c *AppCollector) CollectResourceFromApp(ctx context.Context) ([]Resource, error)

CollectResourceFromApp collect resources created by application

func (*AppCollector) FindResourceFromAppliedResourcesField

func (c *AppCollector) FindResourceFromAppliedResourcesField(ctx context.Context, app *v1beta1.Application) ([]Resource, error)

FindResourceFromAppliedResourcesField find resources from AppliedResources field

func (*AppCollector) FindResourceFromResourceTrackerSpec

func (c *AppCollector) FindResourceFromResourceTrackerSpec(ctx context.Context, app *v1beta1.Application) ([]Resource, error)

FindResourceFromResourceTrackerSpec find resources from ResourceTracker spec

func (*AppCollector) ListApplicationResources

func (c *AppCollector) ListApplicationResources(ctx context.Context, app *v1beta1.Application) ([]types.AppliedResource, error)

ListApplicationResources list application applied resources from tracker

type ChildrenResourcesRule

type ChildrenResourcesRule struct {
	// GroupResourceType the root resource type
	GroupResourceType GroupResourceType
	// every subResourceType can have a specified genListOptionFunc.
	SubResources *SubResources
	// if specified genListOptionFunc is nil will use use default genListOptionFunc to generate listOption.
	DefaultGenListOptionFunc genListOptionFunc
	// DisableFilterByOwnerReference means don't use parent resource's UID filter the result.
	DisableFilterByOwnerReference bool
}

ChildrenResourcesRule define the relationShip between parentObject and children resource

type CustomSelector

type CustomSelector struct {
	ResourceType `json:",inline"`
	// defaultLabelSelector means read the label selector condition from the spec.selector.
	DefaultLabelSelector bool `json:"defaultLabelSelector"`
}

CustomSelector the custom resource selector configuration in configmap. support set the default label selector policy

type FilterOption

type FilterOption struct {
	Cluster          string   `json:"cluster,omitempty"`
	ClusterNamespace string   `json:"clusterNamespace,omitempty"`
	Components       []string `json:"components,omitempty"`
	APIVersion       string   `json:"apiVersion,omitempty"`
	Kind             string   `json:"kind,omitempty"`
	QueryNewest      bool     `json:"queryNewest,omitempty"`
}

FilterOption filter resource created by component

type GroupResourceType

type GroupResourceType struct {
	Group string `json:"group"`
	Kind  string `json:"kind"`
}

GroupResourceType define the parent resource type

type ListParams

type ListParams = oamprovidertypes.Params[ListVars]

ListParams is the params for list

type ListReturnVars

type ListReturnVars[T any] struct {
	List  []T    `json:"list"`
	Error string `json:"err,omitempty"`
}

ListReturnVars is the vars for list return

type ListReturns

type ListReturns[T any] oamprovidertypes.Returns[ListReturnVars[T]]

ListReturns is the returns for list

func CollectResources

func CollectResources(ctx context.Context, params *ListParams) (*ListReturns[querytypes.ResourceItem], error)

CollectResources collects resources from the cluster

func CollectServiceEndpoints

func CollectServiceEndpoints(ctx context.Context, params *ListParams) (*ListReturns[querytypes.ServiceEndpoint], error)

CollectServiceEndpoints generator service endpoints is available for common component type, such as webservice or helm it can not support the cloud service component currently

func ListAppliedResources

func ListAppliedResources(ctx context.Context, params *ListParams) (*ListReturns[querytypes.AppliedResource], error)

ListAppliedResources list applied resource from tracker, this provider only queries the metadata.

func ListResourcesInApp

func ListResourcesInApp(ctx context.Context, params *ListParams) (*ListReturns[Resource], error)

ListResourcesInApp lists CRs created by Application, this provider queries the object data.

func SearchEvents

func SearchEvents(ctx context.Context, params *SearchParams) (*ListReturns[corev1.Event], error)

SearchEvents searches events

type ListVars

type ListVars struct {
	App Option `json:"app"`
}

ListVars is the vars for list

type LogParams

type LogParams = oamprovidertypes.Params[LogVars]

LogParams is the params for log

type LogReturnVars

type LogReturnVars struct {
	Outputs map[string]interface{} `json:"outputs"`
}

LogReturnVars is the log return vars

type LogReturns

LogReturns is the log returns

func CollectLogsInPod

func CollectLogsInPod(ctx context.Context, params *LogParams) (*LogReturns, error)

CollectLogsInPod collects logs in pod

type LogVars

type LogVars struct {
	Cluster   string                `json:"cluster"`
	Namespace string                `json:"namespace"`
	Pod       string                `json:"pod"`
	Options   *corev1.PodLogOptions `json:"options,omitempty"`
}

LogVars is the vars for log

type Option

type Option struct {
	Name      string       `json:"name"`
	Namespace string       `json:"namespace"`
	Filter    FilterOption `json:"filter,omitempty"`
	// WithStatus means query the object from the cluster and get the latest status
	// This field only suitable for ListResourcesInApp
	WithStatus bool `json:"withStatus,omitempty"`

	// WithTree means recursively query the resource tree.
	WithTree bool `json:"withTree,omitempty"`
}

Option is the query option

type Resource

type Resource struct {
	Cluster   string                     `json:"cluster"`
	Component string                     `json:"component"`
	Revision  string                     `json:"revision"`
	Object    *unstructured.Unstructured `json:"object"`
}

Resource refer to an object with cluster info

type ResourceType

type ResourceType struct {
	APIVersion string `json:"apiVersion,omitempty"`
	Kind       string `json:"kind,omitempty"`
}

ResourceType define the children resource type

type RuleList

type RuleList []ChildrenResourcesRule

RuleList the rule list

func (*RuleList) GetRule

GetRule get the rule by the resource type

type SearchParams

type SearchParams = oamprovidertypes.Params[SearchVars]

SearchParams is the params for search

type SearchVars

type SearchVars struct {
	Value   *unstructured.Unstructured `json:"value"`
	Cluster string                     `json:"cluster"`
}

SearchVars is the vars for search

type SubResourceSelector

type SubResourceSelector struct {
	ResourceType
	// contains filtered or unexported fields
}

SubResourceSelector the sub resource selector configuration

type SubResources

type SubResources []*SubResourceSelector

SubResources the sub resource definitions

func (*SubResources) Get

Get get the sub resource by the resource type

func (*SubResources) Put

func (c *SubResources) Put(cr *SubResourceSelector)

Put add a sub resource to the list

type WorkloadUnstructured

type WorkloadUnstructured struct {
	unstructured.Unstructured
}

WorkloadUnstructured the workload unstructured, such as Deployment、Job、StatefulSet、ReplicaSet and DaemonSet

func (*WorkloadUnstructured) GetSelector

func (w *WorkloadUnstructured) GetSelector(fields ...string) (labels.Selector, error)

GetSelector get the selector from the field path

Jump to

Keyboard shortcuts

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