mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
build: move e2e dependencies into e2e/go.mod
Several packages are only used while running the e2e suite. These packages are less important to update, as the they can not influence the final executable that is part of the Ceph-CSI container-image. By moving these dependencies out of the main Ceph-CSI go.mod, it is easier to identify if a reported CVE affects Ceph-CSI, or only the testing (like most of the Kubernetes CVEs). Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
committed by
mergify[bot]
parent
15da101b1b
commit
bec6090996
22
e2e/vendor/k8s.io/component-base/zpages/features/doc.go
generated
vendored
Normal file
22
e2e/vendor/k8s.io/component-base/zpages/features/doc.go
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
Copyright 2024 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Package features contains a separate feature set specifically designed for
|
||||
// managing zpages related features. These feature gates control the
|
||||
// availability and behavior of various zpages within Kubernetes components.
|
||||
// New zpages added to Kubernetes components should utilize this feature set
|
||||
// to ensure proper management of their availability.
|
||||
package features
|
52
e2e/vendor/k8s.io/component-base/zpages/features/kube_features.go
generated
vendored
Normal file
52
e2e/vendor/k8s.io/component-base/zpages/features/kube_features.go
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
Copyright 2024 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package features
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/util/version"
|
||||
"k8s.io/component-base/featuregate"
|
||||
)
|
||||
|
||||
const (
|
||||
// owner: @richabanker
|
||||
// kep: https://kep.k8s.io/4828
|
||||
ComponentFlagz featuregate.Feature = "ComponentFlagz"
|
||||
|
||||
// owner: @richabanker
|
||||
// kep: https://kep.k8s.io/4827
|
||||
// alpha: v1.32
|
||||
//
|
||||
// Enables /statusz endpoint for a component making it accessible to
|
||||
// users with the system:monitoring cluster role.
|
||||
ComponentStatusz featuregate.Feature = "ComponentStatusz"
|
||||
)
|
||||
|
||||
func featureGates() map[featuregate.Feature]featuregate.VersionedSpecs {
|
||||
return map[featuregate.Feature]featuregate.VersionedSpecs{
|
||||
ComponentFlagz: {
|
||||
{Version: version.MustParse("1.32"), Default: false, PreRelease: featuregate.Alpha},
|
||||
},
|
||||
ComponentStatusz: {
|
||||
{Version: version.MustParse("1.32"), Default: false, PreRelease: featuregate.Alpha},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// AddFeatureGates adds all feature gates used by this package.
|
||||
func AddFeatureGates(mutableFeatureGate featuregate.MutableVersionedFeatureGate) error {
|
||||
return mutableFeatureGate.AddVersioned(featureGates())
|
||||
}
|
52
e2e/vendor/k8s.io/component-base/zpages/flagz/flagreader.go
generated
vendored
Normal file
52
e2e/vendor/k8s.io/component-base/zpages/flagz/flagreader.go
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
Copyright 2024 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package flagz
|
||||
|
||||
import (
|
||||
"github.com/spf13/pflag"
|
||||
cliflag "k8s.io/component-base/cli/flag"
|
||||
)
|
||||
|
||||
type Reader interface {
|
||||
GetFlagz() map[string]string
|
||||
}
|
||||
|
||||
// NamedFlagSetsGetter implements Reader for cliflag.NamedFlagSets
|
||||
type NamedFlagSetsReader struct {
|
||||
FlagSets cliflag.NamedFlagSets
|
||||
}
|
||||
|
||||
func (n NamedFlagSetsReader) GetFlagz() map[string]string {
|
||||
return convertNamedFlagSetToFlags(&n.FlagSets)
|
||||
}
|
||||
|
||||
func convertNamedFlagSetToFlags(flagSets *cliflag.NamedFlagSets) map[string]string {
|
||||
flags := make(map[string]string)
|
||||
for _, fs := range flagSets.FlagSets {
|
||||
fs.VisitAll(func(flag *pflag.Flag) {
|
||||
if flag.Value != nil {
|
||||
value := flag.Value.String()
|
||||
if set, ok := flag.Annotations["classified"]; ok && len(set) > 0 {
|
||||
value = "CLASSIFIED"
|
||||
}
|
||||
flags[flag.Name] = value
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return flags
|
||||
}
|
126
e2e/vendor/k8s.io/component-base/zpages/flagz/flagz.go
generated
vendored
Normal file
126
e2e/vendor/k8s.io/component-base/zpages/flagz/flagz.go
generated
vendored
Normal file
@ -0,0 +1,126 @@
|
||||
/*
|
||||
Copyright 2024 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package flagz
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/munnerz/goautoneg"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
const (
|
||||
flagzHeaderFmt = `
|
||||
%s flags
|
||||
Warning: This endpoint is not meant to be machine parseable, has no formatting compatibility guarantees and is for debugging purposes only.
|
||||
|
||||
`
|
||||
)
|
||||
|
||||
var (
|
||||
flagzSeparators = []string{":", ": ", "=", " "}
|
||||
errUnsupportedMediaType = fmt.Errorf("media type not acceptable, must be: text/plain")
|
||||
)
|
||||
|
||||
type registry struct {
|
||||
response bytes.Buffer
|
||||
once sync.Once
|
||||
}
|
||||
|
||||
type mux interface {
|
||||
Handle(path string, handler http.Handler)
|
||||
}
|
||||
|
||||
func Install(m mux, componentName string, flagReader Reader) {
|
||||
var reg registry
|
||||
reg.installHandler(m, componentName, flagReader)
|
||||
}
|
||||
|
||||
func (reg *registry) installHandler(m mux, componentName string, flagReader Reader) {
|
||||
m.Handle("/flagz", reg.handleFlags(componentName, flagReader))
|
||||
}
|
||||
|
||||
func (reg *registry) handleFlags(componentName string, flagReader Reader) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if !acceptableMediaType(r) {
|
||||
http.Error(w, errUnsupportedMediaType.Error(), http.StatusNotAcceptable)
|
||||
return
|
||||
}
|
||||
|
||||
reg.once.Do(func() {
|
||||
fmt.Fprintf(®.response, flagzHeaderFmt, componentName)
|
||||
if flagReader == nil {
|
||||
klog.Error("received nil flagReader")
|
||||
return
|
||||
}
|
||||
|
||||
randomIndex := rand.Intn(len(flagzSeparators))
|
||||
separator := flagzSeparators[randomIndex]
|
||||
// Randomize the delimiter for printing to prevent scraping of the response.
|
||||
printSortedFlags(®.response, flagReader.GetFlagz(), separator)
|
||||
})
|
||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||
_, err := w.Write(reg.response.Bytes())
|
||||
if err != nil {
|
||||
klog.Errorf("error writing response: %v", err)
|
||||
http.Error(w, "error writing response", http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func acceptableMediaType(r *http.Request) bool {
|
||||
accepts := goautoneg.ParseAccept(r.Header.Get("Accept"))
|
||||
for _, accept := range accepts {
|
||||
if !mediaTypeMatches(accept) {
|
||||
continue
|
||||
}
|
||||
if len(accept.Params) == 0 {
|
||||
return true
|
||||
}
|
||||
if len(accept.Params) == 1 {
|
||||
if charset, ok := accept.Params["charset"]; ok && strings.EqualFold(charset, "utf-8") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func mediaTypeMatches(a goautoneg.Accept) bool {
|
||||
return (a.Type == "text" || a.Type == "*") &&
|
||||
(a.SubType == "plain" || a.SubType == "*")
|
||||
}
|
||||
|
||||
func printSortedFlags(w io.Writer, flags map[string]string, separator string) {
|
||||
var sortedKeys []string
|
||||
for key := range flags {
|
||||
sortedKeys = append(sortedKeys, key)
|
||||
}
|
||||
|
||||
sort.Strings(sortedKeys)
|
||||
for _, key := range sortedKeys {
|
||||
fmt.Fprintf(w, "%s%s%s\n", key, separator, flags[key])
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user