mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-08-19 04:26:45 +00:00
34 lines
543 B
Go
34 lines
543 B
Go
// Copyright 2020-2026 Project Capsule Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package admission
|
|
|
|
import (
|
|
"path"
|
|
"strings"
|
|
|
|
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
|
|
)
|
|
|
|
func Deny(message string) *admission.Response {
|
|
response := admission.Denied(message)
|
|
|
|
return &response
|
|
}
|
|
|
|
func Allow(message string) *admission.Response {
|
|
response := admission.Allowed(message)
|
|
|
|
return &response
|
|
}
|
|
|
|
func normalizePath(p string) string {
|
|
if p == "" {
|
|
return ""
|
|
}
|
|
|
|
p = "/" + strings.TrimLeft(p, "/")
|
|
|
|
return path.Clean(p)
|
|
}
|