mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-03-02 17:50:17 +00:00
* feat: forbidden node labels and annotations * test(e2e): forbidden node labels and annotations * build(kustomize): forbidden node labels and annotations * build(helm): forbidden node labels and annotations * build(installer): forbidden node labels and annotations * chore(make): forbidden node labels and annotations * docs: forbidden node labels and annotations * test(e2e): forbidden node labels and annotations. Use EventuallyCreation func * feat: forbidden node labels and annotations. Check kubernetes version * test(e2e): forbidden node labels and annotations. Check kubernetes version * docs: forbidden node labels and annotations. Version restrictions * feat: forbidden node labels and annotations. Do not update deepcopy functions * docs: forbidden node labels and annotations. Use blockquotes for notes Co-authored-by: Maksim Fedotov <m_fedotov@wargaming.net>
54 lines
1.4 KiB
Go
54 lines
1.4 KiB
Go
// Copyright 2020-2021 Clastix Labs
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package node
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
capsulev1beta1 "github.com/clastix/capsule/api/v1beta1"
|
|
)
|
|
|
|
func appendForbiddenError(spec *capsulev1beta1.ForbiddenListSpec) (append string) {
|
|
append += "Forbidden are "
|
|
if len(spec.Exact) > 0 {
|
|
append += fmt.Sprintf("one of the following (%s)", strings.Join(spec.Exact, ", "))
|
|
if len(spec.Regex) > 0 {
|
|
append += " or "
|
|
}
|
|
}
|
|
if len(spec.Regex) > 0 {
|
|
append += fmt.Sprintf("matching the regex %s", spec.Regex)
|
|
}
|
|
return
|
|
}
|
|
|
|
type nodeLabelForbiddenError struct {
|
|
spec *capsulev1beta1.ForbiddenListSpec
|
|
}
|
|
|
|
func NewNodeLabelForbiddenError(forbiddenSpec *capsulev1beta1.ForbiddenListSpec) error {
|
|
return &nodeLabelForbiddenError{
|
|
spec: forbiddenSpec,
|
|
}
|
|
}
|
|
|
|
func (f nodeLabelForbiddenError) Error() string {
|
|
return fmt.Sprintf("Unable to update node as some labels are marked as forbidden by system administrator. %s", appendForbiddenError(f.spec))
|
|
}
|
|
|
|
type nodeAnnotationForbiddenError struct {
|
|
spec *capsulev1beta1.ForbiddenListSpec
|
|
}
|
|
|
|
func NewNodeAnnotationForbiddenError(forbiddenSpec *capsulev1beta1.ForbiddenListSpec) error {
|
|
return &nodeAnnotationForbiddenError{
|
|
spec: forbiddenSpec,
|
|
}
|
|
}
|
|
|
|
func (f nodeAnnotationForbiddenError) Error() string {
|
|
return fmt.Sprintf("Unable to update node as some annotations are marked as forbidden by system administrator. %s", appendForbiddenError(f.spec))
|
|
}
|