deviceutil

package
v0.0.0-...-c351c78 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and IronCore contributors SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const DeviceEndpointIPField = "device.endpoint.ip"

DeviceEndpointIPField is the cache field index key used to look up Device objects by the IP part of spec.endpoint.address. Callers must register this index on the controller-runtime field indexer before calling GetDeviceByEndpointIP.

Variables

View Source
var ErrNoDevice = fmt.Errorf("no %q label present", v1alpha1.DeviceLabel)

ErrNoDevice is returned when the device label could not be found on the object passed in.

View Source
var ErrNoOwnerDevice = errors.New("no Device owner reference found")

ErrNoOwnerDevice is returned when no Device owner reference is found on the object.

Functions

func GetDeviceByEndpointIP

func GetDeviceByEndpointIP(ctx context.Context, r client.Reader, ip string) (*v1alpha1.Device, error)

GetDeviceByEndpointIP finds and returns a Device object by matching the IP portion of its spec.endpoint.address against ip. It returns an error if no device is found. The caller must have registered the DeviceEndpointIPField index before using this function.

func GetDeviceByName

func GetDeviceByName(ctx context.Context, r client.Reader, namespace, name string) (*v1alpha1.Device, error)

GetDeviceByName finds and returns a Device object using the specified selector.

func GetDeviceBySerial

func GetDeviceBySerial(ctx context.Context, r client.Reader, serial string) (*v1alpha1.Device, error)

GetDeviceBySerial finds and returns a Device object using the specified serial number. It returns an error if no device or multiple devices with the same serial number are found. Note: This function assumes that the v1alpha1.DeviceSerialLabel is unique across all Device objects in the cluster.

func GetDeviceFromMetadata

func GetDeviceFromMetadata(ctx context.Context, r client.Reader, obj metav1.Object) (*v1alpha1.Device, error)

GetDeviceFromMetadata resolves the Device for obj by first checking owner references, then falling back to the v1alpha1.DeviceLabel label. Returns an error if the device could not be determined.

func GetOwnerDevice

func GetOwnerDevice(ctx context.Context, r client.Reader, obj metav1.Object) (*v1alpha1.Device, error)

GetOwnerDevice returns the Device object owning the current resource. Returns ErrNoOwnerDevice when no matching owner reference is found.

Types

type Connection

type Connection struct {
	// Address is the API address of the device, in the format "host:port".
	Address string
	// Username for basic authentication. Might be empty if the device does not require authentication.
	Username string
	// Password for basic authentication. Might be empty if the device does not require authentication.
	Password string // #nosec G117
	// TLS configuration for the connection.
	TLS *tls.Config
}

Connection holds the necessary information to connect to a device's API.

func GetDeviceConnection

func GetDeviceConnection(ctx context.Context, r client.Reader, obj *v1alpha1.Device) (*Connection, error)

GetDeviceConnection retrieves the connection details for accessing the Device.

Jump to

Keyboard shortcuts

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