...

Source file src/github.com/chaos-mesh/chaos-mesh/controllers/utils/recorder/common.go

Documentation: github.com/chaos-mesh/chaos-mesh/controllers/utils/recorder

     1  // Copyright 2021 Chaos Mesh Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  // http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  //
    15  
    16  package recorder
    17  
    18  import (
    19  	"fmt"
    20  )
    21  
    22  type Applied struct {
    23  	Id string
    24  }
    25  
    26  func (a Applied) Type() string {
    27  	return "Normal"
    28  }
    29  
    30  func (a Applied) Reason() string {
    31  	return "Applied"
    32  }
    33  
    34  func (a Applied) Message() string {
    35  	return fmt.Sprintf("Successfully apply chaos for %s", a.Id)
    36  }
    37  
    38  type Recovered struct {
    39  	Id string
    40  }
    41  
    42  func (r Recovered) Type() string {
    43  	return "Normal"
    44  }
    45  
    46  func (r Recovered) Reason() string {
    47  	return "Recovered"
    48  }
    49  
    50  func (r Recovered) Message() string {
    51  	return fmt.Sprintf("Successfully recover chaos for %s", r.Id)
    52  }
    53  
    54  type NotSupported struct {
    55  	Activity string
    56  }
    57  
    58  func (r NotSupported) Type() string {
    59  	return "Warning"
    60  }
    61  
    62  func (r NotSupported) Reason() string {
    63  	return "NotSupported"
    64  }
    65  
    66  func (r NotSupported) Message() string {
    67  	return fmt.Sprintf("%s is not supported", r.Activity)
    68  }
    69  
    70  func init() {
    71  	register(Applied{}, Recovered{}, NotSupported{})
    72  }
    73