mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-25 17:34:17 +00:00
Merge branch 'main' into uploader-flush-buffer
This commit is contained in:
@@ -115,7 +115,11 @@ var (
|
||||
"datauploads.velero.io",
|
||||
"persistentvolumes",
|
||||
"persistentvolumeclaims",
|
||||
"clusterroles",
|
||||
"roles",
|
||||
"serviceaccounts",
|
||||
"clusterrolebindings",
|
||||
"rolebindings",
|
||||
"secrets",
|
||||
"configmaps",
|
||||
"limitranges",
|
||||
|
||||
@@ -292,8 +292,14 @@ func (r *DataDownloadReconciler) Reconcile(ctx context.Context, req ctrl.Request
|
||||
return ctrl.Result{}, nil
|
||||
} else if dd.Status.Phase == velerov2alpha1api.DataDownloadPhaseAccepted {
|
||||
if peekErr := r.restoreExposer.PeekExposed(ctx, getDataDownloadOwnerObject(dd)); peekErr != nil {
|
||||
r.tryCancelDataDownload(ctx, dd, fmt.Sprintf("found a datadownload %s/%s with expose error: %s. mark it as cancel", dd.Namespace, dd.Name, peekErr))
|
||||
log.Errorf("Cancel dd %s/%s because of expose error %s", dd.Namespace, dd.Name, peekErr)
|
||||
|
||||
diags := strings.Split(r.restoreExposer.DiagnoseExpose(ctx, getDataDownloadOwnerObject(dd)), "\n")
|
||||
for _, diag := range diags {
|
||||
log.Warnf("[Diagnose DD expose]%s", diag)
|
||||
}
|
||||
|
||||
r.tryCancelDataDownload(ctx, dd, fmt.Sprintf("found a datadownload %s/%s with expose error: %s. mark it as cancel", dd.Namespace, dd.Name, peekErr))
|
||||
} else if dd.Status.AcceptedTimestamp != nil {
|
||||
if time.Since(dd.Status.AcceptedTimestamp.Time) >= r.preparingTimeout {
|
||||
r.onPrepareTimeout(ctx, dd)
|
||||
@@ -918,7 +924,7 @@ func (r *DataDownloadReconciler) setupExposeParam(dd *velerov2alpha1api.DataDown
|
||||
cacheVolume = &exposer.CacheConfigs{
|
||||
Limit: limit,
|
||||
StorageClass: r.cacheVolumeConfigs.StorageClass,
|
||||
ResidentThreshold: r.cacheVolumeConfigs.ResidentThreshold,
|
||||
ResidentThreshold: r.cacheVolumeConfigs.ResidentThresholdInMB << 20,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -561,6 +561,7 @@ func TestDataDownloadReconcile(t *testing.T) {
|
||||
ep.On("GetExposed", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil, nil)
|
||||
} else if test.isPeekExposeErr {
|
||||
ep.On("PeekExposed", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(errors.New("fake-peek-error"))
|
||||
ep.On("DiagnoseExpose", mock.Anything, mock.Anything).Return("")
|
||||
}
|
||||
|
||||
if !test.notMockCleanUp {
|
||||
|
||||
@@ -298,8 +298,14 @@ func (r *DataUploadReconciler) Reconcile(ctx context.Context, req ctrl.Request)
|
||||
return ctrl.Result{}, nil
|
||||
} else if du.Status.Phase == velerov2alpha1api.DataUploadPhaseAccepted {
|
||||
if peekErr := ep.PeekExposed(ctx, getOwnerObject(du)); peekErr != nil {
|
||||
r.tryCancelDataUpload(ctx, du, fmt.Sprintf("found a du %s/%s with expose error: %s. mark it as cancel", du.Namespace, du.Name, peekErr))
|
||||
log.Errorf("Cancel du %s/%s because of expose error %s", du.Namespace, du.Name, peekErr)
|
||||
|
||||
diags := strings.Split(ep.DiagnoseExpose(ctx, getOwnerObject(du)), "\n")
|
||||
for _, diag := range diags {
|
||||
log.Warnf("[Diagnose DU expose]%s", diag)
|
||||
}
|
||||
|
||||
r.tryCancelDataUpload(ctx, du, fmt.Sprintf("found a du %s/%s with expose error: %s. mark it as cancel", du.Namespace, du.Name, peekErr))
|
||||
} else if du.Status.AcceptedTimestamp != nil {
|
||||
if time.Since(du.Status.AcceptedTimestamp.Time) >= r.preparingTimeout {
|
||||
r.onPrepareTimeout(ctx, du)
|
||||
|
||||
@@ -260,6 +260,12 @@ func (r *PodVolumeBackupReconciler) Reconcile(ctx context.Context, req ctrl.Requ
|
||||
} else if pvb.Status.Phase == velerov1api.PodVolumeBackupPhaseAccepted {
|
||||
if peekErr := r.exposer.PeekExposed(ctx, getPVBOwnerObject(pvb)); peekErr != nil {
|
||||
log.Errorf("Cancel PVB %s/%s because of expose error %s", pvb.Namespace, pvb.Name, peekErr)
|
||||
|
||||
diags := strings.Split(r.exposer.DiagnoseExpose(ctx, getPVBOwnerObject(pvb)), "\n")
|
||||
for _, diag := range diags {
|
||||
log.Warnf("[Diagnose PVB expose]%s", diag)
|
||||
}
|
||||
|
||||
r.tryCancelPodVolumeBackup(ctx, pvb, fmt.Sprintf("found a PVB %s/%s with expose error: %s. mark it as cancel", pvb.Namespace, pvb.Name, peekErr))
|
||||
} else if pvb.Status.AcceptedTimestamp != nil {
|
||||
if time.Since(pvb.Status.AcceptedTimestamp.Time) >= r.preparingTimeout {
|
||||
|
||||
@@ -274,6 +274,12 @@ func (r *PodVolumeRestoreReconciler) Reconcile(ctx context.Context, req ctrl.Req
|
||||
} else if pvr.Status.Phase == velerov1api.PodVolumeRestorePhaseAccepted {
|
||||
if peekErr := r.exposer.PeekExposed(ctx, getPVROwnerObject(pvr)); peekErr != nil {
|
||||
log.Errorf("Cancel PVR %s/%s because of expose error %s", pvr.Namespace, pvr.Name, peekErr)
|
||||
|
||||
diags := strings.Split(r.exposer.DiagnoseExpose(ctx, getPVROwnerObject(pvr)), "\n")
|
||||
for _, diag := range diags {
|
||||
log.Warnf("[Diagnose PVR expose]%s", diag)
|
||||
}
|
||||
|
||||
_ = r.tryCancelPodVolumeRestore(ctx, pvr, fmt.Sprintf("found a PVR %s/%s with expose error: %s. mark it as cancel", pvr.Namespace, pvr.Name, peekErr))
|
||||
} else if pvr.Status.AcceptedTimestamp != nil {
|
||||
if time.Since(pvr.Status.AcceptedTimestamp.Time) >= r.preparingTimeout {
|
||||
@@ -934,7 +940,7 @@ func (r *PodVolumeRestoreReconciler) setupExposeParam(pvr *velerov1api.PodVolume
|
||||
cacheVolume = &exposer.CacheConfigs{
|
||||
Limit: limit,
|
||||
StorageClass: r.cacheVolumeConfigs.StorageClass,
|
||||
ResidentThreshold: r.cacheVolumeConfigs.ResidentThreshold,
|
||||
ResidentThreshold: r.cacheVolumeConfigs.ResidentThresholdInMB << 20,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1024,6 +1024,7 @@ func TestPodVolumeRestoreReconcile(t *testing.T) {
|
||||
ep.On("GetExposed", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil, nil)
|
||||
} else if test.isPeekExposeErr {
|
||||
ep.On("PeekExposed", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(errors.New("fake-peek-error"))
|
||||
ep.On("DiagnoseExpose", mock.Anything, mock.Anything).Return("")
|
||||
}
|
||||
|
||||
if !test.notMockCleanUp {
|
||||
|
||||
@@ -259,7 +259,7 @@ func (e *csiSnapshotExposer) Expose(ctx context.Context, ownerObject corev1api.O
|
||||
return errors.Wrap(err, "error to create backup pod")
|
||||
}
|
||||
|
||||
curLog.WithField("pod name", backupPod.Name).WithField("affinity", csiExposeParam.Affinity).Info("Backup pod is created")
|
||||
curLog.WithField("pod name", backupPod.Name).WithField("affinity", affinity).Info("Backup pod is created")
|
||||
|
||||
defer func() {
|
||||
if err != nil {
|
||||
|
||||
@@ -1307,6 +1307,7 @@ func Test_csiSnapshotExposer_DiagnoseExpose(t *testing.T) {
|
||||
Message: "fake-pod-message",
|
||||
},
|
||||
},
|
||||
Message: "fake-pod-message-1",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1501,7 +1502,7 @@ end diagnose CSI exposer`,
|
||||
&backupVSWithoutStatus,
|
||||
},
|
||||
expected: `begin diagnose CSI exposer
|
||||
Pod velero/fake-backup, phase Pending, node name
|
||||
Pod velero/fake-backup, phase Pending, node name , message fake-pod-message-1
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
PVC velero/fake-backup, phase Pending, binding to
|
||||
VS velero/fake-backup, bind to , readyToUse false, errMessage
|
||||
@@ -1518,7 +1519,7 @@ end diagnose CSI exposer`,
|
||||
&backupVSWithoutVSC,
|
||||
},
|
||||
expected: `begin diagnose CSI exposer
|
||||
Pod velero/fake-backup, phase Pending, node name
|
||||
Pod velero/fake-backup, phase Pending, node name , message fake-pod-message-1
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
PVC velero/fake-backup, phase Pending, binding to
|
||||
VS velero/fake-backup, bind to , readyToUse false, errMessage
|
||||
@@ -1535,7 +1536,7 @@ end diagnose CSI exposer`,
|
||||
&backupVSWithoutVSC,
|
||||
},
|
||||
expected: `begin diagnose CSI exposer
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node, message
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
node-agent is not running in node fake-node, err: daemonset pod not found in running state in node fake-node
|
||||
PVC velero/fake-backup, phase Pending, binding to
|
||||
@@ -1554,7 +1555,7 @@ end diagnose CSI exposer`,
|
||||
&backupVSWithoutVSC,
|
||||
},
|
||||
expected: `begin diagnose CSI exposer
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node, message
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
PVC velero/fake-backup, phase Pending, binding to
|
||||
VS velero/fake-backup, bind to , readyToUse false, errMessage
|
||||
@@ -1572,7 +1573,7 @@ end diagnose CSI exposer`,
|
||||
&backupVSWithoutVSC,
|
||||
},
|
||||
expected: `begin diagnose CSI exposer
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node, message
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
PVC velero/fake-backup, phase Pending, binding to fake-pv
|
||||
error getting backup pv fake-pv, err: persistentvolumes "fake-pv" not found
|
||||
@@ -1592,7 +1593,7 @@ end diagnose CSI exposer`,
|
||||
&backupVSWithoutVSC,
|
||||
},
|
||||
expected: `begin diagnose CSI exposer
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node, message
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
PVC velero/fake-backup, phase Pending, binding to fake-pv
|
||||
PV fake-pv, phase Pending, reason , message fake-pv-message
|
||||
@@ -1612,7 +1613,7 @@ end diagnose CSI exposer`,
|
||||
&backupVSWithVSC,
|
||||
},
|
||||
expected: `begin diagnose CSI exposer
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node, message
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
PVC velero/fake-backup, phase Pending, binding to fake-pv
|
||||
PV fake-pv, phase Pending, reason , message fake-pv-message
|
||||
@@ -1634,7 +1635,7 @@ end diagnose CSI exposer`,
|
||||
&backupVSC,
|
||||
},
|
||||
expected: `begin diagnose CSI exposer
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node, message
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
PVC velero/fake-backup, phase Pending, binding to fake-pv
|
||||
PV fake-pv, phase Pending, reason , message fake-pv-message
|
||||
@@ -1698,7 +1699,7 @@ end diagnose CSI exposer`,
|
||||
&backupVSC,
|
||||
},
|
||||
expected: `begin diagnose CSI exposer
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node, message
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
Pod event reason reason-2, message message-2
|
||||
Pod event reason reason-6, message message-6
|
||||
|
||||
@@ -664,6 +664,7 @@ func Test_ReastoreDiagnoseExpose(t *testing.T) {
|
||||
Message: "fake-pod-message",
|
||||
},
|
||||
},
|
||||
Message: "fake-pod-message-1",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -815,7 +816,7 @@ end diagnose restore exposer`,
|
||||
&restorePVCWithoutVolumeName,
|
||||
},
|
||||
expected: `begin diagnose restore exposer
|
||||
Pod velero/fake-restore, phase Pending, node name
|
||||
Pod velero/fake-restore, phase Pending, node name , message fake-pod-message-1
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
PVC velero/fake-restore, phase Pending, binding to
|
||||
end diagnose restore exposer`,
|
||||
@@ -828,7 +829,7 @@ end diagnose restore exposer`,
|
||||
&restorePVCWithoutVolumeName,
|
||||
},
|
||||
expected: `begin diagnose restore exposer
|
||||
Pod velero/fake-restore, phase Pending, node name
|
||||
Pod velero/fake-restore, phase Pending, node name , message fake-pod-message-1
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
PVC velero/fake-restore, phase Pending, binding to
|
||||
end diagnose restore exposer`,
|
||||
@@ -841,7 +842,7 @@ end diagnose restore exposer`,
|
||||
&restorePVCWithoutVolumeName,
|
||||
},
|
||||
expected: `begin diagnose restore exposer
|
||||
Pod velero/fake-restore, phase Pending, node name fake-node
|
||||
Pod velero/fake-restore, phase Pending, node name fake-node, message
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
node-agent is not running in node fake-node, err: daemonset pod not found in running state in node fake-node
|
||||
PVC velero/fake-restore, phase Pending, binding to
|
||||
@@ -856,7 +857,7 @@ end diagnose restore exposer`,
|
||||
&nodeAgentPod,
|
||||
},
|
||||
expected: `begin diagnose restore exposer
|
||||
Pod velero/fake-restore, phase Pending, node name fake-node
|
||||
Pod velero/fake-restore, phase Pending, node name fake-node, message
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
PVC velero/fake-restore, phase Pending, binding to
|
||||
end diagnose restore exposer`,
|
||||
@@ -870,7 +871,7 @@ end diagnose restore exposer`,
|
||||
&nodeAgentPod,
|
||||
},
|
||||
expected: `begin diagnose restore exposer
|
||||
Pod velero/fake-restore, phase Pending, node name fake-node
|
||||
Pod velero/fake-restore, phase Pending, node name fake-node, message
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
PVC velero/fake-restore, phase Pending, binding to fake-pv
|
||||
error getting restore pv fake-pv, err: persistentvolumes "fake-pv" not found
|
||||
@@ -886,7 +887,7 @@ end diagnose restore exposer`,
|
||||
&nodeAgentPod,
|
||||
},
|
||||
expected: `begin diagnose restore exposer
|
||||
Pod velero/fake-restore, phase Pending, node name fake-node
|
||||
Pod velero/fake-restore, phase Pending, node name fake-node, message
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
PVC velero/fake-restore, phase Pending, binding to fake-pv
|
||||
PV fake-pv, phase Pending, reason , message fake-pv-message
|
||||
@@ -902,7 +903,7 @@ end diagnose restore exposer`,
|
||||
&nodeAgentPod,
|
||||
},
|
||||
expected: `begin diagnose restore exposer
|
||||
Pod velero/fake-restore, phase Pending, node name fake-node
|
||||
Pod velero/fake-restore, phase Pending, node name fake-node, message
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
PVC velero/fake-restore, phase Pending, binding to fake-pv
|
||||
error getting restore pv fake-pv, err: persistentvolumes "fake-pv" not found
|
||||
@@ -922,7 +923,7 @@ end diagnose restore exposer`,
|
||||
&nodeAgentPod,
|
||||
},
|
||||
expected: `begin diagnose restore exposer
|
||||
Pod velero/fake-restore, phase Pending, node name fake-node
|
||||
Pod velero/fake-restore, phase Pending, node name fake-node, message
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
PVC velero/fake-restore, phase Pending, binding to fake-pv
|
||||
PV fake-pv, phase Pending, reason , message fake-pv-message
|
||||
@@ -975,7 +976,7 @@ end diagnose restore exposer`,
|
||||
},
|
||||
},
|
||||
expected: `begin diagnose restore exposer
|
||||
Pod velero/fake-restore, phase Pending, node name fake-node
|
||||
Pod velero/fake-restore, phase Pending, node name fake-node, message
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
Pod event reason reason-2, message message-2
|
||||
Pod event reason reason-5, message message-5
|
||||
|
||||
@@ -592,6 +592,7 @@ func TestPodVolumeDiagnoseExpose(t *testing.T) {
|
||||
Message: "fake-pod-message",
|
||||
},
|
||||
},
|
||||
Message: "fake-pod-message-1",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -691,7 +692,7 @@ end diagnose pod volume exposer`,
|
||||
&backupPodWithoutNodeName,
|
||||
},
|
||||
expected: `begin diagnose pod volume exposer
|
||||
Pod velero/fake-backup, phase Pending, node name
|
||||
Pod velero/fake-backup, phase Pending, node name , message fake-pod-message-1
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
end diagnose pod volume exposer`,
|
||||
},
|
||||
@@ -702,7 +703,7 @@ end diagnose pod volume exposer`,
|
||||
&backupPodWithoutNodeName,
|
||||
},
|
||||
expected: `begin diagnose pod volume exposer
|
||||
Pod velero/fake-backup, phase Pending, node name
|
||||
Pod velero/fake-backup, phase Pending, node name , message fake-pod-message-1
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
end diagnose pod volume exposer`,
|
||||
},
|
||||
@@ -713,7 +714,7 @@ end diagnose pod volume exposer`,
|
||||
&backupPodWithNodeName,
|
||||
},
|
||||
expected: `begin diagnose pod volume exposer
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node, message
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
node-agent is not running in node fake-node, err: daemonset pod not found in running state in node fake-node
|
||||
end diagnose pod volume exposer`,
|
||||
@@ -726,7 +727,7 @@ end diagnose pod volume exposer`,
|
||||
&nodeAgentPod,
|
||||
},
|
||||
expected: `begin diagnose pod volume exposer
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node, message
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
end diagnose pod volume exposer`,
|
||||
},
|
||||
@@ -739,7 +740,7 @@ end diagnose pod volume exposer`,
|
||||
&nodeAgentPod,
|
||||
},
|
||||
expected: `begin diagnose pod volume exposer
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node, message
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
PVC velero/fake-backup-cache, phase Pending, binding to fake-pv-cache
|
||||
error getting cache pv fake-pv-cache, err: persistentvolumes "fake-pv-cache" not found
|
||||
@@ -755,7 +756,7 @@ end diagnose pod volume exposer`,
|
||||
&nodeAgentPod,
|
||||
},
|
||||
expected: `begin diagnose pod volume exposer
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node, message
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
PVC velero/fake-backup-cache, phase Pending, binding to fake-pv-cache
|
||||
PV fake-pv-cache, phase Pending, reason , message fake-pv-message
|
||||
@@ -797,7 +798,7 @@ end diagnose pod volume exposer`,
|
||||
},
|
||||
},
|
||||
expected: `begin diagnose pod volume exposer
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node
|
||||
Pod velero/fake-backup, phase Pending, node name fake-node, message
|
||||
Pod condition Initialized, status True, reason , message fake-pod-message
|
||||
Pod event reason reason-2, message message-2
|
||||
Pod event reason reason-4, message message-4
|
||||
|
||||
@@ -18,6 +18,7 @@ limitations under the License.
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
|
||||
"github.com/kopia/kopia/repo/logging"
|
||||
"github.com/sirupsen/logrus"
|
||||
@@ -30,6 +31,10 @@ type kopiaLog struct {
|
||||
logger logrus.FieldLogger
|
||||
}
|
||||
|
||||
type repoLog struct {
|
||||
logger logrus.FieldLogger
|
||||
}
|
||||
|
||||
// SetupKopiaLog sets the Kopia log handler to the specific context, Kopia modules
|
||||
// call the logger in the context to write logs
|
||||
func SetupKopiaLog(ctx context.Context, logger logrus.FieldLogger) context.Context {
|
||||
@@ -39,6 +44,10 @@ func SetupKopiaLog(ctx context.Context, logger logrus.FieldLogger) context.Conte
|
||||
})
|
||||
}
|
||||
|
||||
func RepositoryLogger(logger logrus.FieldLogger) io.Writer {
|
||||
return &repoLog{logger: logger}
|
||||
}
|
||||
|
||||
// Enabled decides whether a given logging level is enabled when logging a message
|
||||
func (kl *kopiaLog) Enabled(level zapcore.Level) bool {
|
||||
entry := kl.logger.WithField("null", "null")
|
||||
@@ -160,3 +169,9 @@ func (kl *kopiaLog) logrusFieldsForWrite(ent zapcore.Entry, fields []zapcore.Fie
|
||||
|
||||
return copied
|
||||
}
|
||||
|
||||
func (rl *repoLog) Write(p []byte) (int, error) {
|
||||
rl.logger.Debug(string(p))
|
||||
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
@@ -671,7 +671,8 @@ func buildJob(
|
||||
}
|
||||
|
||||
if config != nil && len(config.LoadAffinities) > 0 {
|
||||
affinity := kube.ToSystemAffinity(config.LoadAffinities)
|
||||
// Maintenance job only takes the first loadAffinity.
|
||||
affinity := kube.ToSystemAffinity([]*kube.LoadAffinity{config.LoadAffinities[0]})
|
||||
job.Spec.Template.Spec.Affinity = affinity
|
||||
}
|
||||
|
||||
|
||||
@@ -1,669 +0,0 @@
|
||||
// Code generated by mockery v2.53.2. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
import (
|
||||
blob "github.com/kopia/kopia/repo/blob"
|
||||
content "github.com/kopia/kopia/repo/content"
|
||||
|
||||
context "context"
|
||||
|
||||
format "github.com/kopia/kopia/repo/format"
|
||||
|
||||
index "github.com/kopia/kopia/repo/content/index"
|
||||
|
||||
indexblob "github.com/kopia/kopia/repo/content/indexblob"
|
||||
|
||||
manifest "github.com/kopia/kopia/repo/manifest"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
|
||||
object "github.com/kopia/kopia/repo/object"
|
||||
|
||||
repo "github.com/kopia/kopia/repo"
|
||||
|
||||
throttling "github.com/kopia/kopia/repo/blob/throttling"
|
||||
|
||||
time "time"
|
||||
)
|
||||
|
||||
// DirectRepository is an autogenerated mock type for the DirectRepository type
|
||||
type DirectRepository struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// AlsoLogToContentLog provides a mock function with given fields: ctx
|
||||
func (_m *DirectRepository) AlsoLogToContentLog(ctx context.Context) context.Context {
|
||||
ret := _m.Called(ctx)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for AlsoLogToContentLog")
|
||||
}
|
||||
|
||||
var r0 context.Context
|
||||
if rf, ok := ret.Get(0).(func(context.Context) context.Context); ok {
|
||||
r0 = rf(ctx)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(context.Context)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// BlobReader provides a mock function with no fields
|
||||
func (_m *DirectRepository) BlobReader() blob.Reader {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for BlobReader")
|
||||
}
|
||||
|
||||
var r0 blob.Reader
|
||||
if rf, ok := ret.Get(0).(func() blob.Reader); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(blob.Reader)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// BlobVolume provides a mock function with no fields
|
||||
func (_m *DirectRepository) BlobVolume() blob.Volume {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for BlobVolume")
|
||||
}
|
||||
|
||||
var r0 blob.Volume
|
||||
if rf, ok := ret.Get(0).(func() blob.Volume); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(blob.Volume)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// ClientOptions provides a mock function with no fields
|
||||
func (_m *DirectRepository) ClientOptions() repo.ClientOptions {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ClientOptions")
|
||||
}
|
||||
|
||||
var r0 repo.ClientOptions
|
||||
if rf, ok := ret.Get(0).(func() repo.ClientOptions); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
r0 = ret.Get(0).(repo.ClientOptions)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// Close provides a mock function with given fields: ctx
|
||||
func (_m *DirectRepository) Close(ctx context.Context) error {
|
||||
ret := _m.Called(ctx)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Close")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context) error); ok {
|
||||
r0 = rf(ctx)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// ConfigFilename provides a mock function with no fields
|
||||
func (_m *DirectRepository) ConfigFilename() string {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ConfigFilename")
|
||||
}
|
||||
|
||||
var r0 string
|
||||
if rf, ok := ret.Get(0).(func() string); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// ContentInfo provides a mock function with given fields: ctx, contentID
|
||||
func (_m *DirectRepository) ContentInfo(ctx context.Context, contentID index.ID) (index.Info, error) {
|
||||
ret := _m.Called(ctx, contentID)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ContentInfo")
|
||||
}
|
||||
|
||||
var r0 index.Info
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, index.ID) (index.Info, error)); ok {
|
||||
return rf(ctx, contentID)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, index.ID) index.Info); ok {
|
||||
r0 = rf(ctx, contentID)
|
||||
} else {
|
||||
r0 = ret.Get(0).(index.Info)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, index.ID) error); ok {
|
||||
r1 = rf(ctx, contentID)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// ContentReader provides a mock function with no fields
|
||||
func (_m *DirectRepository) ContentReader() content.Reader {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ContentReader")
|
||||
}
|
||||
|
||||
var r0 content.Reader
|
||||
if rf, ok := ret.Get(0).(func() content.Reader); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(content.Reader)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// DeriveKey provides a mock function with given fields: purpose, keyLength
|
||||
func (_m *DirectRepository) DeriveKey(purpose []byte, keyLength int) ([]byte, error) {
|
||||
ret := _m.Called(purpose, keyLength)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for DeriveKey")
|
||||
}
|
||||
|
||||
var r0 []byte
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func([]byte, int) ([]byte, error)); ok {
|
||||
return rf(purpose, keyLength)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func([]byte, int) []byte); ok {
|
||||
r0 = rf(purpose, keyLength)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]byte)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func([]byte, int) error); ok {
|
||||
r1 = rf(purpose, keyLength)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// DisableIndexRefresh provides a mock function with no fields
|
||||
func (_m *DirectRepository) DisableIndexRefresh() {
|
||||
_m.Called()
|
||||
}
|
||||
|
||||
// FindManifests provides a mock function with given fields: ctx, labels
|
||||
func (_m *DirectRepository) FindManifests(ctx context.Context, labels map[string]string) ([]*manifest.EntryMetadata, error) {
|
||||
ret := _m.Called(ctx, labels)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for FindManifests")
|
||||
}
|
||||
|
||||
var r0 []*manifest.EntryMetadata
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, map[string]string) ([]*manifest.EntryMetadata, error)); ok {
|
||||
return rf(ctx, labels)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, map[string]string) []*manifest.EntryMetadata); ok {
|
||||
r0 = rf(ctx, labels)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]*manifest.EntryMetadata)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, map[string]string) error); ok {
|
||||
r1 = rf(ctx, labels)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// FormatManager provides a mock function with no fields
|
||||
func (_m *DirectRepository) FormatManager() *format.Manager {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for FormatManager")
|
||||
}
|
||||
|
||||
var r0 *format.Manager
|
||||
if rf, ok := ret.Get(0).(func() *format.Manager); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*format.Manager)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// GetManifest provides a mock function with given fields: ctx, id, data
|
||||
func (_m *DirectRepository) GetManifest(ctx context.Context, id manifest.ID, data interface{}) (*manifest.EntryMetadata, error) {
|
||||
ret := _m.Called(ctx, id, data)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetManifest")
|
||||
}
|
||||
|
||||
var r0 *manifest.EntryMetadata
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, manifest.ID, interface{}) (*manifest.EntryMetadata, error)); ok {
|
||||
return rf(ctx, id, data)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, manifest.ID, interface{}) *manifest.EntryMetadata); ok {
|
||||
r0 = rf(ctx, id, data)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*manifest.EntryMetadata)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, manifest.ID, interface{}) error); ok {
|
||||
r1 = rf(ctx, id, data)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// IndexBlobs provides a mock function with given fields: ctx, includeInactive
|
||||
func (_m *DirectRepository) IndexBlobs(ctx context.Context, includeInactive bool) ([]indexblob.Metadata, error) {
|
||||
ret := _m.Called(ctx, includeInactive)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for IndexBlobs")
|
||||
}
|
||||
|
||||
var r0 []indexblob.Metadata
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, bool) ([]indexblob.Metadata, error)); ok {
|
||||
return rf(ctx, includeInactive)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, bool) []indexblob.Metadata); ok {
|
||||
r0 = rf(ctx, includeInactive)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]indexblob.Metadata)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, bool) error); ok {
|
||||
r1 = rf(ctx, includeInactive)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// NewDirectWriter provides a mock function with given fields: ctx, opt
|
||||
func (_m *DirectRepository) NewDirectWriter(ctx context.Context, opt repo.WriteSessionOptions) (context.Context, repo.DirectRepositoryWriter, error) {
|
||||
ret := _m.Called(ctx, opt)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for NewDirectWriter")
|
||||
}
|
||||
|
||||
var r0 context.Context
|
||||
var r1 repo.DirectRepositoryWriter
|
||||
var r2 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, repo.WriteSessionOptions) (context.Context, repo.DirectRepositoryWriter, error)); ok {
|
||||
return rf(ctx, opt)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, repo.WriteSessionOptions) context.Context); ok {
|
||||
r0 = rf(ctx, opt)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(context.Context)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, repo.WriteSessionOptions) repo.DirectRepositoryWriter); ok {
|
||||
r1 = rf(ctx, opt)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(repo.DirectRepositoryWriter)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(2).(func(context.Context, repo.WriteSessionOptions) error); ok {
|
||||
r2 = rf(ctx, opt)
|
||||
} else {
|
||||
r2 = ret.Error(2)
|
||||
}
|
||||
|
||||
return r0, r1, r2
|
||||
}
|
||||
|
||||
// NewWriter provides a mock function with given fields: ctx, opt
|
||||
func (_m *DirectRepository) NewWriter(ctx context.Context, opt repo.WriteSessionOptions) (context.Context, repo.RepositoryWriter, error) {
|
||||
ret := _m.Called(ctx, opt)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for NewWriter")
|
||||
}
|
||||
|
||||
var r0 context.Context
|
||||
var r1 repo.RepositoryWriter
|
||||
var r2 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, repo.WriteSessionOptions) (context.Context, repo.RepositoryWriter, error)); ok {
|
||||
return rf(ctx, opt)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, repo.WriteSessionOptions) context.Context); ok {
|
||||
r0 = rf(ctx, opt)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(context.Context)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, repo.WriteSessionOptions) repo.RepositoryWriter); ok {
|
||||
r1 = rf(ctx, opt)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(repo.RepositoryWriter)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(2).(func(context.Context, repo.WriteSessionOptions) error); ok {
|
||||
r2 = rf(ctx, opt)
|
||||
} else {
|
||||
r2 = ret.Error(2)
|
||||
}
|
||||
|
||||
return r0, r1, r2
|
||||
}
|
||||
|
||||
// ObjectFormat provides a mock function with no fields
|
||||
func (_m *DirectRepository) ObjectFormat() format.ObjectFormat {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ObjectFormat")
|
||||
}
|
||||
|
||||
var r0 format.ObjectFormat
|
||||
if rf, ok := ret.Get(0).(func() format.ObjectFormat); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
r0 = ret.Get(0).(format.ObjectFormat)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// OpenObject provides a mock function with given fields: ctx, id
|
||||
func (_m *DirectRepository) OpenObject(ctx context.Context, id object.ID) (object.Reader, error) {
|
||||
ret := _m.Called(ctx, id)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for OpenObject")
|
||||
}
|
||||
|
||||
var r0 object.Reader
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, object.ID) (object.Reader, error)); ok {
|
||||
return rf(ctx, id)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, object.ID) object.Reader); ok {
|
||||
r0 = rf(ctx, id)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(object.Reader)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, object.ID) error); ok {
|
||||
r1 = rf(ctx, id)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// PrefetchContents provides a mock function with given fields: ctx, contentIDs, hint
|
||||
func (_m *DirectRepository) PrefetchContents(ctx context.Context, contentIDs []index.ID, hint string) []index.ID {
|
||||
ret := _m.Called(ctx, contentIDs, hint)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for PrefetchContents")
|
||||
}
|
||||
|
||||
var r0 []index.ID
|
||||
if rf, ok := ret.Get(0).(func(context.Context, []index.ID, string) []index.ID); ok {
|
||||
r0 = rf(ctx, contentIDs, hint)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]index.ID)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// PrefetchObjects provides a mock function with given fields: ctx, objectIDs, hint
|
||||
func (_m *DirectRepository) PrefetchObjects(ctx context.Context, objectIDs []object.ID, hint string) ([]index.ID, error) {
|
||||
ret := _m.Called(ctx, objectIDs, hint)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for PrefetchObjects")
|
||||
}
|
||||
|
||||
var r0 []index.ID
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, []object.ID, string) ([]index.ID, error)); ok {
|
||||
return rf(ctx, objectIDs, hint)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, []object.ID, string) []index.ID); ok {
|
||||
r0 = rf(ctx, objectIDs, hint)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]index.ID)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, []object.ID, string) error); ok {
|
||||
r1 = rf(ctx, objectIDs, hint)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Refresh provides a mock function with given fields: ctx
|
||||
func (_m *DirectRepository) Refresh(ctx context.Context) error {
|
||||
ret := _m.Called(ctx)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Refresh")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context) error); ok {
|
||||
r0 = rf(ctx)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// Throttler provides a mock function with no fields
|
||||
func (_m *DirectRepository) Throttler() throttling.SettableThrottler {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Throttler")
|
||||
}
|
||||
|
||||
var r0 throttling.SettableThrottler
|
||||
if rf, ok := ret.Get(0).(func() throttling.SettableThrottler); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(throttling.SettableThrottler)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// Time provides a mock function with no fields
|
||||
func (_m *DirectRepository) Time() time.Time {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Time")
|
||||
}
|
||||
|
||||
var r0 time.Time
|
||||
if rf, ok := ret.Get(0).(func() time.Time); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
r0 = ret.Get(0).(time.Time)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// Token provides a mock function with given fields: password
|
||||
func (_m *DirectRepository) Token(password string) (string, error) {
|
||||
ret := _m.Called(password)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Token")
|
||||
}
|
||||
|
||||
var r0 string
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string) (string, error)); ok {
|
||||
return rf(password)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string) string); ok {
|
||||
r0 = rf(password)
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = rf(password)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// UniqueID provides a mock function with no fields
|
||||
func (_m *DirectRepository) UniqueID() []byte {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for UniqueID")
|
||||
}
|
||||
|
||||
var r0 []byte
|
||||
if rf, ok := ret.Get(0).(func() []byte); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]byte)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// UpdateDescription provides a mock function with given fields: d
|
||||
func (_m *DirectRepository) UpdateDescription(d string) {
|
||||
_m.Called(d)
|
||||
}
|
||||
|
||||
// VerifyObject provides a mock function with given fields: ctx, id
|
||||
func (_m *DirectRepository) VerifyObject(ctx context.Context, id object.ID) ([]index.ID, error) {
|
||||
ret := _m.Called(ctx, id)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for VerifyObject")
|
||||
}
|
||||
|
||||
var r0 []index.ID
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, object.ID) ([]index.ID, error)); ok {
|
||||
return rf(ctx, id)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, object.ID) []index.ID); ok {
|
||||
r0 = rf(ctx, id)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]index.ID)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, object.ID) error); ok {
|
||||
r1 = rf(ctx, id)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// NewDirectRepository creates a new instance of DirectRepository. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewDirectRepository(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *DirectRepository {
|
||||
mock := &DirectRepository{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -1,854 +0,0 @@
|
||||
// Code generated by mockery v2.53.2. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
import (
|
||||
blob "github.com/kopia/kopia/repo/blob"
|
||||
content "github.com/kopia/kopia/repo/content"
|
||||
|
||||
context "context"
|
||||
|
||||
format "github.com/kopia/kopia/repo/format"
|
||||
|
||||
index "github.com/kopia/kopia/repo/content/index"
|
||||
|
||||
indexblob "github.com/kopia/kopia/repo/content/indexblob"
|
||||
|
||||
manifest "github.com/kopia/kopia/repo/manifest"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
|
||||
object "github.com/kopia/kopia/repo/object"
|
||||
|
||||
repo "github.com/kopia/kopia/repo"
|
||||
|
||||
throttling "github.com/kopia/kopia/repo/blob/throttling"
|
||||
|
||||
time "time"
|
||||
)
|
||||
|
||||
// DirectRepositoryWriter is an autogenerated mock type for the DirectRepositoryWriter type
|
||||
type DirectRepositoryWriter struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// AlsoLogToContentLog provides a mock function with given fields: ctx
|
||||
func (_m *DirectRepositoryWriter) AlsoLogToContentLog(ctx context.Context) context.Context {
|
||||
ret := _m.Called(ctx)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for AlsoLogToContentLog")
|
||||
}
|
||||
|
||||
var r0 context.Context
|
||||
if rf, ok := ret.Get(0).(func(context.Context) context.Context); ok {
|
||||
r0 = rf(ctx)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(context.Context)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// BlobReader provides a mock function with no fields
|
||||
func (_m *DirectRepositoryWriter) BlobReader() blob.Reader {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for BlobReader")
|
||||
}
|
||||
|
||||
var r0 blob.Reader
|
||||
if rf, ok := ret.Get(0).(func() blob.Reader); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(blob.Reader)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// BlobStorage provides a mock function with no fields
|
||||
func (_m *DirectRepositoryWriter) BlobStorage() blob.Storage {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for BlobStorage")
|
||||
}
|
||||
|
||||
var r0 blob.Storage
|
||||
if rf, ok := ret.Get(0).(func() blob.Storage); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(blob.Storage)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// BlobVolume provides a mock function with no fields
|
||||
func (_m *DirectRepositoryWriter) BlobVolume() blob.Volume {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for BlobVolume")
|
||||
}
|
||||
|
||||
var r0 blob.Volume
|
||||
if rf, ok := ret.Get(0).(func() blob.Volume); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(blob.Volume)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// ClientOptions provides a mock function with no fields
|
||||
func (_m *DirectRepositoryWriter) ClientOptions() repo.ClientOptions {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ClientOptions")
|
||||
}
|
||||
|
||||
var r0 repo.ClientOptions
|
||||
if rf, ok := ret.Get(0).(func() repo.ClientOptions); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
r0 = ret.Get(0).(repo.ClientOptions)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// Close provides a mock function with given fields: ctx
|
||||
func (_m *DirectRepositoryWriter) Close(ctx context.Context) error {
|
||||
ret := _m.Called(ctx)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Close")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context) error); ok {
|
||||
r0 = rf(ctx)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// ConcatenateObjects provides a mock function with given fields: ctx, objectIDs, opt
|
||||
func (_m *DirectRepositoryWriter) ConcatenateObjects(ctx context.Context, objectIDs []object.ID, opt repo.ConcatenateOptions) (object.ID, error) {
|
||||
ret := _m.Called(ctx, objectIDs, opt)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ConcatenateObjects")
|
||||
}
|
||||
|
||||
var r0 object.ID
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, []object.ID, repo.ConcatenateOptions) (object.ID, error)); ok {
|
||||
return rf(ctx, objectIDs, opt)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, []object.ID, repo.ConcatenateOptions) object.ID); ok {
|
||||
r0 = rf(ctx, objectIDs, opt)
|
||||
} else {
|
||||
r0 = ret.Get(0).(object.ID)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, []object.ID, repo.ConcatenateOptions) error); ok {
|
||||
r1 = rf(ctx, objectIDs, opt)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// ConfigFilename provides a mock function with no fields
|
||||
func (_m *DirectRepositoryWriter) ConfigFilename() string {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ConfigFilename")
|
||||
}
|
||||
|
||||
var r0 string
|
||||
if rf, ok := ret.Get(0).(func() string); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// ContentInfo provides a mock function with given fields: ctx, contentID
|
||||
func (_m *DirectRepositoryWriter) ContentInfo(ctx context.Context, contentID index.ID) (index.Info, error) {
|
||||
ret := _m.Called(ctx, contentID)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ContentInfo")
|
||||
}
|
||||
|
||||
var r0 index.Info
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, index.ID) (index.Info, error)); ok {
|
||||
return rf(ctx, contentID)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, index.ID) index.Info); ok {
|
||||
r0 = rf(ctx, contentID)
|
||||
} else {
|
||||
r0 = ret.Get(0).(index.Info)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, index.ID) error); ok {
|
||||
r1 = rf(ctx, contentID)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// ContentManager provides a mock function with no fields
|
||||
func (_m *DirectRepositoryWriter) ContentManager() *content.WriteManager {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ContentManager")
|
||||
}
|
||||
|
||||
var r0 *content.WriteManager
|
||||
if rf, ok := ret.Get(0).(func() *content.WriteManager); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*content.WriteManager)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// ContentReader provides a mock function with no fields
|
||||
func (_m *DirectRepositoryWriter) ContentReader() content.Reader {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ContentReader")
|
||||
}
|
||||
|
||||
var r0 content.Reader
|
||||
if rf, ok := ret.Get(0).(func() content.Reader); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(content.Reader)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// DeleteManifest provides a mock function with given fields: ctx, id
|
||||
func (_m *DirectRepositoryWriter) DeleteManifest(ctx context.Context, id manifest.ID) error {
|
||||
ret := _m.Called(ctx, id)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for DeleteManifest")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, manifest.ID) error); ok {
|
||||
r0 = rf(ctx, id)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// DeriveKey provides a mock function with given fields: purpose, keyLength
|
||||
func (_m *DirectRepositoryWriter) DeriveKey(purpose []byte, keyLength int) ([]byte, error) {
|
||||
ret := _m.Called(purpose, keyLength)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for DeriveKey")
|
||||
}
|
||||
|
||||
var r0 []byte
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func([]byte, int) ([]byte, error)); ok {
|
||||
return rf(purpose, keyLength)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func([]byte, int) []byte); ok {
|
||||
r0 = rf(purpose, keyLength)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]byte)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func([]byte, int) error); ok {
|
||||
r1 = rf(purpose, keyLength)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// DisableIndexRefresh provides a mock function with no fields
|
||||
func (_m *DirectRepositoryWriter) DisableIndexRefresh() {
|
||||
_m.Called()
|
||||
}
|
||||
|
||||
// FindManifests provides a mock function with given fields: ctx, labels
|
||||
func (_m *DirectRepositoryWriter) FindManifests(ctx context.Context, labels map[string]string) ([]*manifest.EntryMetadata, error) {
|
||||
ret := _m.Called(ctx, labels)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for FindManifests")
|
||||
}
|
||||
|
||||
var r0 []*manifest.EntryMetadata
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, map[string]string) ([]*manifest.EntryMetadata, error)); ok {
|
||||
return rf(ctx, labels)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, map[string]string) []*manifest.EntryMetadata); ok {
|
||||
r0 = rf(ctx, labels)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]*manifest.EntryMetadata)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, map[string]string) error); ok {
|
||||
r1 = rf(ctx, labels)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Flush provides a mock function with given fields: ctx
|
||||
func (_m *DirectRepositoryWriter) Flush(ctx context.Context) error {
|
||||
ret := _m.Called(ctx)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Flush")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context) error); ok {
|
||||
r0 = rf(ctx)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// FormatManager provides a mock function with no fields
|
||||
func (_m *DirectRepositoryWriter) FormatManager() *format.Manager {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for FormatManager")
|
||||
}
|
||||
|
||||
var r0 *format.Manager
|
||||
if rf, ok := ret.Get(0).(func() *format.Manager); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*format.Manager)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// GetManifest provides a mock function with given fields: ctx, id, data
|
||||
func (_m *DirectRepositoryWriter) GetManifest(ctx context.Context, id manifest.ID, data interface{}) (*manifest.EntryMetadata, error) {
|
||||
ret := _m.Called(ctx, id, data)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetManifest")
|
||||
}
|
||||
|
||||
var r0 *manifest.EntryMetadata
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, manifest.ID, interface{}) (*manifest.EntryMetadata, error)); ok {
|
||||
return rf(ctx, id, data)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, manifest.ID, interface{}) *manifest.EntryMetadata); ok {
|
||||
r0 = rf(ctx, id, data)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*manifest.EntryMetadata)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, manifest.ID, interface{}) error); ok {
|
||||
r1 = rf(ctx, id, data)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// IndexBlobs provides a mock function with given fields: ctx, includeInactive
|
||||
func (_m *DirectRepositoryWriter) IndexBlobs(ctx context.Context, includeInactive bool) ([]indexblob.Metadata, error) {
|
||||
ret := _m.Called(ctx, includeInactive)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for IndexBlobs")
|
||||
}
|
||||
|
||||
var r0 []indexblob.Metadata
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, bool) ([]indexblob.Metadata, error)); ok {
|
||||
return rf(ctx, includeInactive)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, bool) []indexblob.Metadata); ok {
|
||||
r0 = rf(ctx, includeInactive)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]indexblob.Metadata)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, bool) error); ok {
|
||||
r1 = rf(ctx, includeInactive)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// NewDirectWriter provides a mock function with given fields: ctx, opt
|
||||
func (_m *DirectRepositoryWriter) NewDirectWriter(ctx context.Context, opt repo.WriteSessionOptions) (context.Context, repo.DirectRepositoryWriter, error) {
|
||||
ret := _m.Called(ctx, opt)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for NewDirectWriter")
|
||||
}
|
||||
|
||||
var r0 context.Context
|
||||
var r1 repo.DirectRepositoryWriter
|
||||
var r2 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, repo.WriteSessionOptions) (context.Context, repo.DirectRepositoryWriter, error)); ok {
|
||||
return rf(ctx, opt)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, repo.WriteSessionOptions) context.Context); ok {
|
||||
r0 = rf(ctx, opt)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(context.Context)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, repo.WriteSessionOptions) repo.DirectRepositoryWriter); ok {
|
||||
r1 = rf(ctx, opt)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(repo.DirectRepositoryWriter)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(2).(func(context.Context, repo.WriteSessionOptions) error); ok {
|
||||
r2 = rf(ctx, opt)
|
||||
} else {
|
||||
r2 = ret.Error(2)
|
||||
}
|
||||
|
||||
return r0, r1, r2
|
||||
}
|
||||
|
||||
// NewObjectWriter provides a mock function with given fields: ctx, opt
|
||||
func (_m *DirectRepositoryWriter) NewObjectWriter(ctx context.Context, opt object.WriterOptions) object.Writer {
|
||||
ret := _m.Called(ctx, opt)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for NewObjectWriter")
|
||||
}
|
||||
|
||||
var r0 object.Writer
|
||||
if rf, ok := ret.Get(0).(func(context.Context, object.WriterOptions) object.Writer); ok {
|
||||
r0 = rf(ctx, opt)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(object.Writer)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// NewWriter provides a mock function with given fields: ctx, opt
|
||||
func (_m *DirectRepositoryWriter) NewWriter(ctx context.Context, opt repo.WriteSessionOptions) (context.Context, repo.RepositoryWriter, error) {
|
||||
ret := _m.Called(ctx, opt)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for NewWriter")
|
||||
}
|
||||
|
||||
var r0 context.Context
|
||||
var r1 repo.RepositoryWriter
|
||||
var r2 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, repo.WriteSessionOptions) (context.Context, repo.RepositoryWriter, error)); ok {
|
||||
return rf(ctx, opt)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, repo.WriteSessionOptions) context.Context); ok {
|
||||
r0 = rf(ctx, opt)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(context.Context)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, repo.WriteSessionOptions) repo.RepositoryWriter); ok {
|
||||
r1 = rf(ctx, opt)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(repo.RepositoryWriter)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(2).(func(context.Context, repo.WriteSessionOptions) error); ok {
|
||||
r2 = rf(ctx, opt)
|
||||
} else {
|
||||
r2 = ret.Error(2)
|
||||
}
|
||||
|
||||
return r0, r1, r2
|
||||
}
|
||||
|
||||
// ObjectFormat provides a mock function with no fields
|
||||
func (_m *DirectRepositoryWriter) ObjectFormat() format.ObjectFormat {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ObjectFormat")
|
||||
}
|
||||
|
||||
var r0 format.ObjectFormat
|
||||
if rf, ok := ret.Get(0).(func() format.ObjectFormat); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
r0 = ret.Get(0).(format.ObjectFormat)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// OnSuccessfulFlush provides a mock function with given fields: callback
|
||||
func (_m *DirectRepositoryWriter) OnSuccessfulFlush(callback repo.RepositoryWriterCallback) {
|
||||
_m.Called(callback)
|
||||
}
|
||||
|
||||
// OpenObject provides a mock function with given fields: ctx, id
|
||||
func (_m *DirectRepositoryWriter) OpenObject(ctx context.Context, id object.ID) (object.Reader, error) {
|
||||
ret := _m.Called(ctx, id)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for OpenObject")
|
||||
}
|
||||
|
||||
var r0 object.Reader
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, object.ID) (object.Reader, error)); ok {
|
||||
return rf(ctx, id)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, object.ID) object.Reader); ok {
|
||||
r0 = rf(ctx, id)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(object.Reader)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, object.ID) error); ok {
|
||||
r1 = rf(ctx, id)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// PrefetchContents provides a mock function with given fields: ctx, contentIDs, hint
|
||||
func (_m *DirectRepositoryWriter) PrefetchContents(ctx context.Context, contentIDs []index.ID, hint string) []index.ID {
|
||||
ret := _m.Called(ctx, contentIDs, hint)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for PrefetchContents")
|
||||
}
|
||||
|
||||
var r0 []index.ID
|
||||
if rf, ok := ret.Get(0).(func(context.Context, []index.ID, string) []index.ID); ok {
|
||||
r0 = rf(ctx, contentIDs, hint)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]index.ID)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// PrefetchObjects provides a mock function with given fields: ctx, objectIDs, hint
|
||||
func (_m *DirectRepositoryWriter) PrefetchObjects(ctx context.Context, objectIDs []object.ID, hint string) ([]index.ID, error) {
|
||||
ret := _m.Called(ctx, objectIDs, hint)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for PrefetchObjects")
|
||||
}
|
||||
|
||||
var r0 []index.ID
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, []object.ID, string) ([]index.ID, error)); ok {
|
||||
return rf(ctx, objectIDs, hint)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, []object.ID, string) []index.ID); ok {
|
||||
r0 = rf(ctx, objectIDs, hint)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]index.ID)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, []object.ID, string) error); ok {
|
||||
r1 = rf(ctx, objectIDs, hint)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// PutManifest provides a mock function with given fields: ctx, labels, payload
|
||||
func (_m *DirectRepositoryWriter) PutManifest(ctx context.Context, labels map[string]string, payload interface{}) (manifest.ID, error) {
|
||||
ret := _m.Called(ctx, labels, payload)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for PutManifest")
|
||||
}
|
||||
|
||||
var r0 manifest.ID
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, map[string]string, interface{}) (manifest.ID, error)); ok {
|
||||
return rf(ctx, labels, payload)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, map[string]string, interface{}) manifest.ID); ok {
|
||||
r0 = rf(ctx, labels, payload)
|
||||
} else {
|
||||
r0 = ret.Get(0).(manifest.ID)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, map[string]string, interface{}) error); ok {
|
||||
r1 = rf(ctx, labels, payload)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Refresh provides a mock function with given fields: ctx
|
||||
func (_m *DirectRepositoryWriter) Refresh(ctx context.Context) error {
|
||||
ret := _m.Called(ctx)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Refresh")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context) error); ok {
|
||||
r0 = rf(ctx)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// ReplaceManifests provides a mock function with given fields: ctx, labels, payload
|
||||
func (_m *DirectRepositoryWriter) ReplaceManifests(ctx context.Context, labels map[string]string, payload interface{}) (manifest.ID, error) {
|
||||
ret := _m.Called(ctx, labels, payload)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ReplaceManifests")
|
||||
}
|
||||
|
||||
var r0 manifest.ID
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, map[string]string, interface{}) (manifest.ID, error)); ok {
|
||||
return rf(ctx, labels, payload)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, map[string]string, interface{}) manifest.ID); ok {
|
||||
r0 = rf(ctx, labels, payload)
|
||||
} else {
|
||||
r0 = ret.Get(0).(manifest.ID)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, map[string]string, interface{}) error); ok {
|
||||
r1 = rf(ctx, labels, payload)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Throttler provides a mock function with no fields
|
||||
func (_m *DirectRepositoryWriter) Throttler() throttling.SettableThrottler {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Throttler")
|
||||
}
|
||||
|
||||
var r0 throttling.SettableThrottler
|
||||
if rf, ok := ret.Get(0).(func() throttling.SettableThrottler); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(throttling.SettableThrottler)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// Time provides a mock function with no fields
|
||||
func (_m *DirectRepositoryWriter) Time() time.Time {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Time")
|
||||
}
|
||||
|
||||
var r0 time.Time
|
||||
if rf, ok := ret.Get(0).(func() time.Time); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
r0 = ret.Get(0).(time.Time)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// Token provides a mock function with given fields: password
|
||||
func (_m *DirectRepositoryWriter) Token(password string) (string, error) {
|
||||
ret := _m.Called(password)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Token")
|
||||
}
|
||||
|
||||
var r0 string
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string) (string, error)); ok {
|
||||
return rf(password)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string) string); ok {
|
||||
r0 = rf(password)
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = rf(password)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// UniqueID provides a mock function with no fields
|
||||
func (_m *DirectRepositoryWriter) UniqueID() []byte {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for UniqueID")
|
||||
}
|
||||
|
||||
var r0 []byte
|
||||
if rf, ok := ret.Get(0).(func() []byte); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]byte)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// UpdateDescription provides a mock function with given fields: d
|
||||
func (_m *DirectRepositoryWriter) UpdateDescription(d string) {
|
||||
_m.Called(d)
|
||||
}
|
||||
|
||||
// VerifyObject provides a mock function with given fields: ctx, id
|
||||
func (_m *DirectRepositoryWriter) VerifyObject(ctx context.Context, id object.ID) ([]index.ID, error) {
|
||||
ret := _m.Called(ctx, id)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for VerifyObject")
|
||||
}
|
||||
|
||||
var r0 []index.ID
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, object.ID) ([]index.ID, error)); ok {
|
||||
return rf(ctx, id)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, object.ID) []index.ID); ok {
|
||||
r0 = rf(ctx, id)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]index.ID)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, object.ID) error); ok {
|
||||
r1 = rf(ctx, id)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// NewDirectRepositoryWriter creates a new instance of DirectRepositoryWriter. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewDirectRepositoryWriter(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *DirectRepositoryWriter {
|
||||
mock := &DirectRepositoryWriter{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -0,0 +1,832 @@
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package mocks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/kopia/kopia/repo"
|
||||
"github.com/kopia/kopia/repo/content"
|
||||
"github.com/kopia/kopia/repo/manifest"
|
||||
"github.com/kopia/kopia/repo/object"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NewMockRepository creates a new instance of MockRepository. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockRepository(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockRepository {
|
||||
mock := &MockRepository{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockRepository is an autogenerated mock type for the Repository type
|
||||
type MockRepository struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockRepository_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockRepository) EXPECT() *MockRepository_Expecter {
|
||||
return &MockRepository_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// ClientOptions provides a mock function for the type MockRepository
|
||||
func (_mock *MockRepository) ClientOptions() repo.ClientOptions {
|
||||
ret := _mock.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ClientOptions")
|
||||
}
|
||||
|
||||
var r0 repo.ClientOptions
|
||||
if returnFunc, ok := ret.Get(0).(func() repo.ClientOptions); ok {
|
||||
r0 = returnFunc()
|
||||
} else {
|
||||
r0 = ret.Get(0).(repo.ClientOptions)
|
||||
}
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockRepository_ClientOptions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClientOptions'
|
||||
type MockRepository_ClientOptions_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// ClientOptions is a helper method to define mock.On call
|
||||
func (_e *MockRepository_Expecter) ClientOptions() *MockRepository_ClientOptions_Call {
|
||||
return &MockRepository_ClientOptions_Call{Call: _e.mock.On("ClientOptions")}
|
||||
}
|
||||
|
||||
func (_c *MockRepository_ClientOptions_Call) Run(run func()) *MockRepository_ClientOptions_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_ClientOptions_Call) Return(clientOptions repo.ClientOptions) *MockRepository_ClientOptions_Call {
|
||||
_c.Call.Return(clientOptions)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_ClientOptions_Call) RunAndReturn(run func() repo.ClientOptions) *MockRepository_ClientOptions_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Close provides a mock function for the type MockRepository
|
||||
func (_mock *MockRepository) Close(ctx context.Context) error {
|
||||
ret := _mock.Called(ctx)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Close")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context) error); ok {
|
||||
r0 = returnFunc(ctx)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockRepository_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close'
|
||||
type MockRepository_Close_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Close is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
func (_e *MockRepository_Expecter) Close(ctx interface{}) *MockRepository_Close_Call {
|
||||
return &MockRepository_Close_Call{Call: _e.mock.On("Close", ctx)}
|
||||
}
|
||||
|
||||
func (_c *MockRepository_Close_Call) Run(run func(ctx context.Context)) *MockRepository_Close_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_Close_Call) Return(err error) *MockRepository_Close_Call {
|
||||
_c.Call.Return(err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_Close_Call) RunAndReturn(run func(ctx context.Context) error) *MockRepository_Close_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// ContentInfo provides a mock function for the type MockRepository
|
||||
func (_mock *MockRepository) ContentInfo(ctx context.Context, contentID content.ID) (content.Info, error) {
|
||||
ret := _mock.Called(ctx, contentID)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ContentInfo")
|
||||
}
|
||||
|
||||
var r0 content.Info
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, content.ID) (content.Info, error)); ok {
|
||||
return returnFunc(ctx, contentID)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, content.ID) content.Info); ok {
|
||||
r0 = returnFunc(ctx, contentID)
|
||||
} else {
|
||||
r0 = ret.Get(0).(content.Info)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, content.ID) error); ok {
|
||||
r1 = returnFunc(ctx, contentID)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockRepository_ContentInfo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ContentInfo'
|
||||
type MockRepository_ContentInfo_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// ContentInfo is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - contentID content.ID
|
||||
func (_e *MockRepository_Expecter) ContentInfo(ctx interface{}, contentID interface{}) *MockRepository_ContentInfo_Call {
|
||||
return &MockRepository_ContentInfo_Call{Call: _e.mock.On("ContentInfo", ctx, contentID)}
|
||||
}
|
||||
|
||||
func (_c *MockRepository_ContentInfo_Call) Run(run func(ctx context.Context, contentID content.ID)) *MockRepository_ContentInfo_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 content.ID
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(content.ID)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_ContentInfo_Call) Return(v content.Info, err error) *MockRepository_ContentInfo_Call {
|
||||
_c.Call.Return(v, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_ContentInfo_Call) RunAndReturn(run func(ctx context.Context, contentID content.ID) (content.Info, error)) *MockRepository_ContentInfo_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// FindManifests provides a mock function for the type MockRepository
|
||||
func (_mock *MockRepository) FindManifests(ctx context.Context, labels map[string]string) ([]*manifest.EntryMetadata, error) {
|
||||
ret := _mock.Called(ctx, labels)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for FindManifests")
|
||||
}
|
||||
|
||||
var r0 []*manifest.EntryMetadata
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, map[string]string) ([]*manifest.EntryMetadata, error)); ok {
|
||||
return returnFunc(ctx, labels)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, map[string]string) []*manifest.EntryMetadata); ok {
|
||||
r0 = returnFunc(ctx, labels)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]*manifest.EntryMetadata)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, map[string]string) error); ok {
|
||||
r1 = returnFunc(ctx, labels)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockRepository_FindManifests_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FindManifests'
|
||||
type MockRepository_FindManifests_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// FindManifests is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - labels map[string]string
|
||||
func (_e *MockRepository_Expecter) FindManifests(ctx interface{}, labels interface{}) *MockRepository_FindManifests_Call {
|
||||
return &MockRepository_FindManifests_Call{Call: _e.mock.On("FindManifests", ctx, labels)}
|
||||
}
|
||||
|
||||
func (_c *MockRepository_FindManifests_Call) Run(run func(ctx context.Context, labels map[string]string)) *MockRepository_FindManifests_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 map[string]string
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(map[string]string)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_FindManifests_Call) Return(entryMetadatas []*manifest.EntryMetadata, err error) *MockRepository_FindManifests_Call {
|
||||
_c.Call.Return(entryMetadatas, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_FindManifests_Call) RunAndReturn(run func(ctx context.Context, labels map[string]string) ([]*manifest.EntryMetadata, error)) *MockRepository_FindManifests_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// GetManifest provides a mock function for the type MockRepository
|
||||
func (_mock *MockRepository) GetManifest(ctx context.Context, id manifest.ID, data any) (*manifest.EntryMetadata, error) {
|
||||
ret := _mock.Called(ctx, id, data)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetManifest")
|
||||
}
|
||||
|
||||
var r0 *manifest.EntryMetadata
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, manifest.ID, any) (*manifest.EntryMetadata, error)); ok {
|
||||
return returnFunc(ctx, id, data)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, manifest.ID, any) *manifest.EntryMetadata); ok {
|
||||
r0 = returnFunc(ctx, id, data)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*manifest.EntryMetadata)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, manifest.ID, any) error); ok {
|
||||
r1 = returnFunc(ctx, id, data)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockRepository_GetManifest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetManifest'
|
||||
type MockRepository_GetManifest_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// GetManifest is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - id manifest.ID
|
||||
// - data any
|
||||
func (_e *MockRepository_Expecter) GetManifest(ctx interface{}, id interface{}, data interface{}) *MockRepository_GetManifest_Call {
|
||||
return &MockRepository_GetManifest_Call{Call: _e.mock.On("GetManifest", ctx, id, data)}
|
||||
}
|
||||
|
||||
func (_c *MockRepository_GetManifest_Call) Run(run func(ctx context.Context, id manifest.ID, data any)) *MockRepository_GetManifest_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 manifest.ID
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(manifest.ID)
|
||||
}
|
||||
var arg2 any
|
||||
if args[2] != nil {
|
||||
arg2 = args[2].(any)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
arg2,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_GetManifest_Call) Return(entryMetadata *manifest.EntryMetadata, err error) *MockRepository_GetManifest_Call {
|
||||
_c.Call.Return(entryMetadata, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_GetManifest_Call) RunAndReturn(run func(ctx context.Context, id manifest.ID, data any) (*manifest.EntryMetadata, error)) *MockRepository_GetManifest_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewWriter provides a mock function for the type MockRepository
|
||||
func (_mock *MockRepository) NewWriter(ctx context.Context, opt repo.WriteSessionOptions) (context.Context, repo.RepositoryWriter, error) {
|
||||
ret := _mock.Called(ctx, opt)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for NewWriter")
|
||||
}
|
||||
|
||||
var r0 context.Context
|
||||
var r1 repo.RepositoryWriter
|
||||
var r2 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, repo.WriteSessionOptions) (context.Context, repo.RepositoryWriter, error)); ok {
|
||||
return returnFunc(ctx, opt)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, repo.WriteSessionOptions) context.Context); ok {
|
||||
r0 = returnFunc(ctx, opt)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(context.Context)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, repo.WriteSessionOptions) repo.RepositoryWriter); ok {
|
||||
r1 = returnFunc(ctx, opt)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(repo.RepositoryWriter)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(2).(func(context.Context, repo.WriteSessionOptions) error); ok {
|
||||
r2 = returnFunc(ctx, opt)
|
||||
} else {
|
||||
r2 = ret.Error(2)
|
||||
}
|
||||
return r0, r1, r2
|
||||
}
|
||||
|
||||
// MockRepository_NewWriter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NewWriter'
|
||||
type MockRepository_NewWriter_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// NewWriter is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - opt repo.WriteSessionOptions
|
||||
func (_e *MockRepository_Expecter) NewWriter(ctx interface{}, opt interface{}) *MockRepository_NewWriter_Call {
|
||||
return &MockRepository_NewWriter_Call{Call: _e.mock.On("NewWriter", ctx, opt)}
|
||||
}
|
||||
|
||||
func (_c *MockRepository_NewWriter_Call) Run(run func(ctx context.Context, opt repo.WriteSessionOptions)) *MockRepository_NewWriter_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 repo.WriteSessionOptions
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(repo.WriteSessionOptions)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_NewWriter_Call) Return(context1 context.Context, repositoryWriter repo.RepositoryWriter, err error) *MockRepository_NewWriter_Call {
|
||||
_c.Call.Return(context1, repositoryWriter, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_NewWriter_Call) RunAndReturn(run func(ctx context.Context, opt repo.WriteSessionOptions) (context.Context, repo.RepositoryWriter, error)) *MockRepository_NewWriter_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// OpenObject provides a mock function for the type MockRepository
|
||||
func (_mock *MockRepository) OpenObject(ctx context.Context, id object.ID) (object.Reader, error) {
|
||||
ret := _mock.Called(ctx, id)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for OpenObject")
|
||||
}
|
||||
|
||||
var r0 object.Reader
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, object.ID) (object.Reader, error)); ok {
|
||||
return returnFunc(ctx, id)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, object.ID) object.Reader); ok {
|
||||
r0 = returnFunc(ctx, id)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(object.Reader)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, object.ID) error); ok {
|
||||
r1 = returnFunc(ctx, id)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockRepository_OpenObject_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OpenObject'
|
||||
type MockRepository_OpenObject_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// OpenObject is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - id object.ID
|
||||
func (_e *MockRepository_Expecter) OpenObject(ctx interface{}, id interface{}) *MockRepository_OpenObject_Call {
|
||||
return &MockRepository_OpenObject_Call{Call: _e.mock.On("OpenObject", ctx, id)}
|
||||
}
|
||||
|
||||
func (_c *MockRepository_OpenObject_Call) Run(run func(ctx context.Context, id object.ID)) *MockRepository_OpenObject_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 object.ID
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(object.ID)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_OpenObject_Call) Return(reader object.Reader, err error) *MockRepository_OpenObject_Call {
|
||||
_c.Call.Return(reader, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_OpenObject_Call) RunAndReturn(run func(ctx context.Context, id object.ID) (object.Reader, error)) *MockRepository_OpenObject_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// PrefetchContents provides a mock function for the type MockRepository
|
||||
func (_mock *MockRepository) PrefetchContents(ctx context.Context, contentIDs []content.ID, hint string) []content.ID {
|
||||
ret := _mock.Called(ctx, contentIDs, hint)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for PrefetchContents")
|
||||
}
|
||||
|
||||
var r0 []content.ID
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, []content.ID, string) []content.ID); ok {
|
||||
r0 = returnFunc(ctx, contentIDs, hint)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]content.ID)
|
||||
}
|
||||
}
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockRepository_PrefetchContents_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PrefetchContents'
|
||||
type MockRepository_PrefetchContents_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// PrefetchContents is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - contentIDs []content.ID
|
||||
// - hint string
|
||||
func (_e *MockRepository_Expecter) PrefetchContents(ctx interface{}, contentIDs interface{}, hint interface{}) *MockRepository_PrefetchContents_Call {
|
||||
return &MockRepository_PrefetchContents_Call{Call: _e.mock.On("PrefetchContents", ctx, contentIDs, hint)}
|
||||
}
|
||||
|
||||
func (_c *MockRepository_PrefetchContents_Call) Run(run func(ctx context.Context, contentIDs []content.ID, hint string)) *MockRepository_PrefetchContents_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 []content.ID
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].([]content.ID)
|
||||
}
|
||||
var arg2 string
|
||||
if args[2] != nil {
|
||||
arg2 = args[2].(string)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
arg2,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_PrefetchContents_Call) Return(vs []content.ID) *MockRepository_PrefetchContents_Call {
|
||||
_c.Call.Return(vs)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_PrefetchContents_Call) RunAndReturn(run func(ctx context.Context, contentIDs []content.ID, hint string) []content.ID) *MockRepository_PrefetchContents_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// PrefetchObjects provides a mock function for the type MockRepository
|
||||
func (_mock *MockRepository) PrefetchObjects(ctx context.Context, objectIDs []object.ID, hint string) ([]content.ID, error) {
|
||||
ret := _mock.Called(ctx, objectIDs, hint)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for PrefetchObjects")
|
||||
}
|
||||
|
||||
var r0 []content.ID
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, []object.ID, string) ([]content.ID, error)); ok {
|
||||
return returnFunc(ctx, objectIDs, hint)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, []object.ID, string) []content.ID); ok {
|
||||
r0 = returnFunc(ctx, objectIDs, hint)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]content.ID)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, []object.ID, string) error); ok {
|
||||
r1 = returnFunc(ctx, objectIDs, hint)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockRepository_PrefetchObjects_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PrefetchObjects'
|
||||
type MockRepository_PrefetchObjects_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// PrefetchObjects is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - objectIDs []object.ID
|
||||
// - hint string
|
||||
func (_e *MockRepository_Expecter) PrefetchObjects(ctx interface{}, objectIDs interface{}, hint interface{}) *MockRepository_PrefetchObjects_Call {
|
||||
return &MockRepository_PrefetchObjects_Call{Call: _e.mock.On("PrefetchObjects", ctx, objectIDs, hint)}
|
||||
}
|
||||
|
||||
func (_c *MockRepository_PrefetchObjects_Call) Run(run func(ctx context.Context, objectIDs []object.ID, hint string)) *MockRepository_PrefetchObjects_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 []object.ID
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].([]object.ID)
|
||||
}
|
||||
var arg2 string
|
||||
if args[2] != nil {
|
||||
arg2 = args[2].(string)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
arg2,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_PrefetchObjects_Call) Return(vs []content.ID, err error) *MockRepository_PrefetchObjects_Call {
|
||||
_c.Call.Return(vs, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_PrefetchObjects_Call) RunAndReturn(run func(ctx context.Context, objectIDs []object.ID, hint string) ([]content.ID, error)) *MockRepository_PrefetchObjects_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Refresh provides a mock function for the type MockRepository
|
||||
func (_mock *MockRepository) Refresh(ctx context.Context) error {
|
||||
ret := _mock.Called(ctx)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Refresh")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context) error); ok {
|
||||
r0 = returnFunc(ctx)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockRepository_Refresh_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Refresh'
|
||||
type MockRepository_Refresh_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Refresh is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
func (_e *MockRepository_Expecter) Refresh(ctx interface{}) *MockRepository_Refresh_Call {
|
||||
return &MockRepository_Refresh_Call{Call: _e.mock.On("Refresh", ctx)}
|
||||
}
|
||||
|
||||
func (_c *MockRepository_Refresh_Call) Run(run func(ctx context.Context)) *MockRepository_Refresh_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_Refresh_Call) Return(err error) *MockRepository_Refresh_Call {
|
||||
_c.Call.Return(err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_Refresh_Call) RunAndReturn(run func(ctx context.Context) error) *MockRepository_Refresh_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Time provides a mock function for the type MockRepository
|
||||
func (_mock *MockRepository) Time() time.Time {
|
||||
ret := _mock.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Time")
|
||||
}
|
||||
|
||||
var r0 time.Time
|
||||
if returnFunc, ok := ret.Get(0).(func() time.Time); ok {
|
||||
r0 = returnFunc()
|
||||
} else {
|
||||
r0 = ret.Get(0).(time.Time)
|
||||
}
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockRepository_Time_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Time'
|
||||
type MockRepository_Time_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Time is a helper method to define mock.On call
|
||||
func (_e *MockRepository_Expecter) Time() *MockRepository_Time_Call {
|
||||
return &MockRepository_Time_Call{Call: _e.mock.On("Time")}
|
||||
}
|
||||
|
||||
func (_c *MockRepository_Time_Call) Run(run func()) *MockRepository_Time_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_Time_Call) Return(time1 time.Time) *MockRepository_Time_Call {
|
||||
_c.Call.Return(time1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_Time_Call) RunAndReturn(run func() time.Time) *MockRepository_Time_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// UpdateDescription provides a mock function for the type MockRepository
|
||||
func (_mock *MockRepository) UpdateDescription(d string) {
|
||||
_mock.Called(d)
|
||||
return
|
||||
}
|
||||
|
||||
// MockRepository_UpdateDescription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDescription'
|
||||
type MockRepository_UpdateDescription_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// UpdateDescription is a helper method to define mock.On call
|
||||
// - d string
|
||||
func (_e *MockRepository_Expecter) UpdateDescription(d interface{}) *MockRepository_UpdateDescription_Call {
|
||||
return &MockRepository_UpdateDescription_Call{Call: _e.mock.On("UpdateDescription", d)}
|
||||
}
|
||||
|
||||
func (_c *MockRepository_UpdateDescription_Call) Run(run func(d string)) *MockRepository_UpdateDescription_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 string
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(string)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_UpdateDescription_Call) Return() *MockRepository_UpdateDescription_Call {
|
||||
_c.Call.Return()
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_UpdateDescription_Call) RunAndReturn(run func(d string)) *MockRepository_UpdateDescription_Call {
|
||||
_c.Run(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// VerifyObject provides a mock function for the type MockRepository
|
||||
func (_mock *MockRepository) VerifyObject(ctx context.Context, id object.ID) ([]content.ID, error) {
|
||||
ret := _mock.Called(ctx, id)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for VerifyObject")
|
||||
}
|
||||
|
||||
var r0 []content.ID
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, object.ID) ([]content.ID, error)); ok {
|
||||
return returnFunc(ctx, id)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, object.ID) []content.ID); ok {
|
||||
r0 = returnFunc(ctx, id)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]content.ID)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, object.ID) error); ok {
|
||||
r1 = returnFunc(ctx, id)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockRepository_VerifyObject_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'VerifyObject'
|
||||
type MockRepository_VerifyObject_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// VerifyObject is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - id object.ID
|
||||
func (_e *MockRepository_Expecter) VerifyObject(ctx interface{}, id interface{}) *MockRepository_VerifyObject_Call {
|
||||
return &MockRepository_VerifyObject_Call{Call: _e.mock.On("VerifyObject", ctx, id)}
|
||||
}
|
||||
|
||||
func (_c *MockRepository_VerifyObject_Call) Run(run func(ctx context.Context, id object.ID)) *MockRepository_VerifyObject_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 object.ID
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(object.ID)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_VerifyObject_Call) Return(vs []content.ID, err error) *MockRepository_VerifyObject_Call {
|
||||
_c.Call.Return(vs, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRepository_VerifyObject_Call) RunAndReturn(run func(ctx context.Context, id object.ID) ([]content.ID, error)) *MockRepository_VerifyObject_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,6 +19,7 @@ package kopialib
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
@@ -74,7 +75,9 @@ type kopiaObjectWriter struct {
|
||||
rawWriter object.Writer
|
||||
}
|
||||
|
||||
type openOptions struct{}
|
||||
type openOptions struct {
|
||||
repoLogger io.Writer
|
||||
}
|
||||
|
||||
const (
|
||||
defaultLogInterval = time.Second * 10
|
||||
@@ -154,7 +157,7 @@ func (ks *kopiaRepoService) Open(ctx context.Context, repoOption udmrepo.RepoOpt
|
||||
|
||||
repoCtx := kopia.SetupKopiaLog(ctx, ks.logger)
|
||||
|
||||
r, err := openKopiaRepo(repoCtx, repoConfig, repoOption.RepoPassword, nil)
|
||||
r, err := openKopiaRepo(repoCtx, repoConfig, repoOption.RepoPassword, &openOptions{repoLogger: kopia.RepositoryLogger(ks.logger)})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -199,7 +202,7 @@ func (ks *kopiaRepoService) Maintain(ctx context.Context, repoOption udmrepo.Rep
|
||||
|
||||
ks.logger.Info("Start to open repo for maintenance, allow index write on load")
|
||||
|
||||
r, err := openKopiaRepo(repoCtx, repoConfig, repoOption.RepoPassword, nil)
|
||||
r, err := openKopiaRepo(repoCtx, repoConfig, repoOption.RepoPassword, &openOptions{repoLogger: kopia.RepositoryLogger(ks.logger)})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -625,8 +628,10 @@ func (lt *logThrottle) shouldLog() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func openKopiaRepo(ctx context.Context, configFile string, password string, _ *openOptions) (repo.Repository, error) {
|
||||
r, err := kopiaRepoOpen(ctx, configFile, password, &repo.Options{})
|
||||
func openKopiaRepo(ctx context.Context, configFile string, password string, options *openOptions) (repo.Repository, error) {
|
||||
r, err := kopiaRepoOpen(ctx, configFile, password, &repo.Options{
|
||||
ContentLogWriter: options.repoLogger,
|
||||
})
|
||||
if os.IsNotExist(err) {
|
||||
return nil, errors.Wrap(err, "error to open repo, repo doesn't exist")
|
||||
}
|
||||
|
||||
@@ -38,13 +38,14 @@ import (
|
||||
)
|
||||
|
||||
func TestOpen(t *testing.T) {
|
||||
var directRpo *repomocks.DirectRepository
|
||||
var directRpo *repomocks.MockRepository
|
||||
testCases := []struct {
|
||||
name string
|
||||
repoOptions udmrepo.RepoOptions
|
||||
returnRepo *repomocks.DirectRepository
|
||||
returnRepo *repomocks.MockRepository
|
||||
repoOpen func(context.Context, string, string, *repo.Options) (repo.Repository, error)
|
||||
newWriterError error
|
||||
mockClose bool
|
||||
expectedErr string
|
||||
expected *kopiaRepository
|
||||
}{
|
||||
@@ -87,7 +88,8 @@ func TestOpen(t *testing.T) {
|
||||
repoOpen: func(context.Context, string, string, *repo.Options) (repo.Repository, error) {
|
||||
return directRpo, nil
|
||||
},
|
||||
returnRepo: new(repomocks.DirectRepository),
|
||||
returnRepo: repomocks.NewMockRepository(t),
|
||||
mockClose: true,
|
||||
newWriterError: errors.New("fake-new-writer-error"),
|
||||
expectedErr: "error to create repo writer: fake-new-writer-error",
|
||||
},
|
||||
@@ -100,7 +102,7 @@ func TestOpen(t *testing.T) {
|
||||
repoOpen: func(context.Context, string, string, *repo.Options) (repo.Repository, error) {
|
||||
return directRpo, nil
|
||||
},
|
||||
returnRepo: new(repomocks.DirectRepository),
|
||||
returnRepo: repomocks.NewMockRepository(t),
|
||||
expected: &kopiaRepository{
|
||||
description: "fake-description",
|
||||
throttle: logThrottle{
|
||||
@@ -128,7 +130,10 @@ func TestOpen(t *testing.T) {
|
||||
|
||||
if tc.returnRepo != nil {
|
||||
tc.returnRepo.On("NewWriter", mock.Anything, mock.Anything).Return(nil, nil, tc.newWriterError)
|
||||
tc.returnRepo.On("Close", mock.Anything).Return(nil)
|
||||
|
||||
if tc.mockClose {
|
||||
tc.returnRepo.On("Close", mock.Anything).Return(nil)
|
||||
}
|
||||
}
|
||||
|
||||
repo, err := service.Open(t.Context(), tc.repoOptions)
|
||||
@@ -149,12 +154,11 @@ func TestOpen(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMaintain(t *testing.T) {
|
||||
var directRpo *repomocks.DirectRepository
|
||||
testCases := []struct {
|
||||
name string
|
||||
repoOptions udmrepo.RepoOptions
|
||||
returnRepo *repomocks.DirectRepository
|
||||
returnRepoWriter *repomocks.DirectRepositoryWriter
|
||||
returnRepo *repomocks.MockRepository
|
||||
returnRepoWriter *repomocks.MockRepositoryWriter
|
||||
repoOpen func(context.Context, string, string, *repo.Options) (repo.Repository, error)
|
||||
newRepoWriterError error
|
||||
findManifestError error
|
||||
@@ -193,33 +197,6 @@ func TestMaintain(t *testing.T) {
|
||||
},
|
||||
expectedErr: "error to open repo: fake-repo-open-error",
|
||||
},
|
||||
{
|
||||
name: "write session fail",
|
||||
repoOptions: udmrepo.RepoOptions{
|
||||
ConfigFilePath: "/tmp",
|
||||
GeneralOptions: map[string]string{},
|
||||
},
|
||||
repoOpen: func(context.Context, string, string, *repo.Options) (repo.Repository, error) {
|
||||
return directRpo, nil
|
||||
},
|
||||
returnRepo: new(repomocks.DirectRepository),
|
||||
newRepoWriterError: errors.New("fake-new-direct-writer-error"),
|
||||
expectedErr: "error to maintain repo: unable to create direct writer: fake-new-direct-writer-error",
|
||||
},
|
||||
{
|
||||
name: "maintain fail",
|
||||
repoOptions: udmrepo.RepoOptions{
|
||||
ConfigFilePath: "/tmp",
|
||||
GeneralOptions: map[string]string{},
|
||||
},
|
||||
repoOpen: func(context.Context, string, string, *repo.Options) (repo.Repository, error) {
|
||||
return directRpo, nil
|
||||
},
|
||||
returnRepo: new(repomocks.DirectRepository),
|
||||
returnRepoWriter: new(repomocks.DirectRepositoryWriter),
|
||||
findManifestError: errors.New("fake-find-manifest-error"),
|
||||
expectedErr: "error to maintain repo: error to run maintenance under mode auto: unable to get maintenance params: error looking for maintenance manifest: fake-find-manifest-error",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
@@ -236,22 +213,9 @@ func TestMaintain(t *testing.T) {
|
||||
}
|
||||
|
||||
if tc.returnRepo != nil {
|
||||
directRpo = tc.returnRepo
|
||||
}
|
||||
|
||||
if tc.returnRepo != nil {
|
||||
tc.returnRepo.On("NewDirectWriter", mock.Anything, mock.Anything).Return(ctx, tc.returnRepoWriter, tc.newRepoWriterError)
|
||||
tc.returnRepo.On("Close", mock.Anything).Return(nil)
|
||||
}
|
||||
|
||||
if tc.returnRepoWriter != nil {
|
||||
tc.returnRepoWriter.On("DisableIndexRefresh").Return()
|
||||
tc.returnRepoWriter.On("AlsoLogToContentLog", mock.Anything).Return(nil)
|
||||
tc.returnRepoWriter.On("Close", mock.Anything).Return(nil)
|
||||
tc.returnRepoWriter.On("FindManifests", mock.Anything, mock.Anything).Return(nil, tc.findManifestError)
|
||||
tc.returnRepoWriter.On("ClientOptions").Return(repo.ClientOptions{})
|
||||
}
|
||||
|
||||
err := service.Maintain(ctx, tc.repoOptions)
|
||||
|
||||
if tc.expectedErr == "" {
|
||||
@@ -314,7 +278,7 @@ func TestShouldLog(t *testing.T) {
|
||||
func TestOpenObject(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
rawRepo *repomocks.DirectRepository
|
||||
rawRepo *repomocks.MockRepository
|
||||
objectID string
|
||||
retErr error
|
||||
expectedErr string
|
||||
@@ -325,13 +289,13 @@ func TestOpenObject(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "objectID is invalid",
|
||||
rawRepo: repomocks.NewDirectRepository(t),
|
||||
rawRepo: repomocks.NewMockRepository(t),
|
||||
objectID: "fake-id",
|
||||
expectedErr: "error to parse object ID from fake-id: malformed content ID: \"fake-id\": invalid content prefix",
|
||||
},
|
||||
{
|
||||
name: "raw open fail",
|
||||
rawRepo: repomocks.NewDirectRepository(t),
|
||||
rawRepo: repomocks.NewMockRepository(t),
|
||||
retErr: errors.New("fake-open-error"),
|
||||
expectedErr: "error to open object: fake-open-error",
|
||||
},
|
||||
@@ -363,7 +327,7 @@ func TestOpenObject(t *testing.T) {
|
||||
func TestGetManifest(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
rawRepo *repomocks.DirectRepository
|
||||
rawRepo *repomocks.MockRepository
|
||||
retErr error
|
||||
expectedErr string
|
||||
}{
|
||||
@@ -373,7 +337,7 @@ func TestGetManifest(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "raw get fail",
|
||||
rawRepo: repomocks.NewDirectRepository(t),
|
||||
rawRepo: repomocks.NewMockRepository(t),
|
||||
retErr: errors.New("fake-get-error"),
|
||||
expectedErr: "error to get manifest: fake-get-error",
|
||||
},
|
||||
@@ -405,7 +369,7 @@ func TestGetManifest(t *testing.T) {
|
||||
func TestFindManifests(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
rawRepo *repomocks.DirectRepository
|
||||
rawRepo *repomocks.MockRepository
|
||||
retErr error
|
||||
expectedErr string
|
||||
}{
|
||||
@@ -415,7 +379,7 @@ func TestFindManifests(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "raw find fail",
|
||||
rawRepo: repomocks.NewDirectRepository(t),
|
||||
rawRepo: repomocks.NewMockRepository(t),
|
||||
retErr: errors.New("fake-find-error"),
|
||||
expectedErr: "error to find manifests: fake-find-error",
|
||||
},
|
||||
@@ -444,8 +408,8 @@ func TestFindManifests(t *testing.T) {
|
||||
func TestClose(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
rawRepo *repomocks.DirectRepository
|
||||
rawWriter *repomocks.DirectRepositoryWriter
|
||||
rawRepo *repomocks.MockRepository
|
||||
rawWriter *repomocks.MockRepositoryWriter
|
||||
rawRepoRetErr error
|
||||
rawWriterRetErr error
|
||||
expectedErr string
|
||||
@@ -455,21 +419,21 @@ func TestClose(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "writer is not nil",
|
||||
rawWriter: repomocks.NewDirectRepositoryWriter(t),
|
||||
rawWriter: repomocks.NewMockRepositoryWriter(t),
|
||||
},
|
||||
{
|
||||
name: "repo is not nil",
|
||||
rawRepo: repomocks.NewDirectRepository(t),
|
||||
rawRepo: repomocks.NewMockRepository(t),
|
||||
},
|
||||
{
|
||||
name: "writer close error",
|
||||
rawWriter: repomocks.NewDirectRepositoryWriter(t),
|
||||
rawWriter: repomocks.NewMockRepositoryWriter(t),
|
||||
rawWriterRetErr: errors.New("fake-writer-close-error"),
|
||||
expectedErr: "error to close repo writer: fake-writer-close-error",
|
||||
},
|
||||
{
|
||||
name: "repo is not nil",
|
||||
rawRepo: repomocks.NewDirectRepository(t),
|
||||
rawRepo: repomocks.NewMockRepository(t),
|
||||
rawRepoRetErr: errors.New("fake-repo-close-error"),
|
||||
expectedErr: "error to close repo: fake-repo-close-error",
|
||||
},
|
||||
@@ -503,7 +467,7 @@ func TestClose(t *testing.T) {
|
||||
func TestPutManifest(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
rawWriter *repomocks.DirectRepositoryWriter
|
||||
rawWriter *repomocks.MockRepositoryWriter
|
||||
rawWriterRetErr error
|
||||
expectedErr string
|
||||
}{
|
||||
@@ -513,7 +477,7 @@ func TestPutManifest(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "raw put fail",
|
||||
rawWriter: repomocks.NewDirectRepositoryWriter(t),
|
||||
rawWriter: repomocks.NewMockRepositoryWriter(t),
|
||||
rawWriterRetErr: errors.New("fake-writer-put-error"),
|
||||
expectedErr: "error to put manifest: fake-writer-put-error",
|
||||
},
|
||||
@@ -544,7 +508,7 @@ func TestPutManifest(t *testing.T) {
|
||||
func TestDeleteManifest(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
rawWriter *repomocks.DirectRepositoryWriter
|
||||
rawWriter *repomocks.MockRepositoryWriter
|
||||
rawWriterRetErr error
|
||||
expectedErr string
|
||||
}{
|
||||
@@ -554,7 +518,7 @@ func TestDeleteManifest(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "raw delete fail",
|
||||
rawWriter: repomocks.NewDirectRepositoryWriter(t),
|
||||
rawWriter: repomocks.NewMockRepositoryWriter(t),
|
||||
rawWriterRetErr: errors.New("fake-writer-delete-error"),
|
||||
expectedErr: "error to delete manifest: fake-writer-delete-error",
|
||||
},
|
||||
@@ -583,7 +547,7 @@ func TestDeleteManifest(t *testing.T) {
|
||||
func TestFlush(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
rawWriter *repomocks.DirectRepositoryWriter
|
||||
rawWriter *repomocks.MockRepositoryWriter
|
||||
rawWriterRetErr error
|
||||
expectedErr string
|
||||
}{
|
||||
@@ -593,7 +557,7 @@ func TestFlush(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "raw flush fail",
|
||||
rawWriter: repomocks.NewDirectRepositoryWriter(t),
|
||||
rawWriter: repomocks.NewMockRepositoryWriter(t),
|
||||
rawWriterRetErr: errors.New("fake-writer-flush-error"),
|
||||
expectedErr: "error to flush repo: fake-writer-flush-error",
|
||||
},
|
||||
@@ -623,7 +587,7 @@ func TestConcatenateObjects(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
setWriter bool
|
||||
rawWriter *repomocks.DirectRepositoryWriter
|
||||
rawWriter *repomocks.MockRepositoryWriter
|
||||
rawWriterRetErr error
|
||||
objectIDs []udmrepo.ID
|
||||
expectedErr string
|
||||
@@ -649,7 +613,7 @@ func TestConcatenateObjects(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "concatenate error",
|
||||
rawWriter: repomocks.NewDirectRepositoryWriter(t),
|
||||
rawWriter: repomocks.NewMockRepositoryWriter(t),
|
||||
rawWriterRetErr: errors.New("fake-concatenate-error"),
|
||||
objectIDs: []udmrepo.ID{
|
||||
"I123456",
|
||||
@@ -659,7 +623,7 @@ func TestConcatenateObjects(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "succeed",
|
||||
rawWriter: repomocks.NewDirectRepositoryWriter(t),
|
||||
rawWriter: repomocks.NewMockRepositoryWriter(t),
|
||||
objectIDs: []udmrepo.ID{
|
||||
"I123456",
|
||||
},
|
||||
@@ -695,7 +659,7 @@ func TestNewObjectWriter(t *testing.T) {
|
||||
rawObjWriter := repomocks.NewWriter(t)
|
||||
testCases := []struct {
|
||||
name string
|
||||
rawWriter *repomocks.DirectRepositoryWriter
|
||||
rawWriter *repomocks.MockRepositoryWriter
|
||||
rawWriterRet object.Writer
|
||||
expectedRet udmrepo.ObjectWriter
|
||||
}{
|
||||
@@ -704,11 +668,11 @@ func TestNewObjectWriter(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "new object writer fail",
|
||||
rawWriter: repomocks.NewDirectRepositoryWriter(t),
|
||||
rawWriter: repomocks.NewMockRepositoryWriter(t),
|
||||
},
|
||||
{
|
||||
name: "succeed",
|
||||
rawWriter: repomocks.NewDirectRepositoryWriter(t),
|
||||
rawWriter: repomocks.NewMockRepositoryWriter(t),
|
||||
rawWriterRet: rawObjWriter,
|
||||
expectedRet: &kopiaObjectWriter{rawWriter: rawObjWriter},
|
||||
},
|
||||
|
||||
@@ -32,6 +32,7 @@ import (
|
||||
"github.com/kopia/kopia/repo/maintenance"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/vmware-tanzu/velero/pkg/kopia"
|
||||
"github.com/vmware-tanzu/velero/pkg/repository/udmrepo"
|
||||
"github.com/vmware-tanzu/velero/pkg/repository/udmrepo/kopialib/backend"
|
||||
)
|
||||
@@ -354,7 +355,7 @@ func (b *byteBufferReader) Seek(offset int64, whence int) (int64, error) {
|
||||
var funcGetParam = maintenance.GetParams
|
||||
|
||||
func writeInitParameters(ctx context.Context, repoOption udmrepo.RepoOptions, logger logrus.FieldLogger) error {
|
||||
r, err := openKopiaRepo(ctx, repoOption.ConfigFilePath, repoOption.RepoPassword, nil)
|
||||
r, err := openKopiaRepo(ctx, repoOption.ConfigFilePath, repoOption.RepoPassword, &openOptions{repoLogger: kopia.RepositoryLogger(logger)})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -471,15 +471,15 @@ func TestGetRepositoryStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWriteInitParameters(t *testing.T) {
|
||||
var directRpo *repomocks.DirectRepository
|
||||
var directRpo *repomocks.MockRepository
|
||||
assertFullMaintIntervalEqual := func(expected, actual *maintenance.Params) bool {
|
||||
return assert.Equal(t, expected.FullCycle.Interval, actual.FullCycle.Interval)
|
||||
}
|
||||
testCases := []struct {
|
||||
name string
|
||||
repoOptions udmrepo.RepoOptions
|
||||
returnRepo *repomocks.DirectRepository
|
||||
returnRepoWriter *repomocks.DirectRepositoryWriter
|
||||
returnRepo *repomocks.MockRepository
|
||||
returnRepoWriter *repomocks.MockRepositoryWriter
|
||||
repoOpen func(context.Context, string, string, *repo.Options) (repo.Repository, error)
|
||||
newRepoWriterError error
|
||||
replaceManifestError error
|
||||
@@ -488,6 +488,8 @@ func TestWriteInitParameters(t *testing.T) {
|
||||
expectedReplaceManifestsParams *maintenance.Params
|
||||
// allows for asserting only certain fields are set as expected
|
||||
assertReplaceManifestsParams func(*maintenance.Params, *maintenance.Params) bool
|
||||
mockNewWriter bool
|
||||
mockClientOptions bool
|
||||
expectedErr string
|
||||
}{
|
||||
{
|
||||
@@ -524,7 +526,7 @@ func TestWriteInitParameters(t *testing.T) {
|
||||
getParam: func(context.Context, repo.Repository) (*maintenance.Params, error) {
|
||||
return nil, errors.New("fake-get-param-error")
|
||||
},
|
||||
returnRepo: new(repomocks.DirectRepository),
|
||||
returnRepo: repomocks.NewMockRepository(t),
|
||||
expectedErr: "error getting existing maintenance params: fake-get-param-error",
|
||||
},
|
||||
{
|
||||
@@ -541,6 +543,7 @@ func TestWriteInitParameters(t *testing.T) {
|
||||
Owner: "default@default",
|
||||
}, nil
|
||||
},
|
||||
returnRepo: repomocks.NewMockRepository(t),
|
||||
},
|
||||
{
|
||||
name: "existing param with different owner",
|
||||
@@ -556,13 +559,15 @@ func TestWriteInitParameters(t *testing.T) {
|
||||
Owner: "fake-owner",
|
||||
}, nil
|
||||
},
|
||||
returnRepo: new(repomocks.DirectRepository),
|
||||
returnRepoWriter: new(repomocks.DirectRepositoryWriter),
|
||||
returnRepo: repomocks.NewMockRepository(t),
|
||||
returnRepoWriter: repomocks.NewMockRepositoryWriter(t),
|
||||
expectedReplaceManifestsParams: &maintenance.Params{
|
||||
FullCycle: maintenance.CycleParams{
|
||||
Interval: udmrepo.NormalGCInterval,
|
||||
},
|
||||
},
|
||||
mockNewWriter: true,
|
||||
mockClientOptions: true,
|
||||
assertReplaceManifestsParams: assertFullMaintIntervalEqual,
|
||||
},
|
||||
{
|
||||
@@ -574,7 +579,8 @@ func TestWriteInitParameters(t *testing.T) {
|
||||
repoOpen: func(context.Context, string, string, *repo.Options) (repo.Repository, error) {
|
||||
return directRpo, nil
|
||||
},
|
||||
returnRepo: new(repomocks.DirectRepository),
|
||||
returnRepo: repomocks.NewMockRepository(t),
|
||||
mockNewWriter: true,
|
||||
newRepoWriterError: errors.New("fake-new-writer-error"),
|
||||
expectedErr: "error to init write repo parameters: unable to create writer: fake-new-writer-error",
|
||||
},
|
||||
@@ -587,8 +593,10 @@ func TestWriteInitParameters(t *testing.T) {
|
||||
repoOpen: func(context.Context, string, string, *repo.Options) (repo.Repository, error) {
|
||||
return directRpo, nil
|
||||
},
|
||||
returnRepo: new(repomocks.DirectRepository),
|
||||
returnRepoWriter: new(repomocks.DirectRepositoryWriter),
|
||||
returnRepo: repomocks.NewMockRepository(t),
|
||||
returnRepoWriter: repomocks.NewMockRepositoryWriter(t),
|
||||
mockNewWriter: true,
|
||||
mockClientOptions: true,
|
||||
replaceManifestError: errors.New("fake-replace-manifest-error"),
|
||||
expectedErr: "error to init write repo parameters: error to set maintenance params: put manifest: fake-replace-manifest-error",
|
||||
},
|
||||
@@ -603,8 +611,10 @@ func TestWriteInitParameters(t *testing.T) {
|
||||
repoOpen: func(context.Context, string, string, *repo.Options) (repo.Repository, error) {
|
||||
return directRpo, nil
|
||||
},
|
||||
returnRepo: new(repomocks.DirectRepository),
|
||||
returnRepoWriter: new(repomocks.DirectRepositoryWriter),
|
||||
returnRepo: repomocks.NewMockRepository(t),
|
||||
returnRepoWriter: repomocks.NewMockRepositoryWriter(t),
|
||||
mockNewWriter: true,
|
||||
mockClientOptions: true,
|
||||
expectedReplaceManifestsParams: &maintenance.Params{
|
||||
FullCycle: maintenance.CycleParams{
|
||||
Interval: udmrepo.FastGCInterval,
|
||||
@@ -623,8 +633,10 @@ func TestWriteInitParameters(t *testing.T) {
|
||||
repoOpen: func(context.Context, string, string, *repo.Options) (repo.Repository, error) {
|
||||
return directRpo, nil
|
||||
},
|
||||
returnRepo: new(repomocks.DirectRepository),
|
||||
returnRepoWriter: new(repomocks.DirectRepositoryWriter),
|
||||
returnRepo: repomocks.NewMockRepository(t),
|
||||
returnRepoWriter: repomocks.NewMockRepositoryWriter(t),
|
||||
mockNewWriter: true,
|
||||
mockClientOptions: true,
|
||||
expectedReplaceManifestsParams: &maintenance.Params{
|
||||
FullCycle: maintenance.CycleParams{
|
||||
Interval: udmrepo.NormalGCInterval,
|
||||
@@ -643,8 +655,9 @@ func TestWriteInitParameters(t *testing.T) {
|
||||
repoOpen: func(context.Context, string, string, *repo.Options) (repo.Repository, error) {
|
||||
return directRpo, nil
|
||||
},
|
||||
returnRepo: new(repomocks.DirectRepository),
|
||||
returnRepoWriter: new(repomocks.DirectRepositoryWriter),
|
||||
returnRepo: repomocks.NewMockRepository(t),
|
||||
returnRepoWriter: repomocks.NewMockRepositoryWriter(t),
|
||||
mockNewWriter: true,
|
||||
expectedErr: "error to init write repo parameters: invalid full maintenance interval option foo",
|
||||
},
|
||||
}
|
||||
@@ -663,8 +676,14 @@ func TestWriteInitParameters(t *testing.T) {
|
||||
}
|
||||
|
||||
if tc.returnRepo != nil {
|
||||
tc.returnRepo.On("NewWriter", mock.Anything, mock.Anything).Return(ctx, tc.returnRepoWriter, tc.newRepoWriterError)
|
||||
tc.returnRepo.On("ClientOptions").Return(repo.ClientOptions{})
|
||||
if tc.mockNewWriter {
|
||||
tc.returnRepo.On("NewWriter", mock.Anything, mock.Anything).Return(ctx, tc.returnRepoWriter, tc.newRepoWriterError)
|
||||
}
|
||||
|
||||
if tc.mockClientOptions {
|
||||
tc.returnRepo.On("ClientOptions").Return(repo.ClientOptions{})
|
||||
}
|
||||
|
||||
tc.returnRepo.On("Close", mock.Anything).Return(nil)
|
||||
}
|
||||
|
||||
|
||||
@@ -68,10 +68,10 @@ type RestorePVC struct {
|
||||
|
||||
type CachePVC struct {
|
||||
// StorageClass specifies the storage class for cache PVC
|
||||
StorageClass string
|
||||
StorageClass string `json:"storageClass,omitempty"`
|
||||
|
||||
// ResidentThreshold specifies the minimum size of the backup data to create cache PVC
|
||||
ResidentThreshold int64
|
||||
// ResidentThresholdInMB specifies the minimum size of the backup data to create cache PVC
|
||||
ResidentThresholdInMB int64 `json:"residentThresholdInMB,omitempty"`
|
||||
}
|
||||
|
||||
type NodeAgentConfigs struct {
|
||||
|
||||
@@ -140,7 +140,13 @@ func EnsureDeletePod(ctx context.Context, podGetter corev1client.CoreV1Interface
|
||||
func IsPodUnrecoverable(pod *corev1api.Pod, log logrus.FieldLogger) (bool, string) {
|
||||
// Check the Phase field
|
||||
if pod.Status.Phase == corev1api.PodFailed || pod.Status.Phase == corev1api.PodUnknown {
|
||||
message := GetPodTerminateMessage(pod)
|
||||
message := ""
|
||||
if pod.Status.Message != "" {
|
||||
message += pod.Status.Message + "/"
|
||||
}
|
||||
|
||||
message += GetPodTerminateMessage(pod)
|
||||
|
||||
log.Warnf("Pod is in abnormal state %s, message [%s]", pod.Status.Phase, message)
|
||||
return true, fmt.Sprintf("Pod is in abnormal state [%s], message [%s]", pod.Status.Phase, message)
|
||||
}
|
||||
@@ -269,7 +275,7 @@ func ToSystemAffinity(loadAffinities []*LoadAffinity) *corev1api.Affinity {
|
||||
}
|
||||
|
||||
func DiagnosePod(pod *corev1api.Pod, events *corev1api.EventList) string {
|
||||
diag := fmt.Sprintf("Pod %s/%s, phase %s, node name %s\n", pod.Namespace, pod.Name, pod.Status.Phase, pod.Spec.NodeName)
|
||||
diag := fmt.Sprintf("Pod %s/%s, phase %s, node name %s, message %s\n", pod.Namespace, pod.Name, pod.Status.Phase, pod.Spec.NodeName, pod.Status.Message)
|
||||
|
||||
for _, condition := range pod.Status.Conditions {
|
||||
diag += fmt.Sprintf("Pod condition %s, status %s, reason %s, message %s\n", condition.Type, condition.Status, condition.Reason, condition.Message)
|
||||
|
||||
@@ -925,9 +925,10 @@ func TestDiagnosePod(t *testing.T) {
|
||||
Message: "fake-message-2",
|
||||
},
|
||||
},
|
||||
Message: "fake-message-3",
|
||||
},
|
||||
},
|
||||
expected: "Pod fake-ns/fake-pod, phase Pending, node name fake-node\nPod condition Initialized, status True, reason fake-reason-1, message fake-message-1\nPod condition PodScheduled, status False, reason fake-reason-2, message fake-message-2\n",
|
||||
expected: "Pod fake-ns/fake-pod, phase Pending, node name fake-node, message fake-message-3\nPod condition Initialized, status True, reason fake-reason-1, message fake-message-1\nPod condition PodScheduled, status False, reason fake-reason-2, message fake-message-2\n",
|
||||
},
|
||||
{
|
||||
name: "pod with all info and empty event list",
|
||||
@@ -955,10 +956,11 @@ func TestDiagnosePod(t *testing.T) {
|
||||
Message: "fake-message-2",
|
||||
},
|
||||
},
|
||||
Message: "fake-message-3",
|
||||
},
|
||||
},
|
||||
events: &corev1api.EventList{},
|
||||
expected: "Pod fake-ns/fake-pod, phase Pending, node name fake-node\nPod condition Initialized, status True, reason fake-reason-1, message fake-message-1\nPod condition PodScheduled, status False, reason fake-reason-2, message fake-message-2\n",
|
||||
expected: "Pod fake-ns/fake-pod, phase Pending, node name fake-node, message fake-message-3\nPod condition Initialized, status True, reason fake-reason-1, message fake-message-1\nPod condition PodScheduled, status False, reason fake-reason-2, message fake-message-2\n",
|
||||
},
|
||||
{
|
||||
name: "pod with all info and events",
|
||||
@@ -987,6 +989,7 @@ func TestDiagnosePod(t *testing.T) {
|
||||
Message: "fake-message-2",
|
||||
},
|
||||
},
|
||||
Message: "fake-message-3",
|
||||
},
|
||||
},
|
||||
events: &corev1api.EventList{Items: []corev1api.Event{
|
||||
@@ -1027,7 +1030,7 @@ func TestDiagnosePod(t *testing.T) {
|
||||
Message: "message-6",
|
||||
},
|
||||
}},
|
||||
expected: "Pod fake-ns/fake-pod, phase Pending, node name fake-node\nPod condition Initialized, status True, reason fake-reason-1, message fake-message-1\nPod condition PodScheduled, status False, reason fake-reason-2, message fake-message-2\nPod event reason reason-3, message message-3\nPod event reason reason-6, message message-6\n",
|
||||
expected: "Pod fake-ns/fake-pod, phase Pending, node name fake-node, message fake-message-3\nPod condition Initialized, status True, reason fake-reason-1, message fake-message-1\nPod condition PodScheduled, status False, reason fake-reason-2, message fake-message-2\nPod event reason reason-3, message message-3\nPod event reason reason-6, message message-6\n",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user