resources

package
v1.3.13 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const MutationCheckpointInterval = 60 * time.Second

MutationCheckpointInterval is the interval for logging mutation checkpoint messages.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory struct {
	Logger            *zap.Logger
	K8sClient         k8sclient.Client
	Stats             *stream.Stats
	FlowCollectorType pb.FlowCollector
	ClusterName       string // Optional: cluster name for self-managed clusters
}

Factory creates resources stream clients.

func (*Factory) Name

func (f *Factory) Name() string

Name returns the stream name for logging.

func (*Factory) NewStreamClient

func (f *Factory) NewStreamClient(ctx context.Context, grpcConn grpc.ClientConnInterface) (stream.StreamClient, error)

NewStreamClient creates a new resources stream client.

type KubernetesResourcesStream

type KubernetesResourcesStream interface {
	Send(req *pb.SendKubernetesResourcesRequest) error
	Recv() (*pb.SendKubernetesResourcesResponse, error)
}

KubernetesResourcesStream abstracts the SendKubernetesResources gRPC stream.

type ResourceStreamSender

type ResourceStreamSender interface {
	SendObjectData(logger *zap.Logger, metadata *pb.KubernetesObjectData) error
	CreateMutationObject(metadata *pb.KubernetesObjectData, eventType watch.EventType) *pb.KubernetesResourceMutation
}

ResourceStreamSender abstracts the operations for sending resources to CloudSecure. Implemented by resourcesClient.

type Watcher

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

Watcher encapsulates components for listing and managing Kubernetes resources.

func NewWatcher

func NewWatcher(config WatcherConfig) *Watcher

NewWatcher creates a new Watcher for a specific resource type.

func (*Watcher) DynamicListResources

func (r *Watcher) DynamicListResources(ctx context.Context, logger *zap.Logger, apiGroup string) (string, error)

DynamicListResources lists a specified resource dynamically and sends down the current gRPC stream.

func (*Watcher) ExtractObjectMetas

func (r *Watcher) ExtractObjectMetas(resources *unstructured.UnstructuredList) ([]metav1.ObjectMeta, error)

func (*Watcher) FetchResources

func (r *Watcher) FetchResources(ctx context.Context, resource schema.GroupVersionResource, namespace string) (*unstructured.UnstructuredList, error)

func (*Watcher) ListResources

func (r *Watcher) ListResources(ctx context.Context, resource schema.GroupVersionResource, namespace string) ([]metav1.ObjectMeta, string, string, error)

func (*Watcher) WatchK8sResources

func (r *Watcher) WatchK8sResources(ctx context.Context, cancel context.CancelFunc, resourceVersion string, mutationChan chan *pb.KubernetesResourceMutation)

WatchK8sResources initiates a watch stream for the specified Kubernetes resource.

type WatcherConfig

type WatcherConfig struct {
	ResourceName    string
	ApiGroup        string
	Clientset       kubernetes.Interface
	BaseLogger      *zap.Logger
	DynamicClient   dynamic.Interface
	ResourcesClient ResourceStreamSender
	Limiter         *rate.Limiter
}

WatcherConfig holds the configuration for creating a new Watcher.

Jump to

Keyboard shortcuts

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