mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 18:53: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
177
e2e/vendor/github.com/ceph/ceph-csi/LICENSE
generated
vendored
Normal file
177
e2e/vendor/github.com/ceph/ceph-csi/LICENSE
generated
vendored
Normal file
@ -0,0 +1,177 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
63
e2e/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/csi-config-map.go
generated
vendored
Normal file
63
e2e/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/csi-config-map.go
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
Copyright 2023 The Ceph-CSI 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 kubernetes
|
||||
|
||||
type ClusterInfo struct {
|
||||
// ClusterID is used for unique identification
|
||||
ClusterID string `json:"clusterID"`
|
||||
// Monitors is monitor list for corresponding cluster ID
|
||||
Monitors []string `json:"monitors"`
|
||||
// CephFS contains CephFS specific options
|
||||
CephFS CephFS `json:"cephFS"`
|
||||
// RBD Contains RBD specific options
|
||||
RBD RBD `json:"rbd"`
|
||||
// NFS contains NFS specific options
|
||||
NFS NFS `json:"nfs"`
|
||||
// Read affinity map options
|
||||
ReadAffinity ReadAffinity `json:"readAffinity"`
|
||||
}
|
||||
|
||||
type CephFS struct {
|
||||
// symlink filepath for the network namespace where we need to execute commands.
|
||||
NetNamespaceFilePath string `json:"netNamespaceFilePath"`
|
||||
// SubvolumeGroup contains the name of the SubvolumeGroup for CSI volumes
|
||||
SubvolumeGroup string `json:"subvolumeGroup"`
|
||||
// RadosNamespace is a rados namespace in the filesystem metadata pool
|
||||
RadosNamespace string `json:"radosNamespace"`
|
||||
// KernelMountOptions contains the kernel mount options for CephFS volumes
|
||||
KernelMountOptions string `json:"kernelMountOptions"`
|
||||
// FuseMountOptions contains the fuse mount options for CephFS volumes
|
||||
FuseMountOptions string `json:"fuseMountOptions"`
|
||||
}
|
||||
type RBD struct {
|
||||
// symlink filepath for the network namespace where we need to execute commands.
|
||||
NetNamespaceFilePath string `json:"netNamespaceFilePath"`
|
||||
// RadosNamespace is a rados namespace in the pool
|
||||
RadosNamespace string `json:"radosNamespace"`
|
||||
// RBD mirror daemons running in the ceph cluster.
|
||||
MirrorDaemonCount int `json:"mirrorDaemonCount"`
|
||||
}
|
||||
|
||||
type NFS struct {
|
||||
// symlink filepath for the network namespace where we need to execute commands.
|
||||
NetNamespaceFilePath string `json:"netNamespaceFilePath"`
|
||||
}
|
||||
|
||||
type ReadAffinity struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
CrushLocationLabels []string `json:"crushLocationLabels"`
|
||||
}
|
20
e2e/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/doc.go
generated
vendored
Normal file
20
e2e/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/doc.go
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
Copyright 2021 The Ceph-CSI 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 kubernetes contains functions to obtain standard and recommended
|
||||
// deployment artifacts for Kubernetes. These artifacts can be used by
|
||||
// automation tools that want to deploy Ceph-CSI.
|
||||
package kubernetes
|
39
e2e/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/provisioner.go
generated
vendored
Normal file
39
e2e/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/provisioner.go
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
Copyright 2024 The Ceph-CSI 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 kubernetes
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
rbacv1 "k8s.io/api/rbac/v1"
|
||||
)
|
||||
|
||||
// CSIProvisionerRBAC describes the interface that is provided by different
|
||||
// provisioner backends to get details about the required RBAC.
|
||||
type CSIProvisionerRBAC interface {
|
||||
GetServiceAccount() *corev1.ServiceAccount
|
||||
GetClusterRole() *rbacv1.ClusterRole
|
||||
GetClusterRoleBinding() *rbacv1.ClusterRoleBinding
|
||||
GetRole() *rbacv1.Role
|
||||
GetRoleBinding() *rbacv1.RoleBinding
|
||||
}
|
||||
|
||||
// CSIProvisionerRBACValues contains values that can be passed to
|
||||
// NewCSIProvisionerRBAC() functions for different provisioner backends.
|
||||
type CSIProvisionerRBACValues struct {
|
||||
Namespace string
|
||||
ServiceAccount string
|
||||
}
|
156
e2e/vendor/github.com/ceph/ceph-csi/internal/util/log/log.go
generated
vendored
Normal file
156
e2e/vendor/github.com/ceph/ceph-csi/internal/util/log/log.go
generated
vendored
Normal file
@ -0,0 +1,156 @@
|
||||
/*
|
||||
Copyright 2019 The Ceph-CSI 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 log
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
// enum defining logging levels.
|
||||
const (
|
||||
Default klog.Level = iota + 1
|
||||
Useful
|
||||
Extended
|
||||
Debug
|
||||
Trace
|
||||
)
|
||||
|
||||
type contextKey string
|
||||
|
||||
// CtxKey for context based logging.
|
||||
var CtxKey = contextKey("ID")
|
||||
|
||||
// ReqID for logging request ID.
|
||||
var ReqID = contextKey("Req-ID")
|
||||
|
||||
// Log helps in context based logging.
|
||||
func Log(ctx context.Context, format string) string {
|
||||
id := ctx.Value(CtxKey)
|
||||
if id == nil {
|
||||
return format
|
||||
}
|
||||
a := fmt.Sprintf("ID: %v ", id)
|
||||
reqID := ctx.Value(ReqID)
|
||||
if reqID == nil {
|
||||
return a + format
|
||||
}
|
||||
a += fmt.Sprintf("Req-ID: %v ", reqID)
|
||||
|
||||
return a + format
|
||||
}
|
||||
|
||||
// FatalLog helps in logging fatal errors.
|
||||
func FatalLogMsg(message string, args ...interface{}) {
|
||||
logMessage := fmt.Sprintf(message, args...)
|
||||
klog.FatalDepth(1, logMessage)
|
||||
}
|
||||
|
||||
// ErrorLogMsg helps in logging errors with message.
|
||||
func ErrorLogMsg(message string, args ...interface{}) {
|
||||
logMessage := fmt.Sprintf(message, args...)
|
||||
klog.ErrorDepth(1, logMessage)
|
||||
}
|
||||
|
||||
// ErrorLog helps in logging errors with context.
|
||||
func ErrorLog(ctx context.Context, message string, args ...interface{}) {
|
||||
logMessage := fmt.Sprintf(Log(ctx, message), args...)
|
||||
klog.ErrorDepth(1, logMessage)
|
||||
}
|
||||
|
||||
// WarningLogMsg helps in logging warnings with message.
|
||||
func WarningLogMsg(message string, args ...interface{}) {
|
||||
logMessage := fmt.Sprintf(message, args...)
|
||||
klog.WarningDepth(1, logMessage)
|
||||
}
|
||||
|
||||
// WarningLog helps in logging warnings with context.
|
||||
func WarningLog(ctx context.Context, message string, args ...interface{}) {
|
||||
logMessage := fmt.Sprintf(Log(ctx, message), args...)
|
||||
klog.WarningDepth(1, logMessage)
|
||||
}
|
||||
|
||||
// DefaultLog helps in logging with klog.level 1.
|
||||
func DefaultLog(message string, args ...interface{}) {
|
||||
logMessage := fmt.Sprintf(message, args...)
|
||||
// If logging is disabled, don't evaluate the arguments
|
||||
if klog.V(Default).Enabled() {
|
||||
klog.InfoDepth(1, logMessage)
|
||||
}
|
||||
}
|
||||
|
||||
// UsefulLog helps in logging with klog.level 2.
|
||||
func UsefulLog(ctx context.Context, message string, args ...interface{}) {
|
||||
logMessage := fmt.Sprintf(Log(ctx, message), args...)
|
||||
// If logging is disabled, don't evaluate the arguments
|
||||
if klog.V(Useful).Enabled() {
|
||||
klog.InfoDepth(1, logMessage)
|
||||
}
|
||||
}
|
||||
|
||||
// ExtendedLogMsg helps in logging a message with klog.level 3.
|
||||
func ExtendedLogMsg(message string, args ...interface{}) {
|
||||
logMessage := fmt.Sprintf(message, args...)
|
||||
// If logging is disabled, don't evaluate the arguments
|
||||
if klog.V(Extended).Enabled() {
|
||||
klog.InfoDepth(1, logMessage)
|
||||
}
|
||||
}
|
||||
|
||||
// ExtendedLog helps in logging with klog.level 3.
|
||||
func ExtendedLog(ctx context.Context, message string, args ...interface{}) {
|
||||
logMessage := fmt.Sprintf(Log(ctx, message), args...)
|
||||
// If logging is disabled, don't evaluate the arguments
|
||||
if klog.V(Extended).Enabled() {
|
||||
klog.InfoDepth(1, logMessage)
|
||||
}
|
||||
}
|
||||
|
||||
// DebugLogMsg helps in logging a message with klog.level 4.
|
||||
func DebugLogMsg(message string, args ...interface{}) {
|
||||
logMessage := fmt.Sprintf(message, args...)
|
||||
// If logging is disabled, don't evaluate the arguments
|
||||
if klog.V(Debug).Enabled() {
|
||||
klog.InfoDepth(1, logMessage)
|
||||
}
|
||||
}
|
||||
|
||||
// DebugLog helps in logging with klog.level 4.
|
||||
func DebugLog(ctx context.Context, message string, args ...interface{}) {
|
||||
logMessage := fmt.Sprintf(Log(ctx, message), args...)
|
||||
// If logging is disabled, don't evaluate the arguments
|
||||
if klog.V(Debug).Enabled() {
|
||||
klog.InfoDepth(1, logMessage)
|
||||
}
|
||||
}
|
||||
|
||||
// TraceLogMsg helps in logging a message with klog.level 5.
|
||||
func TraceLogMsg(message string, args ...interface{}) {
|
||||
logMessage := fmt.Sprintf(message, args...)
|
||||
// If logging is disabled, don't evaluate the arguments
|
||||
if klog.V(Trace).Enabled() {
|
||||
klog.InfoDepth(1, logMessage)
|
||||
}
|
||||
}
|
||||
|
||||
// TraceLog helps in logging with klog.level 5.
|
||||
func TraceLog(ctx context.Context, message string, args ...interface{}) {
|
||||
logMessage := fmt.Sprintf(Log(ctx, message), args...)
|
||||
// If logging is disabled, don't evaluate the arguments
|
||||
if klog.V(Trace).Enabled() {
|
||||
klog.InfoDepth(1, logMessage)
|
||||
}
|
||||
}
|
51
e2e/vendor/github.com/ceph/ceph-csi/internal/util/log/log_utils.go
generated
vendored
Normal file
51
e2e/vendor/github.com/ceph/ceph-csi/internal/util/log/log_utils.go
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
Copyright 2021 The Ceph-CSI 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 log
|
||||
|
||||
import (
|
||||
"compress/gzip"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// GzipLogFile convert and replace log file from text format to gzip
|
||||
// compressed format.
|
||||
func GzipLogFile(pathToFile string) error {
|
||||
// Get all the bytes from the file.
|
||||
content, err := os.ReadFile(pathToFile) // #nosec:G304, file inclusion via variable.
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Replace .log extension with .gz extension.
|
||||
newExt := strings.ReplaceAll(pathToFile, ".log", ".gz")
|
||||
|
||||
// Open file for writing.
|
||||
gf, err := os.OpenFile(newExt, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0o644) // #nosec:G304,G302, file inclusion & perms
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer gf.Close() // #nosec:G307, error on close is not critical here
|
||||
|
||||
// Write compressed data.
|
||||
w := gzip.NewWriter(gf)
|
||||
defer w.Close()
|
||||
if _, err = w.Write(content); err != nil {
|
||||
os.Remove(newExt) // #nosec:G104, not important error to handle
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return os.Remove(pathToFile)
|
||||
}
|
63
e2e/vendor/github.com/ceph/ceph-csi/pkg/util/crypto/types.go
generated
vendored
Normal file
63
e2e/vendor/github.com/ceph/ceph-csi/pkg/util/crypto/types.go
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
Copyright 2025 The Ceph-CSI 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 crypto
|
||||
|
||||
type EncryptionType int
|
||||
|
||||
const (
|
||||
// EncryptionTypeInvalid signals invalid or unsupported configuration.
|
||||
EncryptionTypeInvalid EncryptionType = iota
|
||||
// EncryptionTypeNone disables encryption.
|
||||
EncryptionTypeNone
|
||||
// EncryptionTypeBlock enables block encryption.
|
||||
EncryptionTypeBlock
|
||||
// EncryptionTypeBlock enables file encryption (fscrypt).
|
||||
EncryptionTypeFile
|
||||
)
|
||||
|
||||
const (
|
||||
encryptionTypeBlockString = "block"
|
||||
encryptionTypeFileString = "file"
|
||||
)
|
||||
|
||||
func ParseEncryptionType(typeStr string) EncryptionType {
|
||||
switch typeStr {
|
||||
case encryptionTypeBlockString:
|
||||
return EncryptionTypeBlock
|
||||
case encryptionTypeFileString:
|
||||
return EncryptionTypeFile
|
||||
case "":
|
||||
return EncryptionTypeNone
|
||||
default:
|
||||
return EncryptionTypeInvalid
|
||||
}
|
||||
}
|
||||
|
||||
func (encType EncryptionType) String() string {
|
||||
switch encType {
|
||||
case EncryptionTypeBlock:
|
||||
return encryptionTypeBlockString
|
||||
case EncryptionTypeFile:
|
||||
return encryptionTypeFileString
|
||||
case EncryptionTypeNone:
|
||||
return ""
|
||||
case EncryptionTypeInvalid:
|
||||
return "INVALID"
|
||||
default:
|
||||
return "UNKNOWN"
|
||||
}
|
||||
}
|
132
e2e/vendor/github.com/ceph/ceph-csi/pkg/util/kernel/version.go
generated
vendored
Normal file
132
e2e/vendor/github.com/ceph/ceph-csi/pkg/util/kernel/version.go
generated
vendored
Normal file
@ -0,0 +1,132 @@
|
||||
/*
|
||||
Copyright 2025 The Ceph-CSI 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 kernel
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"github.com/ceph/ceph-csi/internal/util/log"
|
||||
)
|
||||
|
||||
// GetKernelVersion returns the version of the running Unix (like) system from the
|
||||
// 'utsname' structs 'release' component.
|
||||
func GetKernelVersion() (string, error) {
|
||||
utsname := unix.Utsname{}
|
||||
if err := unix.Uname(&utsname); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return strings.TrimRight(string(utsname.Release[:]), "\x00"), nil
|
||||
}
|
||||
|
||||
// KernelVersion holds kernel related information.
|
||||
type KernelVersion struct {
|
||||
Version int
|
||||
PatchLevel int
|
||||
SubLevel int
|
||||
ExtraVersion int // prefix of the part after the first "-"
|
||||
Distribution string // component of full extraversion
|
||||
Backport bool // backport have a fixed version/patchlevel/sublevel
|
||||
}
|
||||
|
||||
// parseKernelRelease parses a kernel release version string into:
|
||||
// version, patch version, sub version and extra version.
|
||||
func parseKernelRelease(release string) (int, int, int, int, error) {
|
||||
version := 0
|
||||
patchlevel := 0
|
||||
minVersions := 2
|
||||
|
||||
extra := ""
|
||||
n, err := fmt.Sscanf(release, "%d.%d%s", &version, &patchlevel, &extra)
|
||||
if n < minVersions && err != nil {
|
||||
return 0, 0, 0, 0, fmt.Errorf("failed to parse version and patchlevel from %s: %w", release, err)
|
||||
}
|
||||
|
||||
sublevel := 0
|
||||
extraversion := 0
|
||||
if n > minVersions {
|
||||
n, err = fmt.Sscanf(extra, ".%d%s", &sublevel, &extra)
|
||||
if err != nil && n == 0 && extra != "" && extra[0] != '-' && extra[0] == '.' {
|
||||
return 0, 0, 0, 0, fmt.Errorf("failed to parse subversion from %s: %w", release, err)
|
||||
}
|
||||
|
||||
extra = strings.TrimPrefix(extra, "-")
|
||||
// ignore errors, 1st component of extraversion does not need to be an int
|
||||
_, err = fmt.Sscanf(extra, "%d", &extraversion)
|
||||
if err != nil {
|
||||
// "go lint" wants err to be checked...
|
||||
extraversion = 0
|
||||
}
|
||||
}
|
||||
|
||||
return version, patchlevel, sublevel, extraversion, nil
|
||||
}
|
||||
|
||||
// CheckKernelSupport checks the running kernel and comparing it to known
|
||||
// versions that have support for required features . Distributors of
|
||||
// enterprise Linux have backport quota support to previous versions. This
|
||||
// function checks if the running kernel is one of the versions that have the
|
||||
// feature/fixes backport.
|
||||
//
|
||||
// `uname -r` (or Uname().Utsname.Release has a format like 1.2.3-rc.vendor
|
||||
// This can be slit up in the following components: - version (1) - patchlevel
|
||||
// (2) - sublevel (3) - optional, defaults to 0 - extraversion (rc) - optional,
|
||||
// matching integers only - distribution (.vendor) - optional, match against
|
||||
// whole `uname -r` string
|
||||
//
|
||||
// For matching multiple versions, the kernelSupport type contains a backport
|
||||
// bool, which will cause matching
|
||||
// version+patchlevel+sublevel+(>=extraversion)+(~distribution)
|
||||
//
|
||||
// In case the backport bool is false, a simple check for higher versions than
|
||||
// version+patchlevel+sublevel is done.
|
||||
func CheckKernelSupport(release string, supportedVersions []KernelVersion) bool {
|
||||
version, patchlevel, sublevel, extraversion, err := parseKernelRelease(release)
|
||||
if err != nil {
|
||||
log.ErrorLogMsg("%v", err)
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// compare running kernel against known versions
|
||||
for _, kernel := range supportedVersions {
|
||||
if !kernel.Backport {
|
||||
// deal with the default case(s), find >= match for version, patchlevel, sublevel
|
||||
if version > kernel.Version || (version == kernel.Version && patchlevel > kernel.PatchLevel) ||
|
||||
(version == kernel.Version && patchlevel == kernel.PatchLevel && sublevel >= kernel.SubLevel) {
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
// specific backport, match distribution initially
|
||||
if !strings.Contains(release, kernel.Distribution) {
|
||||
continue
|
||||
}
|
||||
|
||||
// strict match version, patchlevel, sublevel, and >= match extraversion
|
||||
if version == kernel.Version && patchlevel == kernel.PatchLevel &&
|
||||
sublevel == kernel.SubLevel && extraversion >= kernel.ExtraVersion {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
log.WarningLogMsg("kernel %s does not support required features", release)
|
||||
|
||||
return false
|
||||
}
|
Reference in New Issue
Block a user