Files
capsule/internal/webhook/dra/errors.go
renovate[bot] eb8d2b6076 chore(deps): update dependency golangci/golangci-lint to v2.8.0 (#1823)
* chore(deps): update dependency golangci/golangci-lint to v2.8.0

* chore(deps): update dependency golangci/golangci-lint to v2.8.0

Signed-off-by: Hristo Hristov <me@hhristov.info>

* chore(deps): update dependency golangci/golangci-lint to v2.8.0

Signed-off-by: Hristo Hristov <me@hhristov.info>

* chore(deps): update dependency golangci/golangci-lint to v2.8.0

Signed-off-by: Hristo Hristov <me@hhristov.info>

---------

Signed-off-by: Hristo Hristov <me@hhristov.info>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Hristo Hristov <me@hhristov.info>
2026-01-08 15:43:32 +02:00

44 lines
1.1 KiB
Go

// Copyright 2020-2026 Project Capsule Authors
// SPDX-License-Identifier: Apache-2.0
package dra
import (
"fmt"
"github.com/projectcapsule/capsule/internal/webhook/utils"
"github.com/projectcapsule/capsule/pkg/api"
)
type deviceClassForbiddenError struct {
deviceClassName string
spec api.SelectorAllowedListSpec
}
func (i deviceClassForbiddenError) Error() string {
err := fmt.Sprintf("Device Class %s is forbidden for the current Tenant: ", i.deviceClassName)
return utils.AllowedValuesErrorMessage(i.spec, err)
}
func NewDeviceClassForbidden(class string, spec api.SelectorAllowedListSpec) error {
return &deviceClassForbiddenError{
deviceClassName: class,
spec: spec,
}
}
type deviceClassUndefinedError struct {
spec api.SelectorAllowedListSpec
}
func NewDeviceClassUndefined(spec api.SelectorAllowedListSpec) error {
return &deviceClassUndefinedError{
spec: spec,
}
}
func (i deviceClassUndefinedError) Error() string {
return utils.AllowedValuesErrorMessage(i.spec, "Selected DeviceClass is forbidden for the current Tenant or does not exist. Specify a device Class which is allowed by ")
}