Skip to content

Commit

Permalink
Update util for experiment in v1alpha2 (kubeflow#485)
Browse files Browse the repository at this point in the history
* Update util for experiment

* Change GetLastConditionType func

* Add empty condition check
  • Loading branch information
andreyvelich authored and k8s-ci-robot committed May 9, 2019
1 parent 41143e8 commit 7cadd62
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/api/operators/apis/experiment/v1alpha2/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ limitations under the License.
package v1alpha2

import (
"errors"

v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -73,10 +75,25 @@ func (exp *Experiment) IsFailed() bool {
return hasCondition(exp, ExperimentFailed)
}

func (exp *Experiment) IsRunning() bool {
return hasCondition(exp, ExperimentRunning)
}

func (exp *Experiment) IsRestarting() bool {
return hasCondition(exp, ExperimentRestarting)
}

func (exp *Experiment) IsCompleted() bool {
return exp.IsSucceeded() || exp.IsFailed()
}

func (exp *Experiment) GetLastConditionType() (ExperimentConditionType, error) {
if len(exp.Status.Conditions) > 0 {
return exp.Status.Conditions[len(exp.Status.Conditions)-1].Type, nil
}
return "", errors.New("Experiment doesn't have any condition")
}

func (exp *Experiment) setCondition(conditionType ExperimentConditionType, status v1.ConditionStatus, reason, message string) {

newCond := newCondition(conditionType, status, reason, message)
Expand Down

0 comments on commit 7cadd62

Please sign in to comment.