mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 06:10:22 +00:00
rbd: controller to regenerate volume group omap data
This commit adds new controller that watches for the VolumeGroupReplicationContent and regenerates the OMAP data if it doesn't exists. Signed-off-by: Praveen M <m.praveen@ibm.com>
This commit is contained in:
parent
6e1c55c52d
commit
0927a48a7e
@ -26,6 +26,7 @@ import (
|
||||
"github.com/ceph/ceph-csi/internal/cephfs"
|
||||
"github.com/ceph/ceph-csi/internal/controller"
|
||||
"github.com/ceph/ceph-csi/internal/controller/persistentvolume"
|
||||
"github.com/ceph/ceph-csi/internal/controller/volumegroup"
|
||||
"github.com/ceph/ceph-csi/internal/liveness"
|
||||
nfsdriver "github.com/ceph/ceph-csi/internal/nfs/driver"
|
||||
rbddriver "github.com/ceph/ceph-csi/internal/rbd/driver"
|
||||
@ -294,6 +295,7 @@ func setPIDLimit(conf *util.Config) {
|
||||
func initControllers() {
|
||||
// Add list of controller here.
|
||||
persistentvolume.Init()
|
||||
volumegroup.Init()
|
||||
}
|
||||
|
||||
func validateCloneDepthFlag(conf *util.Config) {
|
||||
|
6
go.mod
6
go.mod
@ -48,8 +48,11 @@ require (
|
||||
require (
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0
|
||||
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.2.0
|
||||
github.com/csi-addons/kubernetes-csi-addons v0.9.0
|
||||
)
|
||||
|
||||
require github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
|
||||
|
||||
require (
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0 // indirect
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect
|
||||
@ -87,7 +90,6 @@ require (
|
||||
github.com/go-openapi/jsonpointer v0.19.6 // indirect
|
||||
github.com/go-openapi/jsonreference v0.20.2 // indirect
|
||||
github.com/go-openapi/swag v0.22.4 // indirect
|
||||
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
@ -156,7 +158,7 @@ require (
|
||||
go.opentelemetry.io/otel/trace v1.28.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.uber.org/zap v1.26.0 // indirect
|
||||
go.uber.org/zap v1.27.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
|
||||
golang.org/x/oauth2 v0.22.0 // indirect
|
||||
golang.org/x/sync v0.8.0 // indirect
|
||||
|
5
go.sum
5
go.sum
@ -1504,6 +1504,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
|
||||
github.com/csi-addons/kubernetes-csi-addons v0.9.0 h1:Hhb44WcrxtbzmpLY+uqX+DBWCI6HgA/rwQMPyvsyCc8=
|
||||
github.com/csi-addons/kubernetes-csi-addons v0.9.0/go.mod h1:/YROZDdEi1N/1Ls9rdU5W2VNjm8MK7HHApl8W4Sqt9s=
|
||||
github.com/csi-addons/spec v0.2.1-0.20241104111131-27825f744db5 h1:j9NaWj5KmzEVarmsjxS/NDAhes6Uzq1qhkUGHvDlVBk=
|
||||
github.com/csi-addons/spec v0.2.1-0.20241104111131-27825f744db5/go.mod h1:Mwq4iLiUV4s+K1bszcWU6aMsR5KPsbIYzzszJ6+56vI=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
@ -2413,8 +2415,9 @@ go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
|
||||
go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
|
||||
go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo=
|
||||
go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
|
||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||
golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
|
@ -20,13 +20,17 @@ import (
|
||||
|
||||
"github.com/ceph/ceph-csi/internal/util/log"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
apiruntime "k8s.io/apimachinery/pkg/runtime"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
|
||||
"k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/leaderelection/resourcelock"
|
||||
clientConfig "sigs.k8s.io/controller-runtime/pkg/client/config"
|
||||
"sigs.k8s.io/controller-runtime/pkg/manager"
|
||||
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
|
||||
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
|
||||
|
||||
replicationv1alpha1 "github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1"
|
||||
)
|
||||
|
||||
// Manager is the interface that will wrap Add function.
|
||||
@ -62,6 +66,9 @@ func addToManager(mgr manager.Manager, config Config) error {
|
||||
|
||||
// Start will start all the registered managers.
|
||||
func Start(config Config) error {
|
||||
scheme := apiruntime.NewScheme()
|
||||
utilruntime.Must(replicationv1alpha1.AddToScheme(scheme))
|
||||
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
|
||||
electionID := config.DriverName + "-" + config.Namespace
|
||||
opts := manager.Options{
|
||||
LeaderElection: true,
|
||||
@ -70,11 +77,12 @@ func Start(config Config) error {
|
||||
LeaderElectionNamespace: config.Namespace,
|
||||
LeaderElectionResourceLock: resourcelock.LeasesResourceLock,
|
||||
LeaderElectionID: electionID,
|
||||
Scheme: scheme,
|
||||
}
|
||||
|
||||
kubeConfig := clientConfig.GetConfigOrDie()
|
||||
coreKubeConfig := rest.CopyConfig(kubeConfig)
|
||||
coreKubeConfig.ContentType = runtime.ContentTypeProtobuf
|
||||
coreKubeConfig.ContentType = apiruntime.ContentTypeProtobuf
|
||||
mgr, err := manager.New(coreKubeConfig, opts)
|
||||
if err != nil {
|
||||
log.ErrorLogMsg("failed to create manager %s", err)
|
||||
|
200
internal/controller/volumegroup/volumegroupreplicationcontent.go
Normal file
200
internal/controller/volumegroup/volumegroupreplicationcontent.go
Normal file
@ -0,0 +1,200 @@
|
||||
/*
|
||||
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 volumegroup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
replicationv1alpha1 "github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/controller"
|
||||
"sigs.k8s.io/controller-runtime/pkg/handler"
|
||||
"sigs.k8s.io/controller-runtime/pkg/manager"
|
||||
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||
"sigs.k8s.io/controller-runtime/pkg/source"
|
||||
|
||||
ctrl "github.com/ceph/ceph-csi/internal/controller"
|
||||
"github.com/ceph/ceph-csi/internal/rbd"
|
||||
"github.com/ceph/ceph-csi/internal/util"
|
||||
"github.com/ceph/ceph-csi/internal/util/log"
|
||||
)
|
||||
|
||||
type ReconcileVGRContent struct {
|
||||
client client.Client
|
||||
config ctrl.Config
|
||||
Locks *util.VolumeLocks
|
||||
}
|
||||
|
||||
var (
|
||||
_ reconcile.Reconciler = &ReconcileVGRContent{}
|
||||
_ ctrl.Manager = &ReconcileVGRContent{}
|
||||
)
|
||||
|
||||
const (
|
||||
secretNameParameterName = "replication.storage.openshift.io/group-replication-secret-name"
|
||||
secretNamespaceParameterName = "replication.storage.openshift.io/group-replication-secret-namespace"
|
||||
)
|
||||
|
||||
// Init will add the ReconcileVGRContent to the list.
|
||||
func Init() {
|
||||
// add ReconcileVGRContent to the list
|
||||
ctrl.ControllerList = append(ctrl.ControllerList, &ReconcileVGRContent{})
|
||||
}
|
||||
|
||||
// Add adds the newVGRContentReconciler.
|
||||
func (r *ReconcileVGRContent) Add(mgr manager.Manager, config ctrl.Config) error {
|
||||
return add(mgr, newVGRContentReconciler(mgr, config))
|
||||
}
|
||||
|
||||
// newVGRContentReconciler returns a ReconcileVGRContent.
|
||||
func newVGRContentReconciler(mgr manager.Manager, config ctrl.Config) reconcile.Reconciler {
|
||||
r := &ReconcileVGRContent{
|
||||
client: mgr.GetClient(),
|
||||
config: config,
|
||||
Locks: util.NewVolumeLocks(),
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func add(mgr manager.Manager, r reconcile.Reconciler) error {
|
||||
// Create a new controller
|
||||
c, err := controller.New(
|
||||
"vgrcontent-controller",
|
||||
mgr,
|
||||
controller.Options{MaxConcurrentReconciles: 1, Reconciler: r})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Watch for changes to VolumeGroupReplicationContent
|
||||
err = c.Watch(source.Kind(
|
||||
mgr.GetCache(),
|
||||
&replicationv1alpha1.VolumeGroupReplicationContent{},
|
||||
&handler.TypedEnqueueRequestForObject[*replicationv1alpha1.VolumeGroupReplicationContent]{}),
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to watch the changes: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *ReconcileVGRContent) getSecrets(
|
||||
ctx context.Context,
|
||||
name,
|
||||
namespace string,
|
||||
) (map[string]string, error) {
|
||||
if name == "" || namespace == "" {
|
||||
return nil, errors.New("secret name or secret namespace is empty")
|
||||
}
|
||||
secret := &corev1.Secret{}
|
||||
err := r.client.Get(ctx, types.NamespacedName{Name: name, Namespace: namespace}, secret)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error getting secret %s in namespace %s: %w", name, namespace, err)
|
||||
}
|
||||
|
||||
secrets := map[string]string{}
|
||||
for key, value := range secret.Data {
|
||||
secrets[key] = string(value)
|
||||
}
|
||||
|
||||
return secrets, nil
|
||||
}
|
||||
|
||||
func (r *ReconcileVGRContent) reconcileVGRContent(ctx context.Context, obj runtime.Object) error {
|
||||
vgrc, ok := obj.(*replicationv1alpha1.VolumeGroupReplicationContent)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
if vgrc.Spec.Provisioner != r.config.DriverName {
|
||||
return nil
|
||||
}
|
||||
|
||||
reqName := vgrc.Name
|
||||
groupHandle := vgrc.Spec.VolumeGroupReplicationHandle
|
||||
volumeIds := vgrc.Spec.Source.VolumeHandles
|
||||
|
||||
if groupHandle == "" {
|
||||
return errors.New("volume group replication handle is empty")
|
||||
}
|
||||
|
||||
vgrClass := &replicationv1alpha1.VolumeGroupReplicationClass{}
|
||||
err := r.client.Get(ctx, types.NamespacedName{Name: vgrc.Spec.VolumeGroupReplicationClassName}, vgrClass)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if ok = r.Locks.TryAcquire(groupHandle); !ok {
|
||||
return fmt.Errorf("failed to acquire lock for group handle %s", groupHandle)
|
||||
}
|
||||
defer r.Locks.Release(groupHandle)
|
||||
|
||||
parameters := vgrClass.Spec.Parameters
|
||||
secretName := vgrClass.Spec.Parameters[secretNameParameterName]
|
||||
secretNamespace := vgrClass.Spec.Parameters[secretNamespaceParameterName]
|
||||
|
||||
secrets, err := r.getSecrets(ctx, secretName, secretNamespace)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mgr := rbd.NewManager(r.config.InstanceID, parameters, secrets)
|
||||
defer mgr.Destroy(ctx)
|
||||
|
||||
groupID, err := mgr.RegenerateVolumeGroupJournal(ctx, groupHandle, reqName, volumeIds)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if groupID != groupHandle {
|
||||
log.DebugLog(ctx, "groupHandle changed from %s to %s", groupHandle, groupID)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reconcile reconciles the VolumeGroupReplicationContent object and creates a new omap entries
|
||||
// for the volume group.
|
||||
func (r *ReconcileVGRContent) Reconcile(ctx context.Context,
|
||||
request reconcile.Request,
|
||||
) (reconcile.Result, error) {
|
||||
vgrc := &replicationv1alpha1.VolumeGroupReplicationContent{}
|
||||
err := r.client.Get(ctx, request.NamespacedName, vgrc)
|
||||
if err != nil {
|
||||
if apierrors.IsNotFound(err) {
|
||||
return reconcile.Result{}, nil
|
||||
}
|
||||
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
// Check if the object is under deletion
|
||||
if !vgrc.GetDeletionTimestamp().IsZero() {
|
||||
return reconcile.Result{}, nil
|
||||
}
|
||||
|
||||
err = r.reconcileVGRContent(ctx, vgrc)
|
||||
if err != nil {
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
|
||||
return reconcile.Result{}, nil
|
||||
}
|
202
vendor/github.com/csi-addons/kubernetes-csi-addons/LICENSE
generated
vendored
Normal file
202
vendor/github.com/csi-addons/kubernetes-csi-addons/LICENSE
generated
vendored
Normal file
@ -0,0 +1,202 @@
|
||||
|
||||
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
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
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.
|
36
vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/groupversion_info.go
generated
vendored
Normal file
36
vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/groupversion_info.go
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
Copyright 2022 The Kubernetes-CSI-Addons 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 v1alpha1 contains API Schema definitions for the replication.storage v1alpha1 API group
|
||||
// +kubebuilder:object:generate=true
|
||||
// +groupName=replication.storage.openshift.io
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/controller-runtime/pkg/scheme"
|
||||
)
|
||||
|
||||
var (
|
||||
// GroupVersion is group version used to register these objects
|
||||
GroupVersion = schema.GroupVersion{Group: "replication.storage.openshift.io", Version: "v1alpha1"}
|
||||
|
||||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
|
||||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
|
||||
|
||||
// AddToScheme adds the types in this group-version to the given scheme.
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
105
vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumegroupreplication_types.go
generated
vendored
Normal file
105
vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumegroupreplication_types.go
generated
vendored
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
Copyright 2024 The Kubernetes-CSI-Addons 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 v1alpha1
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// VolumeGroupReplicationSpec defines the desired state of VolumeGroupReplication
|
||||
type VolumeGroupReplicationSpec struct {
|
||||
// volumeGroupReplicationClassName is the volumeGroupReplicationClass name for this VolumeGroupReplication resource
|
||||
// +kubebuilder:validation:Required
|
||||
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeGroupReplicationClassName is immutable"
|
||||
VolumeGroupReplicationClassName string `json:"volumeGroupReplicationClassName"`
|
||||
|
||||
// volumeReplicationClassName is the volumeReplicationClass name for VolumeReplication object
|
||||
// +kubebuilder:validation:Required
|
||||
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumReplicationClassName is immutable"
|
||||
VolumeReplicationClassName string `json:"volumeReplicationClassName"`
|
||||
|
||||
// Name of the VolumeReplication object created for this volumeGroupReplication
|
||||
// +kubebuilder:validation:Optional
|
||||
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeReplicationName is immutable"
|
||||
VolumeReplicationName string `json:"volumeReplicationName,omitempty"`
|
||||
|
||||
// Name of the VolumeGroupReplicationContent object created for this volumeGroupReplication
|
||||
// +kubebuilder:validation:Optional
|
||||
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeGroupReplicationContentName is immutable"
|
||||
VolumeGroupReplicationContentName string `json:"volumeGroupReplicationContentName,omitempty"`
|
||||
|
||||
// Source specifies where a group replications will be created from.
|
||||
// This field is immutable after creation.
|
||||
// Required.
|
||||
// +kubebuilder:validation:Required
|
||||
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="source is immutable"
|
||||
Source VolumeGroupReplicationSource `json:"source"`
|
||||
|
||||
// ReplicationState represents the replication operation to be performed on the group.
|
||||
// Supported operations are "primary", "secondary" and "resync"
|
||||
// +kubebuilder:validation:Required
|
||||
ReplicationState ReplicationState `json:"replicationState"`
|
||||
|
||||
// AutoResync represents the group to be auto resynced when
|
||||
// ReplicationState is "secondary"
|
||||
// +kubebuilder:default:=false
|
||||
AutoResync bool `json:"autoResync"`
|
||||
}
|
||||
|
||||
// VolumeGroupReplicationSource specifies the source for the the volumeGroupReplication
|
||||
type VolumeGroupReplicationSource struct {
|
||||
// Selector is a label query over persistent volume claims that are to be
|
||||
// grouped together for replication.
|
||||
// +optional
|
||||
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="selector is immutable"
|
||||
Selector *metav1.LabelSelector `json:"selector,omitempty"`
|
||||
}
|
||||
|
||||
// VolumeGroupReplicationStatus defines the observed state of VolumeGroupReplication
|
||||
type VolumeGroupReplicationStatus struct {
|
||||
VolumeReplicationStatus `json:",inline"`
|
||||
// PersistentVolumeClaimsRefList is the list of PVCs for the volume group replication.
|
||||
// The maximum number of allowed PVCs in the group is 100.
|
||||
// +optional
|
||||
PersistentVolumeClaimsRefList []corev1.LocalObjectReference `json:"persistentVolumeClaimsRefList,omitempty"`
|
||||
}
|
||||
|
||||
//+kubebuilder:object:root=true
|
||||
//+kubebuilder:subresource:status
|
||||
|
||||
// VolumeGroupReplication is the Schema for the volumegroupreplications API
|
||||
type VolumeGroupReplication struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec VolumeGroupReplicationSpec `json:"spec,omitempty"`
|
||||
Status VolumeGroupReplicationStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
//+kubebuilder:object:root=true
|
||||
|
||||
// VolumeGroupReplicationList contains a list of VolumeGroupReplication
|
||||
type VolumeGroupReplicationList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []VolumeGroupReplication `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&VolumeGroupReplication{}, &VolumeGroupReplicationList{})
|
||||
}
|
67
vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumegroupreplicationclass_types.go
generated
vendored
Normal file
67
vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumegroupreplicationclass_types.go
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
Copyright 2024 The Kubernetes-CSI-Addons 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 v1alpha1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// VolumeGroupReplicationClassSpec specifies parameters that an underlying storage system uses
|
||||
// when creating a volumegroup replica. A specific VolumeGroupReplicationClass is used by specifying
|
||||
// its name in a VolumeGroupReplication object.
|
||||
// +kubebuilder:validation:XValidation:rule="has(self.parameters) == has(oldSelf.parameters)",message="parameters are immutable"
|
||||
type VolumeGroupReplicationClassSpec struct {
|
||||
// Provisioner is the name of storage provisioner
|
||||
// +kubebuilder:validation:Required
|
||||
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="provisioner is immutable"
|
||||
Provisioner string `json:"provisioner"`
|
||||
// Parameters is a key-value map with storage provisioner specific configurations for
|
||||
// creating volume group replicas
|
||||
// +kubebuilder:validation:Optional
|
||||
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="parameters are immutable"
|
||||
Parameters map[string]string `json:"parameters,omitempty"`
|
||||
}
|
||||
|
||||
// VolumeGroupReplicationClassStatus defines the observed state of VolumeGroupReplicationClass
|
||||
type VolumeGroupReplicationClassStatus struct {
|
||||
}
|
||||
|
||||
//+kubebuilder:object:root=true
|
||||
//+kubebuilder:subresource:status
|
||||
//+kubebuilder:resource:scope=Cluster
|
||||
|
||||
// VolumeGroupReplicationClass is the Schema for the volumegroupreplicationclasses API
|
||||
type VolumeGroupReplicationClass struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec VolumeGroupReplicationClassSpec `json:"spec,omitempty"`
|
||||
Status VolumeGroupReplicationClassStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
//+kubebuilder:object:root=true
|
||||
|
||||
// VolumeGroupReplicationClassList contains a list of VolumeGroupReplicationClass
|
||||
type VolumeGroupReplicationClassList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []VolumeGroupReplicationClass `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&VolumeGroupReplicationClass{}, &VolumeGroupReplicationClassList{})
|
||||
}
|
101
vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumegroupreplicationcontent_types.go
generated
vendored
Normal file
101
vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumegroupreplicationcontent_types.go
generated
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
Copyright 2024 The Kubernetes-CSI-Addons 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 v1alpha1
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// VolumeGroupReplicationContentSpec defines the desired state of VolumeGroupReplicationContent
|
||||
type VolumeGroupReplicationContentSpec struct {
|
||||
// VolumeGroupreplicationRef specifies the VolumeGroupReplication object to which this
|
||||
// VolumeGroupReplicationContent object is bound.
|
||||
// VolumeGroupReplication.Spec.VolumeGroupReplicationContentName field must reference to
|
||||
// this VolumeGroupReplicationContent's name for the bidirectional binding to be valid.
|
||||
// For a pre-existing VolumeGroupReplicationContent object, name and namespace of the
|
||||
// VolumeGroupReplication object MUST be provided for binding to happen.
|
||||
// This field is immutable after creation.
|
||||
// Required.
|
||||
// +kubebuilder:validation:XValidation:rule="has(self.name) && has(self.__namespace__)",message="both volumeGroupReplicationRef.name and volumeGroupReplicationRef.namespace must be set"
|
||||
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeGroupReplicationRef is immutable"
|
||||
VolumeGroupReplicationRef corev1.ObjectReference `json:"volumeGroupReplicationRef"`
|
||||
|
||||
// VolumeGroupReplicationHandle is a unique id returned by the CSI driver
|
||||
// to identify the VolumeGroupReplication on the storage system.
|
||||
VolumeGroupReplicationHandle string `json:"volumeGroupReplicationHandle"`
|
||||
|
||||
// provisioner is the name of the CSI driver used to create the physical
|
||||
// volume group on
|
||||
// the underlying storage system.
|
||||
// This MUST be the same as the name returned by the CSI GetPluginName() call for
|
||||
// that driver.
|
||||
// Required.
|
||||
Provisioner string `json:"provisioner"`
|
||||
|
||||
// VolumeGroupReplicationClassName is the name of the VolumeGroupReplicationClass from
|
||||
// which this group replication was (or will be) created.
|
||||
// +optional
|
||||
VolumeGroupReplicationClassName string `json:"volumeGroupReplicationClassName"`
|
||||
|
||||
// Source specifies whether the snapshot is (or should be) dynamically provisioned
|
||||
// or already exists, and just requires a Kubernetes object representation.
|
||||
// This field is immutable after creation.
|
||||
// Required.
|
||||
Source VolumeGroupReplicationContentSource `json:"source"`
|
||||
}
|
||||
|
||||
// VolumeGroupReplicationContentSource represents the CSI source of a group replication.
|
||||
type VolumeGroupReplicationContentSource struct {
|
||||
// VolumeHandles is a list of volume handles on the backend to be grouped
|
||||
// and replicated.
|
||||
VolumeHandles []string `json:"volumeHandles"`
|
||||
}
|
||||
|
||||
// VolumeGroupReplicationContentStatus defines the status of VolumeGroupReplicationContent
|
||||
type VolumeGroupReplicationContentStatus struct {
|
||||
// PersistentVolumeRefList is the list of of PV for the group replication
|
||||
// The maximum number of allowed PV in the group is 100.
|
||||
// +optional
|
||||
PersistentVolumeRefList []corev1.LocalObjectReference `json:"persistentVolumeRefList,omitempty"`
|
||||
}
|
||||
|
||||
//+kubebuilder:object:root=true
|
||||
//+kubebuilder:subresource:status
|
||||
//+kubebuilder:resource:scope=Cluster
|
||||
|
||||
// VolumeGroupReplicationContent is the Schema for the volumegroupreplicationcontents API
|
||||
type VolumeGroupReplicationContent struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec VolumeGroupReplicationContentSpec `json:"spec,omitempty"`
|
||||
Status VolumeGroupReplicationContentStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
//+kubebuilder:object:root=true
|
||||
|
||||
// VolumeGroupReplicationContentList contains a list of VolumeGroupReplicationContent
|
||||
type VolumeGroupReplicationContentList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []VolumeGroupReplicationContent `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&VolumeGroupReplicationContent{}, &VolumeGroupReplicationContentList{})
|
||||
}
|
131
vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumereplication_types.go
generated
vendored
Normal file
131
vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumereplication_types.go
generated
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
Copyright 2022 The Kubernetes-CSI-Addons 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 v1alpha1
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
VolumeReplicationNameAnnotation = "replication.storage.openshift.io/volume-replication-name"
|
||||
)
|
||||
|
||||
// ReplicationState represents the replication operations to be performed on the volume.
|
||||
// +kubebuilder:validation:Enum=primary;secondary;resync
|
||||
type ReplicationState string
|
||||
|
||||
const (
|
||||
// Primary ReplicationState enables mirroring and promotes the volume to primary.
|
||||
Primary ReplicationState = "primary"
|
||||
|
||||
// Secondary ReplicationState demotes the volume to secondary and resyncs the volume if out of sync.
|
||||
Secondary ReplicationState = "secondary"
|
||||
|
||||
// Resync option resyncs the volume.
|
||||
Resync ReplicationState = "resync"
|
||||
)
|
||||
|
||||
// State captures the latest state of the replication operation.
|
||||
type State string
|
||||
|
||||
const (
|
||||
// PrimaryState represents the Primary replication state.
|
||||
PrimaryState State = "Primary"
|
||||
|
||||
// SecondaryState represents the Secondary replication state.
|
||||
SecondaryState State = "Secondary"
|
||||
|
||||
// UnknownState represents the Unknown replication state.
|
||||
UnknownState State = "Unknown"
|
||||
)
|
||||
|
||||
// VolumeReplicationSpec defines the desired state of VolumeReplication.
|
||||
type VolumeReplicationSpec struct {
|
||||
// VolumeReplicationClass is the VolumeReplicationClass name for this VolumeReplication resource
|
||||
// +kubebuilder:validation:Required
|
||||
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeReplicationClass is immutable"
|
||||
VolumeReplicationClass string `json:"volumeReplicationClass"`
|
||||
|
||||
// ReplicationState represents the replication operation to be performed on the volume.
|
||||
// Supported operations are "primary", "secondary" and "resync"
|
||||
// +kubebuilder:validation:Required
|
||||
ReplicationState ReplicationState `json:"replicationState"`
|
||||
|
||||
// DataSource represents the object associated with the volume
|
||||
// +kubebuilder:validation:Required
|
||||
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="dataSource is immutable"
|
||||
DataSource corev1.TypedLocalObjectReference `json:"dataSource"`
|
||||
|
||||
// AutoResync represents the volume to be auto resynced when
|
||||
// ReplicationState is "secondary"
|
||||
// +kubebuilder:default:=false
|
||||
AutoResync bool `json:"autoResync"`
|
||||
|
||||
// replicationHandle represents an existing (but new) replication id
|
||||
// +kubebuilder:validation:Optional
|
||||
ReplicationHandle string `json:"replicationHandle"`
|
||||
}
|
||||
|
||||
// VolumeReplicationStatus defines the observed state of VolumeReplication.
|
||||
type VolumeReplicationStatus struct {
|
||||
State State `json:"state,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
// Conditions are the list of conditions and their status.
|
||||
Conditions []metav1.Condition `json:"conditions,omitempty"`
|
||||
// observedGeneration is the last generation change the operator has dealt with
|
||||
// +optional
|
||||
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
|
||||
LastStartTime *metav1.Time `json:"lastStartTime,omitempty"`
|
||||
LastCompletionTime *metav1.Time `json:"lastCompletionTime,omitempty"`
|
||||
LastSyncTime *metav1.Time `json:"lastSyncTime,omitempty"`
|
||||
LastSyncBytes *int64 `json:"lastSyncBytes,omitempty"`
|
||||
LastSyncDuration *metav1.Duration `json:"lastSyncDuration,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +kubebuilder:subresource:status
|
||||
// +kubebuilder:printcolumn:JSONPath=".metadata.creationTimestamp",name=Age,type=date
|
||||
// +kubebuilder:printcolumn:JSONPath=".spec.volumeReplicationClass",name=volumeReplicationClass,type=string
|
||||
// +kubebuilder:printcolumn:JSONPath=".spec.dataSource.name",name=pvcName,type=string
|
||||
// +kubebuilder:printcolumn:JSONPath=".spec.replicationState",name=desiredState,type=string
|
||||
// +kubebuilder:printcolumn:JSONPath=".status.state",name=currentState,type=string
|
||||
// +kubebuilder:resource:shortName=vr
|
||||
|
||||
// VolumeReplication is the Schema for the volumereplications API.
|
||||
type VolumeReplication struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
// +kubebuilder:validation:Required
|
||||
Spec VolumeReplicationSpec `json:"spec"`
|
||||
|
||||
Status VolumeReplicationStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
|
||||
// VolumeReplicationList contains a list of VolumeReplication.
|
||||
type VolumeReplicationList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []VolumeReplication `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&VolumeReplication{}, &VolumeReplicationList{})
|
||||
}
|
69
vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumereplicationclass_types.go
generated
vendored
Normal file
69
vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumereplicationclass_types.go
generated
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
Copyright 2022 The Kubernetes-CSI-Addons 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 v1alpha1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// VolumeReplicationClassSpec specifies parameters that an underlying storage system uses
|
||||
// when creating a volume replica. A specific VolumeReplicationClass is used by specifying
|
||||
// its name in a VolumeReplication object.
|
||||
// +kubebuilder:validation:XValidation:rule="has(self.parameters) == has(oldSelf.parameters)",message="parameters are immutable"
|
||||
type VolumeReplicationClassSpec struct {
|
||||
// Provisioner is the name of storage provisioner
|
||||
// +kubebuilder:validation:Required
|
||||
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="provisioner is immutable"
|
||||
Provisioner string `json:"provisioner"`
|
||||
// Parameters is a key-value map with storage provisioner specific configurations for
|
||||
// creating volume replicas
|
||||
// +kubebuilder:validation:Optional
|
||||
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="parameters are immutable"
|
||||
Parameters map[string]string `json:"parameters,omitempty"`
|
||||
}
|
||||
|
||||
// VolumeReplicationClassStatus defines the observed state of VolumeReplicationClass.
|
||||
type VolumeReplicationClassStatus struct{}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +kubebuilder:subresource:status
|
||||
// +kubebuilder:resource:scope=Cluster,shortName=vrc
|
||||
// +kubebuilder:printcolumn:JSONPath=".spec.provisioner",name=provisioner,type=string
|
||||
|
||||
// VolumeReplicationClass is the Schema for the volumereplicationclasses API.
|
||||
type VolumeReplicationClass struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
// +kubebuilder:validation:Required
|
||||
Spec VolumeReplicationClassSpec `json:"spec"`
|
||||
|
||||
Status VolumeReplicationClassStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
|
||||
// VolumeReplicationClassList contains a list of VolumeReplicationClass.
|
||||
type VolumeReplicationClassList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []VolumeReplicationClass `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&VolumeReplicationClass{}, &VolumeReplicationClassList{})
|
||||
}
|
570
vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/zz_generated.deepcopy.go
generated
vendored
Normal file
570
vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/zz_generated.deepcopy.go
generated
vendored
Normal file
@ -0,0 +1,570 @@
|
||||
//go:build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2022 The Kubernetes-CSI-Addons 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.
|
||||
*/
|
||||
|
||||
// Code generated by controller-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeGroupReplication) DeepCopyInto(out *VolumeGroupReplication) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplication.
|
||||
func (in *VolumeGroupReplication) DeepCopy() *VolumeGroupReplication {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeGroupReplication)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *VolumeGroupReplication) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeGroupReplicationClass) DeepCopyInto(out *VolumeGroupReplicationClass) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
out.Status = in.Status
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationClass.
|
||||
func (in *VolumeGroupReplicationClass) DeepCopy() *VolumeGroupReplicationClass {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeGroupReplicationClass)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *VolumeGroupReplicationClass) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeGroupReplicationClassList) DeepCopyInto(out *VolumeGroupReplicationClassList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]VolumeGroupReplicationClass, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationClassList.
|
||||
func (in *VolumeGroupReplicationClassList) DeepCopy() *VolumeGroupReplicationClassList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeGroupReplicationClassList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *VolumeGroupReplicationClassList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeGroupReplicationClassSpec) DeepCopyInto(out *VolumeGroupReplicationClassSpec) {
|
||||
*out = *in
|
||||
if in.Parameters != nil {
|
||||
in, out := &in.Parameters, &out.Parameters
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationClassSpec.
|
||||
func (in *VolumeGroupReplicationClassSpec) DeepCopy() *VolumeGroupReplicationClassSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeGroupReplicationClassSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeGroupReplicationClassStatus) DeepCopyInto(out *VolumeGroupReplicationClassStatus) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationClassStatus.
|
||||
func (in *VolumeGroupReplicationClassStatus) DeepCopy() *VolumeGroupReplicationClassStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeGroupReplicationClassStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeGroupReplicationContent) DeepCopyInto(out *VolumeGroupReplicationContent) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationContent.
|
||||
func (in *VolumeGroupReplicationContent) DeepCopy() *VolumeGroupReplicationContent {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeGroupReplicationContent)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *VolumeGroupReplicationContent) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeGroupReplicationContentList) DeepCopyInto(out *VolumeGroupReplicationContentList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]VolumeGroupReplicationContent, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationContentList.
|
||||
func (in *VolumeGroupReplicationContentList) DeepCopy() *VolumeGroupReplicationContentList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeGroupReplicationContentList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *VolumeGroupReplicationContentList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeGroupReplicationContentSource) DeepCopyInto(out *VolumeGroupReplicationContentSource) {
|
||||
*out = *in
|
||||
if in.VolumeHandles != nil {
|
||||
in, out := &in.VolumeHandles, &out.VolumeHandles
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationContentSource.
|
||||
func (in *VolumeGroupReplicationContentSource) DeepCopy() *VolumeGroupReplicationContentSource {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeGroupReplicationContentSource)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeGroupReplicationContentSpec) DeepCopyInto(out *VolumeGroupReplicationContentSpec) {
|
||||
*out = *in
|
||||
out.VolumeGroupReplicationRef = in.VolumeGroupReplicationRef
|
||||
in.Source.DeepCopyInto(&out.Source)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationContentSpec.
|
||||
func (in *VolumeGroupReplicationContentSpec) DeepCopy() *VolumeGroupReplicationContentSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeGroupReplicationContentSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeGroupReplicationContentStatus) DeepCopyInto(out *VolumeGroupReplicationContentStatus) {
|
||||
*out = *in
|
||||
if in.PersistentVolumeRefList != nil {
|
||||
in, out := &in.PersistentVolumeRefList, &out.PersistentVolumeRefList
|
||||
*out = make([]corev1.LocalObjectReference, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationContentStatus.
|
||||
func (in *VolumeGroupReplicationContentStatus) DeepCopy() *VolumeGroupReplicationContentStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeGroupReplicationContentStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeGroupReplicationList) DeepCopyInto(out *VolumeGroupReplicationList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]VolumeGroupReplication, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationList.
|
||||
func (in *VolumeGroupReplicationList) DeepCopy() *VolumeGroupReplicationList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeGroupReplicationList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *VolumeGroupReplicationList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeGroupReplicationSource) DeepCopyInto(out *VolumeGroupReplicationSource) {
|
||||
*out = *in
|
||||
if in.Selector != nil {
|
||||
in, out := &in.Selector, &out.Selector
|
||||
*out = new(v1.LabelSelector)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationSource.
|
||||
func (in *VolumeGroupReplicationSource) DeepCopy() *VolumeGroupReplicationSource {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeGroupReplicationSource)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeGroupReplicationSpec) DeepCopyInto(out *VolumeGroupReplicationSpec) {
|
||||
*out = *in
|
||||
in.Source.DeepCopyInto(&out.Source)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationSpec.
|
||||
func (in *VolumeGroupReplicationSpec) DeepCopy() *VolumeGroupReplicationSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeGroupReplicationSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeGroupReplicationStatus) DeepCopyInto(out *VolumeGroupReplicationStatus) {
|
||||
*out = *in
|
||||
in.VolumeReplicationStatus.DeepCopyInto(&out.VolumeReplicationStatus)
|
||||
if in.PersistentVolumeClaimsRefList != nil {
|
||||
in, out := &in.PersistentVolumeClaimsRefList, &out.PersistentVolumeClaimsRefList
|
||||
*out = make([]corev1.LocalObjectReference, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationStatus.
|
||||
func (in *VolumeGroupReplicationStatus) DeepCopy() *VolumeGroupReplicationStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeGroupReplicationStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeReplication) DeepCopyInto(out *VolumeReplication) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeReplication.
|
||||
func (in *VolumeReplication) DeepCopy() *VolumeReplication {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeReplication)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *VolumeReplication) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeReplicationClass) DeepCopyInto(out *VolumeReplicationClass) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
out.Status = in.Status
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeReplicationClass.
|
||||
func (in *VolumeReplicationClass) DeepCopy() *VolumeReplicationClass {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeReplicationClass)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *VolumeReplicationClass) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeReplicationClassList) DeepCopyInto(out *VolumeReplicationClassList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]VolumeReplicationClass, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeReplicationClassList.
|
||||
func (in *VolumeReplicationClassList) DeepCopy() *VolumeReplicationClassList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeReplicationClassList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *VolumeReplicationClassList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeReplicationClassSpec) DeepCopyInto(out *VolumeReplicationClassSpec) {
|
||||
*out = *in
|
||||
if in.Parameters != nil {
|
||||
in, out := &in.Parameters, &out.Parameters
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeReplicationClassSpec.
|
||||
func (in *VolumeReplicationClassSpec) DeepCopy() *VolumeReplicationClassSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeReplicationClassSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeReplicationClassStatus) DeepCopyInto(out *VolumeReplicationClassStatus) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeReplicationClassStatus.
|
||||
func (in *VolumeReplicationClassStatus) DeepCopy() *VolumeReplicationClassStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeReplicationClassStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeReplicationList) DeepCopyInto(out *VolumeReplicationList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]VolumeReplication, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeReplicationList.
|
||||
func (in *VolumeReplicationList) DeepCopy() *VolumeReplicationList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeReplicationList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *VolumeReplicationList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeReplicationSpec) DeepCopyInto(out *VolumeReplicationSpec) {
|
||||
*out = *in
|
||||
in.DataSource.DeepCopyInto(&out.DataSource)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeReplicationSpec.
|
||||
func (in *VolumeReplicationSpec) DeepCopy() *VolumeReplicationSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeReplicationSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VolumeReplicationStatus) DeepCopyInto(out *VolumeReplicationStatus) {
|
||||
*out = *in
|
||||
if in.Conditions != nil {
|
||||
in, out := &in.Conditions, &out.Conditions
|
||||
*out = make([]v1.Condition, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
if in.LastStartTime != nil {
|
||||
in, out := &in.LastStartTime, &out.LastStartTime
|
||||
*out = (*in).DeepCopy()
|
||||
}
|
||||
if in.LastCompletionTime != nil {
|
||||
in, out := &in.LastCompletionTime, &out.LastCompletionTime
|
||||
*out = (*in).DeepCopy()
|
||||
}
|
||||
if in.LastSyncTime != nil {
|
||||
in, out := &in.LastSyncTime, &out.LastSyncTime
|
||||
*out = (*in).DeepCopy()
|
||||
}
|
||||
if in.LastSyncBytes != nil {
|
||||
in, out := &in.LastSyncBytes, &out.LastSyncBytes
|
||||
*out = new(int64)
|
||||
**out = **in
|
||||
}
|
||||
if in.LastSyncDuration != nil {
|
||||
in, out := &in.LastSyncDuration, &out.LastSyncDuration
|
||||
*out = new(v1.Duration)
|
||||
**out = **in
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeReplicationStatus.
|
||||
func (in *VolumeReplicationStatus) DeepCopy() *VolumeReplicationStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VolumeReplicationStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
2
vendor/go.uber.org/zap/.golangci.yml
generated
vendored
2
vendor/go.uber.org/zap/.golangci.yml
generated
vendored
@ -17,7 +17,7 @@ linters:
|
||||
- unused
|
||||
|
||||
# Our own extras:
|
||||
- gofmt
|
||||
- gofumpt
|
||||
- nolintlint # lints nolint directives
|
||||
- revive
|
||||
|
||||
|
10
vendor/go.uber.org/zap/.readme.tmpl
generated
vendored
10
vendor/go.uber.org/zap/.readme.tmpl
generated
vendored
@ -1,7 +1,15 @@
|
||||
# :zap: zap [![GoDoc][doc-img]][doc] [![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov]
|
||||
|
||||
<div align="center">
|
||||
|
||||
Blazing fast, structured, leveled logging in Go.
|
||||
|
||||
![Zap logo](assets/logo.png)
|
||||
|
||||
[![GoDoc][doc-img]][doc] [![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov]
|
||||
|
||||
</div>
|
||||
|
||||
## Installation
|
||||
|
||||
`go get -u go.uber.org/zap`
|
||||
@ -92,7 +100,7 @@ standard.
|
||||
|
||||
<hr>
|
||||
|
||||
Released under the [MIT License](LICENSE.txt).
|
||||
Released under the [MIT License](LICENSE).
|
||||
|
||||
<sup id="footnote-versions">1</sup> In particular, keep in mind that we may be
|
||||
benchmarking against slightly older versions of other packages. Versions are
|
||||
|
52
vendor/go.uber.org/zap/CHANGELOG.md
generated
vendored
52
vendor/go.uber.org/zap/CHANGELOG.md
generated
vendored
@ -3,14 +3,30 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## 1.27.0 (20 Feb 2024)
|
||||
Enhancements:
|
||||
* [#1378][]: Add `WithLazy` method for `SugaredLogger`.
|
||||
* [#1399][]: zaptest: Add `NewTestingWriter` for customizing TestingWriter with more flexibility than `NewLogger`.
|
||||
* [#1406][]: Add `Log`, `Logw`, `Logln` methods for `SugaredLogger`.
|
||||
* [#1416][]: Add `WithPanicHook` option for testing panic logs.
|
||||
|
||||
Thanks to @defval, @dimmo, @arxeiss, and @MKrupauskas for their contributions to this release.
|
||||
|
||||
[#1378]: https://github.com/uber-go/zap/pull/1378
|
||||
[#1399]: https://github.com/uber-go/zap/pull/1399
|
||||
[#1406]: https://github.com/uber-go/zap/pull/1406
|
||||
[#1416]: https://github.com/uber-go/zap/pull/1416
|
||||
|
||||
## 1.26.0 (14 Sep 2023)
|
||||
Enhancements:
|
||||
* [#1297][]: Add Dict as a Field.
|
||||
* [#1319][]: Add `WithLazy` method to `Logger` which lazily evaluates the structured
|
||||
context.
|
||||
* [#1350][]: String encoding is much (~50%) faster now.
|
||||
|
||||
Thanks to @jquirke, @cdvr1993 for their contributions to this release.
|
||||
Thanks to @hhk7734, @jquirke, and @cdvr1993 for their contributions to this release.
|
||||
|
||||
[#1297]: https://github.com/uber-go/zap/pull/1297
|
||||
[#1319]: https://github.com/uber-go/zap/pull/1319
|
||||
[#1350]: https://github.com/uber-go/zap/pull/1350
|
||||
|
||||
@ -352,7 +368,7 @@ to this release.
|
||||
[#675]: https://github.com/uber-go/zap/pull/675
|
||||
[#704]: https://github.com/uber-go/zap/pull/704
|
||||
|
||||
## v1.9.1 (06 Aug 2018)
|
||||
## 1.9.1 (06 Aug 2018)
|
||||
|
||||
Bugfixes:
|
||||
|
||||
@ -360,7 +376,7 @@ Bugfixes:
|
||||
|
||||
[#614]: https://github.com/uber-go/zap/pull/614
|
||||
|
||||
## v1.9.0 (19 Jul 2018)
|
||||
## 1.9.0 (19 Jul 2018)
|
||||
|
||||
Enhancements:
|
||||
* [#602][]: Reduce number of allocations when logging with reflection.
|
||||
@ -373,7 +389,7 @@ Thanks to @nfarah86, @AlekSi, @JeanMertz, @philippgille, @etsangsplk, and
|
||||
[#572]: https://github.com/uber-go/zap/pull/572
|
||||
[#606]: https://github.com/uber-go/zap/pull/606
|
||||
|
||||
## v1.8.0 (13 Apr 2018)
|
||||
## 1.8.0 (13 Apr 2018)
|
||||
|
||||
Enhancements:
|
||||
* [#508][]: Make log level configurable when redirecting the standard
|
||||
@ -391,14 +407,14 @@ Thanks to @DiSiqueira and @djui for their contributions to this release.
|
||||
[#577]: https://github.com/uber-go/zap/pull/577
|
||||
[#574]: https://github.com/uber-go/zap/pull/574
|
||||
|
||||
## v1.7.1 (25 Sep 2017)
|
||||
## 1.7.1 (25 Sep 2017)
|
||||
|
||||
Bugfixes:
|
||||
* [#504][]: Store strings when using AddByteString with the map encoder.
|
||||
|
||||
[#504]: https://github.com/uber-go/zap/pull/504
|
||||
|
||||
## v1.7.0 (21 Sep 2017)
|
||||
## 1.7.0 (21 Sep 2017)
|
||||
|
||||
Enhancements:
|
||||
|
||||
@ -407,7 +423,7 @@ Enhancements:
|
||||
|
||||
[#487]: https://github.com/uber-go/zap/pull/487
|
||||
|
||||
## v1.6.0 (30 Aug 2017)
|
||||
## 1.6.0 (30 Aug 2017)
|
||||
|
||||
Enhancements:
|
||||
|
||||
@ -418,7 +434,7 @@ Enhancements:
|
||||
[#490]: https://github.com/uber-go/zap/pull/490
|
||||
[#491]: https://github.com/uber-go/zap/pull/491
|
||||
|
||||
## v1.5.0 (22 Jul 2017)
|
||||
## 1.5.0 (22 Jul 2017)
|
||||
|
||||
Enhancements:
|
||||
|
||||
@ -436,7 +452,7 @@ Thanks to @richard-tunein and @pavius for their contributions to this release.
|
||||
[#460]: https://github.com/uber-go/zap/pull/460
|
||||
[#470]: https://github.com/uber-go/zap/pull/470
|
||||
|
||||
## v1.4.1 (08 Jun 2017)
|
||||
## 1.4.1 (08 Jun 2017)
|
||||
|
||||
This release fixes two bugs.
|
||||
|
||||
@ -448,7 +464,7 @@ Bugfixes:
|
||||
[#435]: https://github.com/uber-go/zap/pull/435
|
||||
[#444]: https://github.com/uber-go/zap/pull/444
|
||||
|
||||
## v1.4.0 (12 May 2017)
|
||||
## 1.4.0 (12 May 2017)
|
||||
|
||||
This release adds a few small features and is fully backward-compatible.
|
||||
|
||||
@ -464,7 +480,7 @@ Enhancements:
|
||||
[#425]: https://github.com/uber-go/zap/pull/425
|
||||
[#431]: https://github.com/uber-go/zap/pull/431
|
||||
|
||||
## v1.3.0 (25 Apr 2017)
|
||||
## 1.3.0 (25 Apr 2017)
|
||||
|
||||
This release adds an enhancement to zap's testing helpers as well as the
|
||||
ability to marshal an AtomicLevel. It is fully backward-compatible.
|
||||
@ -478,7 +494,7 @@ Enhancements:
|
||||
[#415]: https://github.com/uber-go/zap/pull/415
|
||||
[#416]: https://github.com/uber-go/zap/pull/416
|
||||
|
||||
## v1.2.0 (13 Apr 2017)
|
||||
## 1.2.0 (13 Apr 2017)
|
||||
|
||||
This release adds a gRPC compatibility wrapper. It is fully backward-compatible.
|
||||
|
||||
@ -489,7 +505,7 @@ Enhancements:
|
||||
|
||||
[#402]: https://github.com/uber-go/zap/pull/402
|
||||
|
||||
## v1.1.0 (31 Mar 2017)
|
||||
## 1.1.0 (31 Mar 2017)
|
||||
|
||||
This release fixes two bugs and adds some enhancements to zap's testing helpers.
|
||||
It is fully backward-compatible.
|
||||
@ -510,7 +526,7 @@ Thanks to @moitias for contributing to this release.
|
||||
[#396]: https://github.com/uber-go/zap/pull/396
|
||||
[#386]: https://github.com/uber-go/zap/pull/386
|
||||
|
||||
## v1.0.0 (14 Mar 2017)
|
||||
## 1.0.0 (14 Mar 2017)
|
||||
|
||||
This is zap's first stable release. All exported APIs are now final, and no
|
||||
further breaking changes will be made in the 1.x release series. Anyone using a
|
||||
@ -569,7 +585,7 @@ contributions to this release.
|
||||
[#365]: https://github.com/uber-go/zap/pull/365
|
||||
[#372]: https://github.com/uber-go/zap/pull/372
|
||||
|
||||
## v1.0.0-rc.3 (7 Mar 2017)
|
||||
## 1.0.0-rc.3 (7 Mar 2017)
|
||||
|
||||
This is the third release candidate for zap's stable release. There are no
|
||||
breaking changes.
|
||||
@ -595,7 +611,7 @@ Thanks to @ansel1 and @suyash for their contributions to this release.
|
||||
[#353]: https://github.com/uber-go/zap/pull/353
|
||||
[#311]: https://github.com/uber-go/zap/pull/311
|
||||
|
||||
## v1.0.0-rc.2 (21 Feb 2017)
|
||||
## 1.0.0-rc.2 (21 Feb 2017)
|
||||
|
||||
This is the second release candidate for zap's stable release. It includes two
|
||||
breaking changes.
|
||||
@ -641,7 +657,7 @@ Thanks to @skipor and @chapsuk for their contributions to this release.
|
||||
[#326]: https://github.com/uber-go/zap/pull/326
|
||||
[#300]: https://github.com/uber-go/zap/pull/300
|
||||
|
||||
## v1.0.0-rc.1 (14 Feb 2017)
|
||||
## 1.0.0-rc.1 (14 Feb 2017)
|
||||
|
||||
This is the first release candidate for zap's stable release. There are multiple
|
||||
breaking changes and improvements from the pre-release version. Most notably:
|
||||
@ -661,7 +677,7 @@ breaking changes and improvements from the pre-release version. Most notably:
|
||||
* Sampling is more accurate, and doesn't depend on the standard library's shared
|
||||
timer heap.
|
||||
|
||||
## v0.1.0-beta.1 (6 Feb 2017)
|
||||
## 0.1.0-beta.1 (6 Feb 2017)
|
||||
|
||||
This is a minor version, tagged to allow users to pin to the pre-1.0 APIs and
|
||||
upgrade at their leisure. Since this is the first tagged release, there are no
|
||||
|
0
vendor/go.uber.org/zap/LICENSE.txt → vendor/go.uber.org/zap/LICENSE
generated
vendored
0
vendor/go.uber.org/zap/LICENSE.txt → vendor/go.uber.org/zap/LICENSE
generated
vendored
66
vendor/go.uber.org/zap/README.md
generated
vendored
66
vendor/go.uber.org/zap/README.md
generated
vendored
@ -1,7 +1,16 @@
|
||||
# :zap: zap [![GoDoc][doc-img]][doc] [![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov]
|
||||
# :zap: zap
|
||||
|
||||
|
||||
<div align="center">
|
||||
|
||||
Blazing fast, structured, leveled logging in Go.
|
||||
|
||||
![Zap logo](assets/logo.png)
|
||||
|
||||
[![GoDoc][doc-img]][doc] [![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov]
|
||||
|
||||
</div>
|
||||
|
||||
## Installation
|
||||
|
||||
`go get -u go.uber.org/zap`
|
||||
@ -66,41 +75,44 @@ Log a message and 10 fields:
|
||||
|
||||
| Package | Time | Time % to zap | Objects Allocated |
|
||||
| :------ | :--: | :-----------: | :---------------: |
|
||||
| :zap: zap | 1744 ns/op | +0% | 5 allocs/op
|
||||
| :zap: zap (sugared) | 2483 ns/op | +42% | 10 allocs/op
|
||||
| zerolog | 918 ns/op | -47% | 1 allocs/op
|
||||
| go-kit | 5590 ns/op | +221% | 57 allocs/op
|
||||
| slog | 5640 ns/op | +223% | 40 allocs/op
|
||||
| apex/log | 21184 ns/op | +1115% | 63 allocs/op
|
||||
| logrus | 24338 ns/op | +1296% | 79 allocs/op
|
||||
| log15 | 26054 ns/op | +1394% | 74 allocs/op
|
||||
| :zap: zap | 656 ns/op | +0% | 5 allocs/op
|
||||
| :zap: zap (sugared) | 935 ns/op | +43% | 10 allocs/op
|
||||
| zerolog | 380 ns/op | -42% | 1 allocs/op
|
||||
| go-kit | 2249 ns/op | +243% | 57 allocs/op
|
||||
| slog (LogAttrs) | 2479 ns/op | +278% | 40 allocs/op
|
||||
| slog | 2481 ns/op | +278% | 42 allocs/op
|
||||
| apex/log | 9591 ns/op | +1362% | 63 allocs/op
|
||||
| log15 | 11393 ns/op | +1637% | 75 allocs/op
|
||||
| logrus | 11654 ns/op | +1677% | 79 allocs/op
|
||||
|
||||
Log a message with a logger that already has 10 fields of context:
|
||||
|
||||
| Package | Time | Time % to zap | Objects Allocated |
|
||||
| :------ | :--: | :-----------: | :---------------: |
|
||||
| :zap: zap | 193 ns/op | +0% | 0 allocs/op
|
||||
| :zap: zap (sugared) | 227 ns/op | +18% | 1 allocs/op
|
||||
| zerolog | 81 ns/op | -58% | 0 allocs/op
|
||||
| slog | 322 ns/op | +67% | 0 allocs/op
|
||||
| go-kit | 5377 ns/op | +2686% | 56 allocs/op
|
||||
| apex/log | 19518 ns/op | +10013% | 53 allocs/op
|
||||
| log15 | 19812 ns/op | +10165% | 70 allocs/op
|
||||
| logrus | 21997 ns/op | +11297% | 68 allocs/op
|
||||
| :zap: zap | 67 ns/op | +0% | 0 allocs/op
|
||||
| :zap: zap (sugared) | 84 ns/op | +25% | 1 allocs/op
|
||||
| zerolog | 35 ns/op | -48% | 0 allocs/op
|
||||
| slog | 193 ns/op | +188% | 0 allocs/op
|
||||
| slog (LogAttrs) | 200 ns/op | +199% | 0 allocs/op
|
||||
| go-kit | 2460 ns/op | +3572% | 56 allocs/op
|
||||
| log15 | 9038 ns/op | +13390% | 70 allocs/op
|
||||
| apex/log | 9068 ns/op | +13434% | 53 allocs/op
|
||||
| logrus | 10521 ns/op | +15603% | 68 allocs/op
|
||||
|
||||
Log a static string, without any context or `printf`-style templating:
|
||||
|
||||
| Package | Time | Time % to zap | Objects Allocated |
|
||||
| :------ | :--: | :-----------: | :---------------: |
|
||||
| :zap: zap | 165 ns/op | +0% | 0 allocs/op
|
||||
| :zap: zap (sugared) | 212 ns/op | +28% | 1 allocs/op
|
||||
| zerolog | 95 ns/op | -42% | 0 allocs/op
|
||||
| slog | 296 ns/op | +79% | 0 allocs/op
|
||||
| go-kit | 415 ns/op | +152% | 9 allocs/op
|
||||
| standard library | 422 ns/op | +156% | 2 allocs/op
|
||||
| apex/log | 1601 ns/op | +870% | 5 allocs/op
|
||||
| logrus | 3017 ns/op | +1728% | 23 allocs/op
|
||||
| log15 | 3469 ns/op | +2002% | 20 allocs/op
|
||||
| :zap: zap | 63 ns/op | +0% | 0 allocs/op
|
||||
| :zap: zap (sugared) | 81 ns/op | +29% | 1 allocs/op
|
||||
| zerolog | 32 ns/op | -49% | 0 allocs/op
|
||||
| standard library | 124 ns/op | +97% | 1 allocs/op
|
||||
| slog | 196 ns/op | +211% | 0 allocs/op
|
||||
| slog (LogAttrs) | 200 ns/op | +217% | 0 allocs/op
|
||||
| go-kit | 213 ns/op | +238% | 9 allocs/op
|
||||
| apex/log | 771 ns/op | +1124% | 5 allocs/op
|
||||
| logrus | 1439 ns/op | +2184% | 23 allocs/op
|
||||
| log15 | 2069 ns/op | +3184% | 20 allocs/op
|
||||
|
||||
## Development Status: Stable
|
||||
|
||||
@ -120,7 +132,7 @@ standard.
|
||||
|
||||
<hr>
|
||||
|
||||
Released under the [MIT License](LICENSE.txt).
|
||||
Released under the [MIT License](LICENSE).
|
||||
|
||||
<sup id="footnote-versions">1</sup> In particular, keep in mind that we may be
|
||||
benchmarking against slightly older versions of other packages. Versions are
|
||||
|
2
vendor/go.uber.org/zap/buffer/buffer.go
generated
vendored
2
vendor/go.uber.org/zap/buffer/buffer.go
generated
vendored
@ -42,7 +42,7 @@ func (b *Buffer) AppendByte(v byte) {
|
||||
b.bs = append(b.bs, v)
|
||||
}
|
||||
|
||||
// AppendBytes writes a single byte to the Buffer.
|
||||
// AppendBytes writes the given slice of bytes to the Buffer.
|
||||
func (b *Buffer) AppendBytes(v []byte) {
|
||||
b.bs = append(b.bs, v...)
|
||||
}
|
||||
|
2
vendor/go.uber.org/zap/field.go
generated
vendored
2
vendor/go.uber.org/zap/field.go
generated
vendored
@ -460,6 +460,8 @@ func (d dictObject) MarshalLogObject(enc zapcore.ObjectEncoder) error {
|
||||
// - https://github.com/uber-go/zap/pull/1304
|
||||
// - https://github.com/uber-go/zap/pull/1305
|
||||
// - https://github.com/uber-go/zap/pull/1308
|
||||
//
|
||||
// See https://github.com/golang/go/issues/62077 for upstream issue.
|
||||
type anyFieldC[T any] func(string, T) Field
|
||||
|
||||
func (f anyFieldC[T]) Any(key string, val any) Field {
|
||||
|
39
vendor/go.uber.org/zap/logger.go
generated
vendored
39
vendor/go.uber.org/zap/logger.go
generated
vendored
@ -43,6 +43,7 @@ type Logger struct {
|
||||
|
||||
development bool
|
||||
addCaller bool
|
||||
onPanic zapcore.CheckWriteHook // default is WriteThenPanic
|
||||
onFatal zapcore.CheckWriteHook // default is WriteThenFatal
|
||||
|
||||
name string
|
||||
@ -345,27 +346,12 @@ func (log *Logger) check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry {
|
||||
// Set up any required terminal behavior.
|
||||
switch ent.Level {
|
||||
case zapcore.PanicLevel:
|
||||
ce = ce.After(ent, zapcore.WriteThenPanic)
|
||||
ce = ce.After(ent, terminalHookOverride(zapcore.WriteThenPanic, log.onPanic))
|
||||
case zapcore.FatalLevel:
|
||||
onFatal := log.onFatal
|
||||
// nil or WriteThenNoop will lead to continued execution after
|
||||
// a Fatal log entry, which is unexpected. For example,
|
||||
//
|
||||
// f, err := os.Open(..)
|
||||
// if err != nil {
|
||||
// log.Fatal("cannot open", zap.Error(err))
|
||||
// }
|
||||
// fmt.Println(f.Name())
|
||||
//
|
||||
// The f.Name() will panic if we continue execution after the
|
||||
// log.Fatal.
|
||||
if onFatal == nil || onFatal == zapcore.WriteThenNoop {
|
||||
onFatal = zapcore.WriteThenFatal
|
||||
}
|
||||
ce = ce.After(ent, onFatal)
|
||||
ce = ce.After(ent, terminalHookOverride(zapcore.WriteThenFatal, log.onFatal))
|
||||
case zapcore.DPanicLevel:
|
||||
if log.development {
|
||||
ce = ce.After(ent, zapcore.WriteThenPanic)
|
||||
ce = ce.After(ent, terminalHookOverride(zapcore.WriteThenPanic, log.onPanic))
|
||||
}
|
||||
}
|
||||
|
||||
@ -430,3 +416,20 @@ func (log *Logger) check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry {
|
||||
|
||||
return ce
|
||||
}
|
||||
|
||||
func terminalHookOverride(defaultHook, override zapcore.CheckWriteHook) zapcore.CheckWriteHook {
|
||||
// A nil or WriteThenNoop hook will lead to continued execution after
|
||||
// a Panic or Fatal log entry, which is unexpected. For example,
|
||||
//
|
||||
// f, err := os.Open(..)
|
||||
// if err != nil {
|
||||
// log.Fatal("cannot open", zap.Error(err))
|
||||
// }
|
||||
// fmt.Println(f.Name())
|
||||
//
|
||||
// The f.Name() will panic if we continue execution after the log.Fatal.
|
||||
if override == nil || override == zapcore.WriteThenNoop {
|
||||
return defaultHook
|
||||
}
|
||||
return override
|
||||
}
|
||||
|
15
vendor/go.uber.org/zap/options.go
generated
vendored
15
vendor/go.uber.org/zap/options.go
generated
vendored
@ -132,6 +132,21 @@ func IncreaseLevel(lvl zapcore.LevelEnabler) Option {
|
||||
})
|
||||
}
|
||||
|
||||
// WithPanicHook sets a CheckWriteHook to run on Panic/DPanic logs.
|
||||
// Zap will call this hook after writing a log statement with a Panic/DPanic level.
|
||||
//
|
||||
// For example, the following builds a logger that will exit the current
|
||||
// goroutine after writing a Panic/DPanic log message, but it will not start a panic.
|
||||
//
|
||||
// zap.New(core, zap.WithPanicHook(zapcore.WriteThenGoexit))
|
||||
//
|
||||
// This is useful for testing Panic/DPanic log output.
|
||||
func WithPanicHook(hook zapcore.CheckWriteHook) Option {
|
||||
return optionFunc(func(log *Logger) {
|
||||
log.onPanic = hook
|
||||
})
|
||||
}
|
||||
|
||||
// OnFatal sets the action to take on fatal logs.
|
||||
//
|
||||
// Deprecated: Use [WithFatalHook] instead.
|
||||
|
39
vendor/go.uber.org/zap/sugar.go
generated
vendored
39
vendor/go.uber.org/zap/sugar.go
generated
vendored
@ -115,6 +115,21 @@ func (s *SugaredLogger) With(args ...interface{}) *SugaredLogger {
|
||||
return &SugaredLogger{base: s.base.With(s.sweetenFields(args)...)}
|
||||
}
|
||||
|
||||
// WithLazy adds a variadic number of fields to the logging context lazily.
|
||||
// The fields are evaluated only if the logger is further chained with [With]
|
||||
// or is written to with any of the log level methods.
|
||||
// Until that occurs, the logger may retain references to objects inside the fields,
|
||||
// and logging will reflect the state of an object at the time of logging,
|
||||
// not the time of WithLazy().
|
||||
//
|
||||
// Similar to [With], fields added to the child don't affect the parent,
|
||||
// and vice versa. Also, the keys in key-value pairs should be strings. In development,
|
||||
// passing a non-string key panics, while in production it logs an error and skips the pair.
|
||||
// Passing an orphaned key has the same behavior.
|
||||
func (s *SugaredLogger) WithLazy(args ...interface{}) *SugaredLogger {
|
||||
return &SugaredLogger{base: s.base.WithLazy(s.sweetenFields(args)...)}
|
||||
}
|
||||
|
||||
// Level reports the minimum enabled level for this logger.
|
||||
//
|
||||
// For NopLoggers, this is [zapcore.InvalidLevel].
|
||||
@ -122,6 +137,12 @@ func (s *SugaredLogger) Level() zapcore.Level {
|
||||
return zapcore.LevelOf(s.base.core)
|
||||
}
|
||||
|
||||
// Log logs the provided arguments at provided level.
|
||||
// Spaces are added between arguments when neither is a string.
|
||||
func (s *SugaredLogger) Log(lvl zapcore.Level, args ...interface{}) {
|
||||
s.log(lvl, "", args, nil)
|
||||
}
|
||||
|
||||
// Debug logs the provided arguments at [DebugLevel].
|
||||
// Spaces are added between arguments when neither is a string.
|
||||
func (s *SugaredLogger) Debug(args ...interface{}) {
|
||||
@ -165,6 +186,12 @@ func (s *SugaredLogger) Fatal(args ...interface{}) {
|
||||
s.log(FatalLevel, "", args, nil)
|
||||
}
|
||||
|
||||
// Logf formats the message according to the format specifier
|
||||
// and logs it at provided level.
|
||||
func (s *SugaredLogger) Logf(lvl zapcore.Level, template string, args ...interface{}) {
|
||||
s.log(lvl, template, args, nil)
|
||||
}
|
||||
|
||||
// Debugf formats the message according to the format specifier
|
||||
// and logs it at [DebugLevel].
|
||||
func (s *SugaredLogger) Debugf(template string, args ...interface{}) {
|
||||
@ -208,6 +235,12 @@ func (s *SugaredLogger) Fatalf(template string, args ...interface{}) {
|
||||
s.log(FatalLevel, template, args, nil)
|
||||
}
|
||||
|
||||
// Logw logs a message with some additional context. The variadic key-value
|
||||
// pairs are treated as they are in With.
|
||||
func (s *SugaredLogger) Logw(lvl zapcore.Level, msg string, keysAndValues ...interface{}) {
|
||||
s.log(lvl, msg, nil, keysAndValues)
|
||||
}
|
||||
|
||||
// Debugw logs a message with some additional context. The variadic key-value
|
||||
// pairs are treated as they are in With.
|
||||
//
|
||||
@ -255,6 +288,12 @@ func (s *SugaredLogger) Fatalw(msg string, keysAndValues ...interface{}) {
|
||||
s.log(FatalLevel, msg, nil, keysAndValues)
|
||||
}
|
||||
|
||||
// Logln logs a message at provided level.
|
||||
// Spaces are always added between arguments.
|
||||
func (s *SugaredLogger) Logln(lvl zapcore.Level, args ...interface{}) {
|
||||
s.logln(lvl, args, nil)
|
||||
}
|
||||
|
||||
// Debugln logs a message at [DebugLevel].
|
||||
// Spaces are always added between arguments.
|
||||
func (s *SugaredLogger) Debugln(args ...interface{}) {
|
||||
|
2
vendor/go.uber.org/zap/zapcore/console_encoder.go
generated
vendored
2
vendor/go.uber.org/zap/zapcore/console_encoder.go
generated
vendored
@ -77,7 +77,7 @@ func (c consoleEncoder) EncodeEntry(ent Entry, fields []Field) (*buffer.Buffer,
|
||||
// If this ever becomes a performance bottleneck, we can implement
|
||||
// ArrayEncoder for our plain-text format.
|
||||
arr := getSliceEncoder()
|
||||
if c.TimeKey != "" && c.EncodeTime != nil {
|
||||
if c.TimeKey != "" && c.EncodeTime != nil && !ent.Time.IsZero() {
|
||||
c.EncodeTime(ent.Time, arr)
|
||||
}
|
||||
if c.LevelKey != "" && c.EncodeLevel != nil {
|
||||
|
15
vendor/go.uber.org/zap/zapcore/encoder.go
generated
vendored
15
vendor/go.uber.org/zap/zapcore/encoder.go
generated
vendored
@ -37,6 +37,9 @@ const DefaultLineEnding = "\n"
|
||||
const OmitKey = ""
|
||||
|
||||
// A LevelEncoder serializes a Level to a primitive type.
|
||||
//
|
||||
// This function must make exactly one call
|
||||
// to a PrimitiveArrayEncoder's Append* method.
|
||||
type LevelEncoder func(Level, PrimitiveArrayEncoder)
|
||||
|
||||
// LowercaseLevelEncoder serializes a Level to a lowercase string. For example,
|
||||
@ -90,6 +93,9 @@ func (e *LevelEncoder) UnmarshalText(text []byte) error {
|
||||
}
|
||||
|
||||
// A TimeEncoder serializes a time.Time to a primitive type.
|
||||
//
|
||||
// This function must make exactly one call
|
||||
// to a PrimitiveArrayEncoder's Append* method.
|
||||
type TimeEncoder func(time.Time, PrimitiveArrayEncoder)
|
||||
|
||||
// EpochTimeEncoder serializes a time.Time to a floating-point number of seconds
|
||||
@ -219,6 +225,9 @@ func (e *TimeEncoder) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
// A DurationEncoder serializes a time.Duration to a primitive type.
|
||||
//
|
||||
// This function must make exactly one call
|
||||
// to a PrimitiveArrayEncoder's Append* method.
|
||||
type DurationEncoder func(time.Duration, PrimitiveArrayEncoder)
|
||||
|
||||
// SecondsDurationEncoder serializes a time.Duration to a floating-point number of seconds elapsed.
|
||||
@ -262,6 +271,9 @@ func (e *DurationEncoder) UnmarshalText(text []byte) error {
|
||||
}
|
||||
|
||||
// A CallerEncoder serializes an EntryCaller to a primitive type.
|
||||
//
|
||||
// This function must make exactly one call
|
||||
// to a PrimitiveArrayEncoder's Append* method.
|
||||
type CallerEncoder func(EntryCaller, PrimitiveArrayEncoder)
|
||||
|
||||
// FullCallerEncoder serializes a caller in /full/path/to/package/file:line
|
||||
@ -292,6 +304,9 @@ func (e *CallerEncoder) UnmarshalText(text []byte) error {
|
||||
|
||||
// A NameEncoder serializes a period-separated logger name to a primitive
|
||||
// type.
|
||||
//
|
||||
// This function must make exactly one call
|
||||
// to a PrimitiveArrayEncoder's Append* method.
|
||||
type NameEncoder func(string, PrimitiveArrayEncoder)
|
||||
|
||||
// FullNameEncoder serializes the logger name as-is.
|
||||
|
2
vendor/go.uber.org/zap/zapcore/field.go
generated
vendored
2
vendor/go.uber.org/zap/zapcore/field.go
generated
vendored
@ -47,7 +47,7 @@ const (
|
||||
ByteStringType
|
||||
// Complex128Type indicates that the field carries a complex128.
|
||||
Complex128Type
|
||||
// Complex64Type indicates that the field carries a complex128.
|
||||
// Complex64Type indicates that the field carries a complex64.
|
||||
Complex64Type
|
||||
// DurationType indicates that the field carries a time.Duration.
|
||||
DurationType
|
||||
|
2
vendor/go.uber.org/zap/zapcore/json_encoder.go
generated
vendored
2
vendor/go.uber.org/zap/zapcore/json_encoder.go
generated
vendored
@ -372,7 +372,7 @@ func (enc *jsonEncoder) EncodeEntry(ent Entry, fields []Field) (*buffer.Buffer,
|
||||
final.AppendString(ent.Level.String())
|
||||
}
|
||||
}
|
||||
if final.TimeKey != "" {
|
||||
if final.TimeKey != "" && !ent.Time.IsZero() {
|
||||
final.AddTime(final.TimeKey, ent.Time)
|
||||
}
|
||||
if ent.LoggerName != "" && final.NameKey != "" {
|
||||
|
18
vendor/go.uber.org/zap/zapgrpc/zapgrpc.go
generated
vendored
18
vendor/go.uber.org/zap/zapgrpc/zapgrpc.go
generated
vendored
@ -36,16 +36,14 @@ const (
|
||||
grpcLvlFatal
|
||||
)
|
||||
|
||||
var (
|
||||
// _grpcToZapLevel maps gRPC log levels to zap log levels.
|
||||
// See https://pkg.go.dev/go.uber.org/zap@v1.16.0/zapcore#Level
|
||||
_grpcToZapLevel = map[int]zapcore.Level{
|
||||
grpcLvlInfo: zapcore.InfoLevel,
|
||||
grpcLvlWarn: zapcore.WarnLevel,
|
||||
grpcLvlError: zapcore.ErrorLevel,
|
||||
grpcLvlFatal: zapcore.FatalLevel,
|
||||
}
|
||||
)
|
||||
// _grpcToZapLevel maps gRPC log levels to zap log levels.
|
||||
// See https://pkg.go.dev/go.uber.org/zap@v1.16.0/zapcore#Level
|
||||
var _grpcToZapLevel = map[int]zapcore.Level{
|
||||
grpcLvlInfo: zapcore.InfoLevel,
|
||||
grpcLvlWarn: zapcore.WarnLevel,
|
||||
grpcLvlError: zapcore.ErrorLevel,
|
||||
grpcLvlFatal: zapcore.FatalLevel,
|
||||
}
|
||||
|
||||
// An Option overrides a Logger's default configuration.
|
||||
type Option interface {
|
||||
|
6
vendor/modules.txt
vendored
6
vendor/modules.txt
vendored
@ -235,6 +235,9 @@ github.com/coreos/go-semver/semver
|
||||
## explicit; go 1.12
|
||||
github.com/coreos/go-systemd/v22/daemon
|
||||
github.com/coreos/go-systemd/v22/journal
|
||||
# github.com/csi-addons/kubernetes-csi-addons v0.9.0
|
||||
## explicit; go 1.22.0
|
||||
github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1
|
||||
# github.com/csi-addons/spec v0.2.1-0.20241104111131-27825f744db5
|
||||
## explicit
|
||||
github.com/csi-addons/spec/lib/go/encryptionkeyrotation
|
||||
@ -714,7 +717,7 @@ go.opentelemetry.io/proto/otlp/trace/v1
|
||||
# go.uber.org/multierr v1.11.0
|
||||
## explicit; go 1.19
|
||||
go.uber.org/multierr
|
||||
# go.uber.org/zap v1.26.0
|
||||
# go.uber.org/zap v1.27.0
|
||||
## explicit; go 1.19
|
||||
go.uber.org/zap
|
||||
go.uber.org/zap/buffer
|
||||
@ -1813,6 +1816,7 @@ sigs.k8s.io/controller-runtime/pkg/metrics/server
|
||||
sigs.k8s.io/controller-runtime/pkg/predicate
|
||||
sigs.k8s.io/controller-runtime/pkg/reconcile
|
||||
sigs.k8s.io/controller-runtime/pkg/recorder
|
||||
sigs.k8s.io/controller-runtime/pkg/scheme
|
||||
sigs.k8s.io/controller-runtime/pkg/source
|
||||
sigs.k8s.io/controller-runtime/pkg/webhook
|
||||
sigs.k8s.io/controller-runtime/pkg/webhook/admission
|
||||
|
93
vendor/sigs.k8s.io/controller-runtime/pkg/scheme/scheme.go
generated
vendored
Normal file
93
vendor/sigs.k8s.io/controller-runtime/pkg/scheme/scheme.go
generated
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
Copyright 2018 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 scheme contains utilities for gradually building Schemes,
|
||||
// which contain information associating Go types with Kubernetes
|
||||
// groups, versions, and kinds.
|
||||
//
|
||||
// Each API group should define a utility function
|
||||
// called AddToScheme for adding its types to a Scheme:
|
||||
//
|
||||
// // in package myapigroupv1...
|
||||
// var (
|
||||
// SchemeGroupVersion = schema.GroupVersion{Group: "my.api.group", Version: "v1"}
|
||||
// SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
|
||||
// AddToScheme = SchemeBuilder.AddToScheme
|
||||
// )
|
||||
//
|
||||
// func init() {
|
||||
// SchemeBuilder.Register(&MyType{}, &MyTypeList)
|
||||
// }
|
||||
// var (
|
||||
// scheme *runtime.Scheme = runtime.NewScheme()
|
||||
// )
|
||||
//
|
||||
// This also true of the built-in Kubernetes types. Then, in the entrypoint for
|
||||
// your manager, assemble the scheme containing exactly the types you need,
|
||||
// panicing if scheme registration failed. For instance, if our controller needs
|
||||
// types from the core/v1 API group (e.g. Pod), plus types from my.api.group/v1:
|
||||
//
|
||||
// func init() {
|
||||
// utilruntime.Must(myapigroupv1.AddToScheme(scheme))
|
||||
// utilruntime.Must(kubernetesscheme.AddToScheme(scheme))
|
||||
// }
|
||||
//
|
||||
// func main() {
|
||||
// mgr := controllers.NewManager(context.Background(), controllers.GetConfigOrDie(), manager.Options{
|
||||
// Scheme: scheme,
|
||||
// })
|
||||
// // ...
|
||||
// }
|
||||
package scheme
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
// Builder builds a new Scheme for mapping go types to Kubernetes GroupVersionKinds.
|
||||
type Builder struct {
|
||||
GroupVersion schema.GroupVersion
|
||||
runtime.SchemeBuilder
|
||||
}
|
||||
|
||||
// Register adds one or more objects to the SchemeBuilder so they can be added to a Scheme. Register mutates bld.
|
||||
func (bld *Builder) Register(object ...runtime.Object) *Builder {
|
||||
bld.SchemeBuilder.Register(func(scheme *runtime.Scheme) error {
|
||||
scheme.AddKnownTypes(bld.GroupVersion, object...)
|
||||
metav1.AddToGroupVersion(scheme, bld.GroupVersion)
|
||||
return nil
|
||||
})
|
||||
return bld
|
||||
}
|
||||
|
||||
// RegisterAll registers all types from the Builder argument. RegisterAll mutates bld.
|
||||
func (bld *Builder) RegisterAll(b *Builder) *Builder {
|
||||
bld.SchemeBuilder = append(bld.SchemeBuilder, b.SchemeBuilder...)
|
||||
return bld
|
||||
}
|
||||
|
||||
// AddToScheme adds all registered types to s.
|
||||
func (bld *Builder) AddToScheme(s *runtime.Scheme) error {
|
||||
return bld.SchemeBuilder.AddToScheme(s)
|
||||
}
|
||||
|
||||
// Build returns a new Scheme containing the registered types.
|
||||
func (bld *Builder) Build() (*runtime.Scheme, error) {
|
||||
s := runtime.NewScheme()
|
||||
return s, bld.AddToScheme(s)
|
||||
}
|
Loading…
Reference in New Issue
Block a user