namespaceapi

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NamespaceAPI

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

NamespaceAPI provides high-level methods for retrieving and manipulating Kubernetes namespaces.

func NewNamespaceAPI

func NewNamespaceAPI(client kubernetes.Interface) *NamespaceAPI

NewNamespaceAPI creates a new NamespaceAPI instance with the provided Kubernetes client.

The client parameter should be a valid implementation of kubernetes.Interface.

Returns an initialized *NamespaceAPI.

func (*NamespaceAPI) GetNamespaceByName

func (n *NamespaceAPI) GetNamespaceByName(ctx context.Context, name string) (*corev1.Namespace, error)

GetNamespaceByName retrieves a single Namespace object by its name.

The name parameter is validated to ensure it is not empty. If the validation fails or if the retrieval from the Kubernetes API fails, an error is returned.

  • ctx: The context to use for cancellation.
  • name: The name of the Kubernetes namespace to retrieve.

Returns a pointer to a corev1.Namespace object or an error if the namespace is not found or if any other retrieval error occurs.

func (*NamespaceAPI) ListNamespacesByField

func (n *NamespaceAPI) ListNamespacesByField(ctx context.Context, fieldSelector string) ([]corev1.Namespace, error)

ListNamespacesByField retrieves a list of Namespace objects filtered by a field selector.

The fieldSelector parameter is validated to ensure it uses a valid Kubernetes field selector syntax. An error is returned if the validation or the Kubernetes API call fails.

  • ctx: The context to use for cancellation.
  • fieldSelector: The Kubernetes-compliant field selector string.

Returns a slice of corev1.Namespace objects matching the field selector, or an error if the operation fails.

func (*NamespaceAPI) ListNamespacesByLabel

func (n *NamespaceAPI) ListNamespacesByLabel(ctx context.Context, labelSelector string) ([]corev1.Namespace, error)

ListNamespacesByLabel retrieves a list of Namespace objects filtered by a label selector.

The labelSelector parameter is validated to ensure it uses a valid Kubernetes label selector syntax. If the validation fails or if the Kubernetes API call fails, an error is returned.

  • ctx: The context to use for cancellation.
  • labelSelector: The Kubernetes-compliant label selector string.

Returns a slice of corev1.Namespace objects matching the label selector, or an error if the operation fails.

Jump to

Keyboard shortcuts

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