Skip to content

Commit

Permalink
Rename hasCondition with isStatusConditionTrue
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Iwai <yuki.iwai.tz@gmail.com>
  • Loading branch information
tenzen-y committed Jul 19, 2023
1 parent ce7259e commit 4c28296
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions pkg/util/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ func IsFinished(status apiv1.JobStatus) bool {

// IsSucceeded checks if the job is succeeded
func IsSucceeded(status apiv1.JobStatus) bool {
return hasCondition(status, apiv1.JobSucceeded)
return isStatusConditionTrue(status, apiv1.JobSucceeded)
}

// IsFailed checks if the job is failed
func IsFailed(status apiv1.JobStatus) bool {
return hasCondition(status, apiv1.JobFailed)
return isStatusConditionTrue(status, apiv1.JobFailed)
}

func IsRunning(status apiv1.JobStatus) bool {
return hasCondition(status, apiv1.JobRunning)
return isStatusConditionTrue(status, apiv1.JobRunning)
}

func IsSuspended(status apiv1.JobStatus) bool {
return hasCondition(status, apiv1.JobSuspended)
return isStatusConditionTrue(status, apiv1.JobSuspended)
}

// UpdateJobConditions adds to the jobStatus a new condition if needed, with the conditionType, reason, and message
Expand All @@ -67,7 +67,7 @@ func UpdateJobConditions(
return nil
}

func hasCondition(status apiv1.JobStatus, condType apiv1.JobConditionType) bool {
func isStatusConditionTrue(status apiv1.JobStatus, condType apiv1.JobConditionType) bool {
for _, condition := range status.Conditions {
if condition.Type == condType && condition.Status == v1.ConditionTrue {
return true
Expand Down
3 changes: 2 additions & 1 deletion pkg/util/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package util
import (
"testing"

apiv1 "github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v1"
"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"

apiv1 "github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v1"
)

func TestIsFinished(t *testing.T) {
Expand Down

0 comments on commit 4c28296

Please sign in to comment.