query

package
v1.10.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 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.

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.OAMParams[ListVars]

ListParams is the params for list

type ListResult

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

ListResult is the result for list

func CollectResources

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

CollectResources collects resources from the cluster

func CollectServiceEndpoints

func CollectServiceEndpoints(ctx context.Context, params *ListParams) (*ListResult[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) (*ListResult[querytypes.AppliedResource], error)

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

func ListResourcesInApp

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

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

func SearchEvents

func SearchEvents(ctx context.Context, params *SearchParams) (*ListResult[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.OAMParams[LogVars]

LogParams is the params for log

type LogResult

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

LogResult is the result for log

func CollectLogsInPod

func CollectLogsInPod(ctx context.Context, params *LogParams) (*LogResult, 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.OAMParams[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