selector

package
v0.0.0-...-58d9a08 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HostIPKey = ".status.hostIP"
	PhaseKey  = ".status.phase"
)

Variables

This section is empty.

Functions

func GetTargetContainer

func GetTargetContainer(containerName string, status []corev1.ContainerStatus) (container *model.ContainerInfo, err error)

func GetTargetContainers

func GetTargetContainers(containerReg string, status []corev1.ContainerStatus) (containers []model.ContainerInfo, err error)

func SetupAnalyzer

func SetupAnalyzer(apiServer client.Client)

Types

type Analyzer

type Analyzer struct {
	ApiServer client.Client
}

func (*Analyzer) GetContainer

func (a *Analyzer) GetContainer(ctx context.Context, ns, podName, containerName string) (*model.ContainerObject, error)
func (a *Analyzer) GetNodeListByNodeIP(ctx context.Context, nodeIP []string, containerName string) ([]*model.NodeObject, error) {
	var nodeIPMap = make(map[string]bool)
	var result []*model.NodeObject
	for _, unit := range nodeIP {
		if !nodeIPMap[unit] {
			nodeIPMap[unit] = true
			tmpNode := &model.NodeObject{
				NodeInternalIP: unit,
			}
			if containerName != "" {
				r, id, err := model.ParseContainerID(containerName)
				if err != nil {
					return nil, fmt.Errorf("parse container info error: %s", err.Error())
				}

				tmpNode.ContainerRuntime, tmpNode.ContainerID = r, id
			}

			result = append(result, tmpNode)
		}
	}

	return result, nil
}

func (*Analyzer) GetDaemonSetByName

func (a *Analyzer) GetDaemonSetByName(ctx context.Context, namespace, name string) (*model.DaemonSetObject, error)

func (*Analyzer) GetDeploymentListByLabel

func (a *Analyzer) GetDeploymentListByLabel(ctx context.Context, namespace string, label map[string]string) ([]*model.DeploymentObject, error)

func (*Analyzer) GetDeploymentListByName

func (a *Analyzer) GetDeploymentListByName(ctx context.Context, namespace string, name []string) ([]*model.DeploymentObject, error)

func (*Analyzer) GetExperimentListByPhase

func (a *Analyzer) GetExperimentListByPhase(ctx context.Context, phase string) (*v1alpha1.ExperimentList, error)

func (*Analyzer) GetNodeListByLabel

func (a *Analyzer) GetNodeListByLabel(ctx context.Context, label map[string]string, containerName string) ([]*model.NodeObject, error)

GetNodeListByLabel return all node when label is empty map or nil

func (*Analyzer) GetNodeListByNodeIP

func (a *Analyzer) GetNodeListByNodeIP(ctx context.Context, nodeIP []string, containerName string) ([]*model.NodeObject, error)

GetNodeListByNodeIP In order to support non-k8s machines, so do not filter from apiServer

func (*Analyzer) GetNodeListByNodeName

func (a *Analyzer) GetNodeListByNodeName(ctx context.Context, nodeName []string, containerName string) ([]*model.NodeObject, error)

func (*Analyzer) GetPod

func (a *Analyzer) GetPod(ctx context.Context, ns, podName, containerName string) (*model.PodObject, error)

func (*Analyzer) GetPodListByLabel

func (a *Analyzer) GetPodListByLabel(ctx context.Context, namespace string, label map[string]string, containerReg string) ([]*model.PodObject, error)

func (*Analyzer) GetPodListByLabelInNode

func (a *Analyzer) GetPodListByLabelInNode(ctx context.Context, namespace string, label map[string]string, nodeIP string) ([]*model.PodObject, error)

func (*Analyzer) GetPodListByPodName

func (a *Analyzer) GetPodListByPodName(ctx context.Context, namespace string, podName []string, containerName string) ([]*model.PodObject, error)

type IAnalyzer

type IAnalyzer interface {
	GetExperimentListByPhase(ctx context.Context, phase string) (*v1alpha1.ExperimentList, error)
	GetContainer(ctx context.Context, ns, podName, containerName string) (*model.ContainerObject, error)

	GetPod(ctx context.Context, ns, podName, containerName string) (*model.PodObject, error)
	GetPodListByLabelInNode(ctx context.Context, namespace string, label map[string]string, nodeIP string) ([]*model.PodObject, error)
	GetPodListByLabel(ctx context.Context, namespace string, label map[string]string, containerName string) ([]*model.PodObject, error)
	GetPodListByPodName(ctx context.Context, namespace string, podName []string, containerName string) ([]*model.PodObject, error)

	GetNodeListByLabel(ctx context.Context, label map[string]string, containerName string) ([]*model.NodeObject, error)
	GetNodeListByNodeName(ctx context.Context, nodeName []string, containerName string) ([]*model.NodeObject, error)
	GetNodeListByNodeIP(ctx context.Context, nodeIP []string, containerName string) ([]*model.NodeObject, error)

	GetDeploymentListByLabel(ctx context.Context, namespace string, label map[string]string) ([]*model.DeploymentObject, error)
	GetDeploymentListByName(ctx context.Context, namespace string, name []string) ([]*model.DeploymentObject, error)

	GetDaemonSetByName(ctx context.Context, namespace string, name string) (*model.DaemonSetObject, error)
}

func GetAnalyzer

func GetAnalyzer() IAnalyzer

Jump to

Keyboard shortcuts

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