Documentation
¶
Overview ¶
SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and IronCore contributors SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- Variables
- func GetDeviceByEndpointIP(ctx context.Context, r client.Reader, ip string) (*v1alpha1.Device, error)
- func GetDeviceByName(ctx context.Context, r client.Reader, namespace, name string) (*v1alpha1.Device, error)
- func GetDeviceBySerial(ctx context.Context, r client.Reader, serial string) (*v1alpha1.Device, error)
- func GetDeviceFromMetadata(ctx context.Context, r client.Reader, obj metav1.Object) (*v1alpha1.Device, error)
- func GetOwnerDevice(ctx context.Context, r client.Reader, obj metav1.Object) (*v1alpha1.Device, error)
- type Connection
Constants ¶
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 ¶
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.
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.
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.