github.com/kubevela/workflow@v0.6.0/pkg/mock/mock.go (about)

     1  /*
     2  Copyright 2022 The KubeVela Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package mock
    18  
    19  import "github.com/kubevela/workflow/api/v1alpha1"
    20  
    21  // Action ...
    22  type Action struct {
    23  	Phase string
    24  	Msg   string
    25  }
    26  
    27  // Suspend makes the step suspend
    28  func (act *Action) Suspend(message string) {
    29  	act.Phase = "Suspend"
    30  	if message != "" {
    31  		act.Msg = message
    32  	}
    33  }
    34  
    35  // GetStatus returns the step status
    36  func (act *Action) GetStatus() v1alpha1.StepStatus {
    37  	return v1alpha1.StepStatus{}
    38  }
    39  
    40  // Resume makes the step resume
    41  func (act *Action) Resume(message string) {
    42  	act.Phase = "Resume"
    43  	if message != "" {
    44  		act.Msg = message
    45  	}
    46  }
    47  
    48  // Terminate makes the step terminate
    49  func (act *Action) Terminate(message string) {
    50  	act.Phase = "Terminate"
    51  	if message != "" {
    52  		act.Msg = message
    53  	}
    54  }
    55  
    56  // Wait makes the step wait
    57  func (act *Action) Wait(message string) {
    58  	act.Phase = "Wait"
    59  	if message != "" {
    60  		act.Msg = message
    61  	}
    62  }
    63  
    64  // Fail makes the step fail
    65  func (act *Action) Fail(message string) {
    66  	act.Phase = "Fail"
    67  	if message != "" {
    68  		act.Msg = message
    69  	}
    70  }
    71  
    72  // Message write message to step status
    73  func (act *Action) Message(message string) {
    74  	act.Phase = "Fail"
    75  	if message != "" {
    76  		act.Msg = message
    77  	}
    78  }