func validateDeviceID()

in internal/cmd/grow_container.go [148:168]


func validateDeviceID(id string, partitions *types.SystemPartitions) error {
	// Check if ID is provided
	if strings.TrimSpace(id) == "" {
		return errors.New("empty device id")
	}

	// Get the device identifier
	deviceID := identifier.ParseDiskID(id)
	if deviceID == "" {
		return errors.New("id does not match the expected device identifier format")
	}

	// Check the device directory for the given identifier
	for _, name := range partitions.AllDisks {
		if strings.EqualFold(name, deviceID) {
			return nil
		}
	}

	return errors.New("invalid device identifier")
}