Skip to content

Commit

Permalink
Refactor invoker package (#146)
Browse files Browse the repository at this point in the history
* Refactor invoker package

Signed-off-by: Emruz Hossain <[email protected]>

* WIP: Refactor invoker package

Signed-off-by: Emruz Hossain <[email protected]>

* Added license header

Signed-off-by: Emruz Hossain <[email protected]>

* Reorganize interfaces

Signed-off-by: Emruz Hossain <[email protected]>

* Fix GetRepoRef() function

Signed-off-by: Emruz Hossain <[email protected]>
  • Loading branch information
Emruz Hossain authored Jan 24, 2022
1 parent 7da4b19 commit d7bf57b
Show file tree
Hide file tree
Showing 10 changed files with 1,291 additions and 738 deletions.
36 changes: 18 additions & 18 deletions pkg/conditions/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ func SetRepositoryFoundConditionToUnknown(i interface{}, err error) error {
Status: core.ConditionUnknown,
Reason: apis.UnableToCheckRepositoryAvailability,
Message: fmt.Sprintf("Failed to check whether the Repository %s/%s exist or not. Reason: %v",
in.Repository.Namespace,
in.Repository,
in.GetRepoRef().Namespace,
in.GetRepoRef().Name,
err.Error(),
),
})
Expand All @@ -89,8 +89,8 @@ func SetRepositoryFoundConditionToUnknown(i interface{}, err error) error {
Status: core.ConditionUnknown,
Reason: apis.UnableToCheckRepositoryAvailability,
Message: fmt.Sprintf("Failed to check whether the Repository %s/%s exist or not. Reason: %v",
in.Repository.Namespace,
in.Repository,
in.GetRepoRef().Namespace,
in.GetRepoRef().Name,
err.Error(),
),
})
Expand All @@ -107,8 +107,8 @@ func SetRepositoryFoundConditionToFalse(i interface{}) error {
Status: core.ConditionFalse,
Reason: apis.RepositoryNotAvailable,
Message: fmt.Sprintf("Repository %s/%s does not exist.",
in.Repository.Namespace,
in.Repository,
in.GetRepoRef().Namespace,
in.GetRepoRef().Name,
),
})
case invoker.RestoreInvoker:
Expand All @@ -117,8 +117,8 @@ func SetRepositoryFoundConditionToFalse(i interface{}) error {
Status: core.ConditionFalse,
Reason: apis.RepositoryNotAvailable,
Message: fmt.Sprintf("Repository %s/%s does not exist.",
in.Repository.Namespace,
in.Repository,
in.GetRepoRef().Namespace,
in.GetRepoRef().Name,
),
})
default:
Expand All @@ -134,8 +134,8 @@ func SetRepositoryFoundConditionToTrue(i interface{}) error {
Status: core.ConditionTrue,
Reason: apis.RepositoryAvailable,
Message: fmt.Sprintf("Repository %s/%s exist.",
in.Repository.Namespace,
in.Repository,
in.GetRepoRef().Namespace,
in.GetRepoRef().Name,
),
})
case invoker.RestoreInvoker:
Expand All @@ -144,8 +144,8 @@ func SetRepositoryFoundConditionToTrue(i interface{}) error {
Status: core.ConditionTrue,
Reason: apis.RepositoryAvailable,
Message: fmt.Sprintf("Repository %s/%s exist.",
in.Repository.Namespace,
in.Repository,
in.GetRepoRef().Namespace,
in.GetRepoRef().Name,
),
})
default:
Expand All @@ -161,7 +161,7 @@ func SetBackendSecretFoundConditionToUnknown(i interface{}, secretName string, e
Status: core.ConditionUnknown,
Reason: apis.UnableToCheckBackendSecretAvailability,
Message: fmt.Sprintf("Failed to check whether the backend Secret %s/%s exist or not. Reason: %v",
in.Repository.Namespace,
in.GetRepoRef().Namespace,
secretName,
err.Error(),
),
Expand All @@ -172,7 +172,7 @@ func SetBackendSecretFoundConditionToUnknown(i interface{}, secretName string, e
Status: core.ConditionUnknown,
Reason: apis.UnableToCheckBackendSecretAvailability,
Message: fmt.Sprintf("Failed to check whether the backend Secret %s/%s exist or not. Reason: %v",
in.Repository.Namespace,
in.GetRepoRef().Namespace,
secretName,
err.Error(),
),
Expand All @@ -190,7 +190,7 @@ func SetBackendSecretFoundConditionToFalse(i interface{}, secretName string) err
Status: core.ConditionFalse,
Reason: apis.BackendSecretNotAvailable,
Message: fmt.Sprintf("Backend Secret %s/%s does not exist.",
in.Repository.Namespace,
in.GetRepoRef().Namespace,
secretName,
),
})
Expand All @@ -200,7 +200,7 @@ func SetBackendSecretFoundConditionToFalse(i interface{}, secretName string) err
Status: core.ConditionFalse,
Reason: apis.BackendSecretNotAvailable,
Message: fmt.Sprintf("Backend Secret %s/%s does not exist.",
in.Repository.Namespace,
in.GetRepoRef().Namespace,
secretName,
),
})
Expand All @@ -217,7 +217,7 @@ func SetBackendSecretFoundConditionToTrue(i interface{}, secretName string) erro
Status: core.ConditionTrue,
Reason: apis.BackendSecretAvailable,
Message: fmt.Sprintf("Backend Secret %s/%s exist.",
in.Repository.Namespace,
in.GetRepoRef().Namespace,
secretName,
),
})
Expand All @@ -227,7 +227,7 @@ func SetBackendSecretFoundConditionToTrue(i interface{}, secretName string) erro
Status: core.ConditionTrue,
Reason: apis.BackendSecretAvailable,
Message: fmt.Sprintf("Backend Secret %s/%s exist.",
in.Repository.Namespace,
in.GetRepoRef().Namespace,
secretName,
),
})
Expand Down
6 changes: 3 additions & 3 deletions pkg/conditions/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

func SetRestoreTargetFoundConditionToTrue(inv invoker.RestoreInvoker, index int) error {
target := inv.TargetsInfo[index].Target
target := inv.GetTargetInfo()[index].Target
return inv.SetCondition(&target.Ref, kmapi.Condition{
Type: apis.RestoreTargetFound,
Status: core.ConditionTrue,
Expand All @@ -43,7 +43,7 @@ func SetRestoreTargetFoundConditionToTrue(inv invoker.RestoreInvoker, index int)
}

func SetRestoreTargetFoundConditionToFalse(inv invoker.RestoreInvoker, index int) error {
target := inv.TargetsInfo[index].Target
target := inv.GetTargetInfo()[index].Target
return inv.SetCondition(&target.Ref, kmapi.Condition{
Type: apis.RestoreTargetFound,
Status: core.ConditionFalse,
Expand All @@ -57,7 +57,7 @@ func SetRestoreTargetFoundConditionToFalse(inv invoker.RestoreInvoker, index int
}

func SetRestoreTargetFoundConditionToUnknown(inv invoker.RestoreInvoker, index int, err error) error {
target := inv.TargetsInfo[index].Target
target := inv.GetTargetInfo()[index].Target
return inv.SetCondition(&target.Ref, kmapi.Condition{
Type: apis.RestoreTargetFound,
Status: core.ConditionUnknown,
Expand Down
Loading

0 comments on commit d7bf57b

Please sign in to comment.