Files
capsule/internal/webhook/service/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

66 lines
1.6 KiB
Go

// Copyright 2020-2026 Project Capsule Authors
// SPDX-License-Identifier: Apache-2.0
package service
import (
"fmt"
"strings"
"github.com/projectcapsule/capsule/pkg/api"
)
type externalServiceIPForbiddenError struct {
cidr []string
}
func NewExternalServiceIPForbidden(allowedIps []api.AllowedIP) error {
cidr := make([]string, 0, len(allowedIps))
for _, i := range allowedIps {
cidr = append(cidr, string(i))
}
return &externalServiceIPForbiddenError{
cidr: cidr,
}
}
func (e externalServiceIPForbiddenError) Error() string {
if len(e.cidr) == 0 {
return "The current Tenant does not allow the use of Service with external IPs"
}
return fmt.Sprintf("The selected external IPs for the current Service are violating the following enforced CIDRs: %s", strings.Join(e.cidr, ", "))
}
type nodePortDisabledError struct{}
func NewNodePortDisabledError() error {
return &nodePortDisabledError{}
}
func (nodePortDisabledError) Error() string {
return "NodePort service types are forbidden for the tenant: please, reach out to the system administrators"
}
type externalNameDisabledError struct{}
func NewExternalNameDisabledError() error {
return &externalNameDisabledError{}
}
func (externalNameDisabledError) Error() string {
return "ExternalName service types are forbidden for the tenant: please, reach out to the system administrators"
}
type loadBalancerDisabledError struct{}
func NewLoadBalancerDisabled() error {
return &loadBalancerDisabledError{}
}
func (loadBalancerDisabledError) Error() string {
return "LoadBalancer service types are forbidden for the tenant: please, reach out to the system administrators"
}