Skip to content

Commit

Permalink
Update deps (#1534)
Browse files Browse the repository at this point in the history
* Update deps

/cherry-pick

Signed-off-by: Tamal Saha <tamal@appscode.com>

* Update conditions util

Signed-off-by: Tamal Saha <tamal@appscode.com>

---------

Signed-off-by: Tamal Saha <tamal@appscode.com>
  • Loading branch information
tamalsaha authored Aug 14, 2023
1 parent 93a4b4c commit 06bacfd
Show file tree
Hide file tree
Showing 52 changed files with 2,112 additions and 654 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
gomodules.xyz/envsubst v0.1.0
gomodules.xyz/flags v0.1.3
gomodules.xyz/go-sh v0.1.0
gomodules.xyz/logs v0.0.6
gomodules.xyz/logs v0.0.7
gomodules.xyz/pointer v0.1.0
gomodules.xyz/runtime v0.3.0
gomodules.xyz/stow v0.2.4
Expand All @@ -35,7 +35,7 @@ require (
k8s.io/klog/v2 v2.80.1
k8s.io/kube-aggregator v0.25.1
k8s.io/kubernetes v0.0.0-00010101000000-000000000000
kmodules.xyz/client-go v0.25.23
kmodules.xyz/client-go v0.25.29
kmodules.xyz/constants v0.0.0-20220317041001-545c1e31a70a
kmodules.xyz/csi-utils v0.25.4
kmodules.xyz/custom-resources v0.25.2
Expand All @@ -45,7 +45,7 @@ require (
kmodules.xyz/prober v0.25.0
kmodules.xyz/webhook-runtime v0.25.0
sigs.k8s.io/controller-runtime v0.13.1
stash.appscode.dev/apimachinery v0.30.0
stash.appscode.dev/apimachinery v0.30.1-0.20230814025143-fcb8a9106d3c
)

require (
Expand Down Expand Up @@ -169,7 +169,7 @@ require (
golang.org/x/time v0.1.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
gomodules.xyz/clock v0.0.0-20200817085942-06523dba733f // indirect
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
gomodules.xyz/jsonpath v0.0.2 // indirect
gomodules.xyz/mergo v0.3.13 // indirect
gomodules.xyz/password-generator v0.2.9 // indirect
Expand Down
19 changes: 9 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
Expand Down Expand Up @@ -639,6 +638,7 @@ github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo=
github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM=
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
Expand Down Expand Up @@ -1032,12 +1032,12 @@ gomodules.xyz/flags v0.1.3 h1:jQ06+EfmoMv5NvjXvJon03dOhLU+FF0TQMWN7I6qpzs=
gomodules.xyz/flags v0.1.3/go.mod h1:e+kvBLnqdEWGG670SKOYag1CXStM2Slrxq01OIK3tFs=
gomodules.xyz/go-sh v0.1.0 h1:1BJAuGREh2RhePt7HRrpmjnkbgfpXlCzc42SiyZ5dkc=
gomodules.xyz/go-sh v0.1.0/go.mod h1:N8IrjNiYppUI/rxENYrWD6FOrSxSyEZnIekPEWM7LP0=
gomodules.xyz/jsonpatch/v2 v2.3.0 h1:8NFhfS6gzxNqjLIYnZxg319wZ5Qjnx4m/CcX+Klzazc=
gomodules.xyz/jsonpatch/v2 v2.3.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY=
gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw=
gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY=
gomodules.xyz/jsonpath v0.0.2 h1:taUvqxKQ9KqVl3vq/+hLg7rCZUIQjq+izhbvo6nTIkE=
gomodules.xyz/jsonpath v0.0.2/go.mod h1:du28vmLHrgEV48JqK/7rn92YHsVDoQuqrowb2w6YZmE=
gomodules.xyz/logs v0.0.6 h1:8+9Wkud5yBPtIvkVszubyTeFxNII30lWODom0+GZD8U=
gomodules.xyz/logs v0.0.6/go.mod h1:Q+fFtZFLEB5q86KmDehXCGuMP72Rv+Rwz0KuVxK+Gi4=
gomodules.xyz/logs v0.0.7 h1:dkhpdQuzj+pOS3S7VaOq+JV7BVU7f68/k3uDYufhPow=
gomodules.xyz/logs v0.0.7/go.mod h1:IEIZbRl9zua2jb35NU4KoqxUEDPmKvem3PhfRHqQI54=
gomodules.xyz/mergo v0.3.13 h1:q6cL/MMXZH/MrR2+yjSihFFq6UifXqjwaqI48B6cMEM=
gomodules.xyz/mergo v0.3.13/go.mod h1:F/2rKC7j0URTnHUKDiTiLcGdLMhdv8jK2Za3cRTUVmc=
gomodules.xyz/password-generator v0.2.9 h1:qYoXoA61+9zs9A1scffefCgcRGpi9Tw1LsTkIe4bEno=
Expand Down Expand Up @@ -1231,7 +1231,6 @@ k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8
k8s.io/gengo v0.0.0-20200428234225-8167cfdcfc14/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
k8s.io/klog/v2 v2.8.0/go.mod h1:hy9LJ/NvuK+iVyP4Ehqva4HxZG/oXyIS3n3Jmire4Ec=
k8s.io/klog/v2 v2.80.1 h1:atnLQ121W371wYYFawwYx1aEY2eUfs4l3J72wtgAwV4=
k8s.io/klog/v2 v2.80.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
k8s.io/kube-aggregator v0.25.1 h1:XJajtusVLQ13kRPFL1xeQ2cHIzGTuXgOet1lMRF89+o=
Expand All @@ -1244,8 +1243,8 @@ k8s.io/utils v0.0.0-20220823124924-e9cbc92d1a73 h1:H9TCJUUx+2VA0ZiD9lvtaX8fthFsM
k8s.io/utils v0.0.0-20220823124924-e9cbc92d1a73/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
kmodules.xyz/apiversion v0.2.0 h1:vAQYqZFm4xu4pbB1cAdHbFEPES6EQkcR4wc06xdTOWk=
kmodules.xyz/apiversion v0.2.0/go.mod h1:oPX8g8LvlPdPX3Yc5YvCzJHQnw3YF/X4/jdW0b1am80=
kmodules.xyz/client-go v0.25.23 h1:qz5XJYHLVZUowqfRXEJD7JQ4iaLLzQ1O1zPMmsdrkJw=
kmodules.xyz/client-go v0.25.23/go.mod h1:wbdzLEoDYiCPI6dTW0mIAGNwkwFV4lC5BN1FJxiDsbw=
kmodules.xyz/client-go v0.25.29 h1:6CYoTJdLBqdXAaNtWJb1LLowG6KuDwb53ey8u7DS88Y=
kmodules.xyz/client-go v0.25.29/go.mod h1:r/Va2Y6t1G8X1sPRjrQC6FWB3oh/i6rjssmlfJnbCmg=
kmodules.xyz/constants v0.0.0-20220317041001-545c1e31a70a h1:wo6TxmquRJwXXX/HejI6NRyfx13UzuHGjndTumlutbc=
kmodules.xyz/constants v0.0.0-20220317041001-545c1e31a70a/go.mod h1:3C5i73Z7fcMVyu5TXtPuizGD8vWAbesXFVp1ESbIa1k=
kmodules.xyz/csi-utils v0.25.4 h1:fwTgihG/MEfjhGQylzcb0vqlsCfFT5pdYKRxdg7XrM0=
Expand Down Expand Up @@ -1287,5 +1286,5 @@ sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
stash.appscode.dev/apimachinery v0.30.0 h1:imc3OuXaCI8B9ImB1e4QtDYhZCc2VyiXQHW5gheKG/s=
stash.appscode.dev/apimachinery v0.30.0/go.mod h1:xEWpZn0wmhP0Acpq7cpebNbMXwIui8Crh4dpuE9FHSQ=
stash.appscode.dev/apimachinery v0.30.1-0.20230814025143-fcb8a9106d3c h1:/3plffjueo5ffL+XhHAtluJ9TfP+K9elbY1tyIxNeKY=
stash.appscode.dev/apimachinery v0.30.1-0.20230814025143-fcb8a9106d3c/go.mod h1:IDbssRbYLSnMwZAQOGX4Vam+hl43FofP8BuXMLXVaPQ=
3 changes: 2 additions & 1 deletion pkg/backup/backupsession.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
"k8s.io/client-go/tools/record"
"k8s.io/klog/v2"
kmapi "kmodules.xyz/client-go/api/v1"
condutil "kmodules.xyz/client-go/conditions"
"kmodules.xyz/client-go/meta"
"kmodules.xyz/client-go/tools/queue"
v1 "kmodules.xyz/offshoot-api/api/v1"
Expand Down Expand Up @@ -481,7 +482,7 @@ func (c *BackupSessionController) isBackupTakenForThisHost(backupSession *api_v1
if backupSession.Status.Phase == api_v1beta1.BackupSessionSucceeded ||
backupSession.Status.Phase == api_v1beta1.BackupSessionFailed ||
backupSession.Status.Phase == api_v1beta1.BackupSessionSkipped ||
kmapi.IsConditionFalse(backupSession.Status.Conditions, api_v1beta1.GlobalPreBackupHookSucceeded) {
condutil.IsConditionFalse(backupSession.Status.Conditions, api_v1beta1.GlobalPreBackupHookSucceeded) {
return true
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/cmds/create_volumesnapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func (opt *VSoption) createVolumeSnapshot(bsMeta metav1.ObjectMeta, inv invoker.

backupOutput.BackupTargetStatus.Conditions = append(backupOutput.BackupTargetStatus.Conditions, kmapi.Condition{
Type: api_v1beta1.PreBackupHookExecutionSucceeded,
Status: corev1.ConditionTrue,
Status: metav1.ConditionTrue,
Reason: api_v1beta1.SuccessfullyExecutedPreBackupHook,
Message: "Successfully executed preBackup hook.",
LastTransitionTime: metav1.Now(),
Expand Down Expand Up @@ -236,7 +236,7 @@ func (opt *VSoption) createVolumeSnapshot(bsMeta metav1.ObjectMeta, inv invoker.
}
backupOutput.BackupTargetStatus.Conditions = append(backupOutput.BackupTargetStatus.Conditions, kmapi.Condition{
Type: api_v1beta1.PostBackupHookExecutionSucceeded,
Status: corev1.ConditionTrue,
Status: metav1.ConditionTrue,
Reason: api_v1beta1.SuccessfullyExecutedPostBackupHook,
Message: "Successfully executed postBackup hook",
LastTransitionTime: metav1.Now(),
Expand Down
17 changes: 9 additions & 8 deletions pkg/controller/backup_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
"k8s.io/klog/v2"
kutil "kmodules.xyz/client-go"
kmapi "kmodules.xyz/client-go/api/v1"
condutil "kmodules.xyz/client-go/conditions"
"kmodules.xyz/client-go/meta"
"kmodules.xyz/client-go/tools/queue"
"kmodules.xyz/webhook-runtime/admission"
Expand Down Expand Up @@ -540,7 +541,7 @@ func (r *backupSessionReconciler) initiateTargetBackup(index int) error {
}

func (r *backupSessionReconciler) isBackupHistoryCleaned() bool {
return kmapi.HasCondition(r.session.GetConditions(), api_v1beta1.BackupHistoryCleaned)
return condutil.HasCondition(r.session.GetConditions(), api_v1beta1.BackupHistoryCleaned)
}

// cleanupBackupHistory deletes old BackupSessions and theirs associate resources according to BackupHistoryLimit
Expand Down Expand Up @@ -623,7 +624,7 @@ func (r *backupSessionReconciler) shouldWaitForTargetPostBackupHookExecution() b
func (r *backupSessionReconciler) targetPreBackupHookFailed(targetRef api_v1beta1.TargetRef) bool {
for _, s := range r.session.GetTargetStatus() {
if invoker.TargetMatched(s.Ref, targetRef) {
return kmapi.IsConditionFalse(s.Conditions, api_v1beta1.PreBackupHookExecutionSucceeded)
return condutil.IsConditionFalse(s.Conditions, api_v1beta1.PreBackupHookExecutionSucceeded)
}
}
return false
Expand All @@ -636,7 +637,7 @@ func (r *backupSessionReconciler) postBackupHookExecutedForTarget(targetInfo inv

for _, s := range r.session.GetTargetStatus() {
if invoker.TargetMatched(s.Ref, targetInfo.Target.Ref) {
if kmapi.HasCondition(s.Conditions, api_v1beta1.PostBackupHookExecutionSucceeded) {
if condutil.HasCondition(s.Conditions, api_v1beta1.PostBackupHookExecutionSucceeded) {
return true
}
}
Expand All @@ -650,7 +651,7 @@ func (r *backupSessionReconciler) shouldExecuteGlobalPostBackupHook() bool {
if r.globalPreBackupHookFailed() {
return false
}
return !kmapi.HasCondition(r.session.GetConditions(), api_v1beta1.GlobalPostBackupHookSucceeded)
return !condutil.HasCondition(r.session.GetConditions(), api_v1beta1.GlobalPostBackupHookSucceeded)
}
return false
}
Expand Down Expand Up @@ -695,7 +696,7 @@ func (r *backupSessionReconciler) executeGlobalPostBackupHook() error {
func (r *backupSessionReconciler) shouldExecuteGlobalPreBackupHook() bool {
hook := r.invoker.GetGlobalHooks()
if hook != nil && hook.PreBackup != nil {
return !kmapi.HasCondition(r.session.GetConditions(), api_v1beta1.GlobalPreBackupHookSucceeded)
return !condutil.HasCondition(r.session.GetConditions(), api_v1beta1.GlobalPreBackupHookSucceeded)
}
return false
}
Expand Down Expand Up @@ -809,7 +810,7 @@ func (r *backupSessionReconciler) isSessionCompleted() bool {
return true
}

if kmapi.IsConditionTrue(r.session.GetConditions(), api_v1beta1.DeadlineExceeded) {
if condutil.IsConditionTrue(r.session.GetConditions(), api_v1beta1.DeadlineExceeded) {
return true
}

Expand All @@ -820,7 +821,7 @@ func (r *backupSessionReconciler) isSessionCompleted() bool {
}

func (r *backupSessionReconciler) globalPreBackupHookFailed() bool {
return kmapi.IsConditionFalse(r.session.GetConditions(), api_v1beta1.GlobalPreBackupHookSucceeded)
return condutil.IsConditionFalse(r.session.GetConditions(), api_v1beta1.GlobalPreBackupHookSucceeded)
}

func (r *backupSessionReconciler) isBackupRunning() bool {
Expand Down Expand Up @@ -913,7 +914,7 @@ func (r *backupSessionReconciler) getIncompleteBackupSessionForTarget(targetRef
}

func (r *backupSessionReconciler) backupMetricPushed() bool {
return kmapi.IsConditionTrue(r.session.GetConditions(), api_v1beta1.MetricsPushed)
return condutil.IsConditionTrue(r.session.GetConditions(), api_v1beta1.MetricsPushed)
}

func (r *backupSessionReconciler) sendBackupMetrics() error {
Expand Down
17 changes: 9 additions & 8 deletions pkg/controller/restore_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"k8s.io/klog/v2"
kutil "kmodules.xyz/client-go"
kmapi "kmodules.xyz/client-go/api/v1"
condutil "kmodules.xyz/client-go/conditions"
core_util "kmodules.xyz/client-go/core/v1"
"kmodules.xyz/client-go/meta"
"kmodules.xyz/client-go/tools/queue"
Expand Down Expand Up @@ -392,7 +393,7 @@ func (r *restoreInvokerReconciler) isSessionCompleted() bool {
return true
}

if kmapi.IsConditionTrue(r.invoker.GetStatus().Conditions, api_v1beta1.DeadlineExceeded) {
if condutil.IsConditionTrue(r.invoker.GetStatus().Conditions, api_v1beta1.DeadlineExceeded) {
return true
}

Expand All @@ -403,7 +404,7 @@ func (r *restoreInvokerReconciler) isSessionCompleted() bool {
}

func (r *restoreInvokerReconciler) globalPreRestoreHookFailed() bool {
return kmapi.IsConditionFalse(r.invoker.GetStatus().Conditions, api_v1beta1.GlobalPreRestoreHookSucceeded)
return condutil.IsConditionFalse(r.invoker.GetStatus().Conditions, api_v1beta1.GlobalPreRestoreHookSucceeded)
}

func (r *restoreInvokerReconciler) shouldWaitForTargetPostRestoreHookExecution() bool {
Expand All @@ -423,7 +424,7 @@ func (r *restoreInvokerReconciler) shouldWaitForTargetPostRestoreHookExecution()
func (r *restoreInvokerReconciler) targetPreRestoreHookFailed(targetRef api_v1beta1.TargetRef) bool {
for _, s := range r.invoker.GetStatus().TargetStatus {
if invoker.TargetMatched(s.Ref, targetRef) {
return kmapi.IsConditionFalse(s.Conditions, api_v1beta1.PreRestoreHookExecutionSucceeded)
return condutil.IsConditionFalse(s.Conditions, api_v1beta1.PreRestoreHookExecutionSucceeded)
}
}
return false
Expand All @@ -437,7 +438,7 @@ func (r *restoreInvokerReconciler) postRestoreHookExecutedForTarget(targetInfo i

for _, s := range status.TargetStatus {
if invoker.TargetMatched(s.Ref, targetInfo.Target.Ref) {
if kmapi.HasCondition(s.Conditions, api_v1beta1.PostRestoreHookExecutionSucceeded) {
if condutil.HasCondition(s.Conditions, api_v1beta1.PostRestoreHookExecutionSucceeded) {
return true
}
}
Expand All @@ -451,7 +452,7 @@ func (r *restoreInvokerReconciler) shouldExecuteGlobalPostRestoreHook() bool {
if r.globalPreRestoreHookFailed() {
return false
}
return !kmapi.HasCondition(r.invoker.GetStatus().Conditions, api_v1beta1.GlobalPostRestoreHookSucceeded)
return !condutil.HasCondition(r.invoker.GetStatus().Conditions, api_v1beta1.GlobalPostRestoreHookSucceeded)
}
return false
}
Expand Down Expand Up @@ -493,7 +494,7 @@ func (r *restoreInvokerReconciler) executeGlobalPostRestoreHook() error {
func (r *restoreInvokerReconciler) shouldExecuteGlobalPreRestoreHook() bool {
hook := r.invoker.GetGlobalHooks()
if hook != nil && hook.PreRestore != nil {
return !kmapi.HasCondition(r.invoker.GetStatus().Conditions, api_v1beta1.GlobalPreRestoreHookSucceeded)
return !condutil.HasCondition(r.invoker.GetStatus().Conditions, api_v1beta1.GlobalPreRestoreHookSucceeded)
}
return false
}
Expand Down Expand Up @@ -524,7 +525,7 @@ func (r *restoreInvokerReconciler) targetRestoreInitiated(targetRef api_v1beta1.
}
for _, target := range status.TargetStatus {
if invoker.TargetMatched(target.Ref, targetRef) {
return kmapi.HasCondition(target.Conditions, api_v1beta1.RestoreExecutorEnsured) || target.Phase == api_v1beta1.TargetRestoreRunning
return condutil.HasCondition(target.Conditions, api_v1beta1.RestoreExecutorEnsured) || target.Phase == api_v1beta1.TargetRestoreRunning
}
}
return false
Expand Down Expand Up @@ -557,7 +558,7 @@ func (r *restoreInvokerReconciler) setTargetRestorePending(targetRef api_v1beta1
}

func restoreMetricsPushed(conditions []kmapi.Condition) bool {
return kmapi.IsConditionTrue(conditions, api_v1beta1.MetricsPushed)
return condutil.IsConditionTrue(conditions, api_v1beta1.MetricsPushed)
}

func (r *restoreInvokerReconciler) sendRestoreMetrics() error {
Expand Down
3 changes: 2 additions & 1 deletion pkg/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"k8s.io/client-go/tools/leaderelection/resourcelock"
"k8s.io/klog/v2"
kmapi "kmodules.xyz/client-go/api/v1"
condutil "kmodules.xyz/client-go/conditions"
"kmodules.xyz/client-go/meta"
v1 "kmodules.xyz/offshoot-api/api/v1"
)
Expand Down Expand Up @@ -254,7 +255,7 @@ func (opt *Options) isRestoredForThisHost(inv invoker.RestoreInvoker, targetInfo
if phase == api_v1beta1.RestoreSucceeded ||
phase == api_v1beta1.RestoreFailed ||
phase == api_v1beta1.RestorePhaseUnknown ||
kmapi.IsConditionFalse(inv.GetStatus().Conditions, api_v1beta1.GlobalPreRestoreHookSucceeded) {
condutil.IsConditionFalse(inv.GetStatus().Conditions, api_v1beta1.GlobalPreRestoreHookSucceeded) {
return true
}
for _, member := range inv.GetStatus().TargetStatus {
Expand Down
7 changes: 4 additions & 3 deletions pkg/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
"k8s.io/client-go/rest"
"k8s.io/klog/v2"
kmapi "kmodules.xyz/client-go/api/v1"
condutil "kmodules.xyz/client-go/conditions"
)

type UpdateStatusOptions struct {
Expand Down Expand Up @@ -311,7 +312,7 @@ func (o UpdateStatusOptions) applyRetentionPolicy(inv invoker.BackupInvoker, ses
}

func isRetentionPolicyApplied(session *invoker.BackupSessionHandler) bool {
return kmapi.HasCondition(session.GetConditions(), v1beta1.RetentionPolicyApplied)
return condutil.HasCondition(session.GetConditions(), v1beta1.RetentionPolicyApplied)
}

func (o UpdateStatusOptions) verifyRepositoryIntegrity(session *invoker.BackupSessionHandler) (*restic.RepositoryStats, error) {
Expand All @@ -331,7 +332,7 @@ func (o UpdateStatusOptions) verifyRepositoryIntegrity(session *invoker.BackupSe
}

func isRepoIntegrityVerified(session *invoker.BackupSessionHandler) bool {
return kmapi.HasCondition(session.GetConditions(), v1beta1.RepositoryIntegrityVerified)
return condutil.HasCondition(session.GetConditions(), v1beta1.RepositoryIntegrityVerified)
}

func (o *UpdateStatusOptions) sendRepositoryMetrics(inv invoker.BackupInvoker, session *invoker.BackupSessionHandler, repoStats restic.RepositoryStats) error {
Expand All @@ -347,7 +348,7 @@ func (o *UpdateStatusOptions) sendRepositoryMetrics(inv invoker.BackupInvoker, s
}

func isRepositoryMetricSent(session *invoker.BackupSessionHandler) bool {
return kmapi.HasCondition(session.GetConditions(), v1beta1.RepositoryMetricsPushed)
return condutil.HasCondition(session.GetConditions(), v1beta1.RepositoryMetricsPushed)
}

func (o *UpdateStatusOptions) updateRepositoryStatus(inv invoker.BackupInvoker, session *invoker.BackupSessionHandler, repoStats restic.RepositoryStats) error {
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/framework/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,32 @@ import (
"stash.appscode.dev/apimachinery/apis/stash/v1beta1"

. "github.com/onsi/gomega"
core "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kmapi "kmodules.xyz/client-go/api/v1"
condutil "kmodules.xyz/client-go/conditions"
)

func (f *Framework) EventuallyCondition(meta metav1.ObjectMeta, kind string, condType string) GomegaAsyncAssertion {
return Eventually(
func() core.ConditionStatus {
func() metav1.ConditionStatus {
var conditions []kmapi.Condition
switch kind {
case v1beta1.ResourceKindBackupConfiguration:
bc, err := f.StashClient.StashV1beta1().BackupConfigurations(meta.Namespace).Get(context.TODO(), meta.Name, metav1.GetOptions{})
if err != nil {
return core.ConditionUnknown
return metav1.ConditionUnknown
}
conditions = bc.Status.Conditions
case v1beta1.ResourceKindRestoreSession:
rs, err := f.StashClient.StashV1beta1().RestoreSessions(meta.Namespace).Get(context.TODO(), meta.Name, metav1.GetOptions{})
if err != nil {
return core.ConditionUnknown
return metav1.ConditionUnknown
}
conditions = rs.Status.Conditions
}
_, cond := kmapi.GetCondition(conditions, condType)
_, cond := condutil.GetCondition(conditions, condType)
if cond == nil {
return core.ConditionUnknown
return metav1.ConditionUnknown
}
return cond.Status
},
Expand Down
4 changes: 4 additions & 0 deletions vendor/gomodules.xyz/jsonpatch/v2/jsonpatch.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package jsonpatch

import (
"bytes"
"encoding/json"
"fmt"
"reflect"
Expand Down Expand Up @@ -64,6 +65,9 @@ func NewOperation(op, path string, value interface{}) Operation {
//
// An error will be returned if any of the two documents are invalid.
func CreatePatch(a, b []byte) ([]Operation, error) {
if bytes.Equal(a, b) {
return []Operation{}, nil
}
var aI interface{}
var bI interface{}
err := json.Unmarshal(a, &aI)
Expand Down
Loading

0 comments on commit 06bacfd

Please sign in to comment.