...

Source file src/github.com/chaos-mesh/chaos-mesh/controllers/types/types.go

Documentation: github.com/chaos-mesh/chaos-mesh/controllers/types

     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 types
    17  
    18  import (
    19  	"go.uber.org/fx"
    20  
    21  	"github.com/chaos-mesh/chaos-mesh/api/v1alpha1"
    22  )
    23  
    24  type Controller string
    25  
    26  // Object only used for registration webhook for various Kind of chaos custom resources.
    27  // Deprecated: use WebhookObject instead.
    28  // TODO: migrate it to WebhookObject
    29  type Object struct {
    30  	// Object should be the same as the kind of the chaos custom resource.
    31  	Object v1alpha1.InnerObject
    32  	// Name indicates the name of the webhook. It would be used to dedicate enabling the webhook for this Kind of
    33  	// chaos custom resource or not.
    34  	Name string
    35  }
    36  
    37  // ChaosObjects is the list of all kind of chaos custom resource, following the registration pattern.
    38  // Deprecated: use WebhookObjects instead.
    39  var ChaosObjects = fx.Supply(
    40  	fx.Annotated{
    41  		Group: "objs",
    42  		Target: Object{
    43  			Name:   "awschaos",
    44  			Object: &v1alpha1.AWSChaos{},
    45  		},
    46  	},
    47  
    48  	fx.Annotated{
    49  		Group: "objs",
    50  		Target: Object{
    51  			Name:   "dnschaos",
    52  			Object: &v1alpha1.DNSChaos{},
    53  		},
    54  	},
    55  
    56  	fx.Annotated{
    57  		Group: "objs",
    58  		Target: Object{
    59  			Name:   "httpchaos",
    60  			Object: &v1alpha1.HTTPChaos{},
    61  		},
    62  	},
    63  
    64  	fx.Annotated{
    65  		Group: "objs",
    66  		Target: Object{
    67  			Name:   "iochaos",
    68  			Object: &v1alpha1.IOChaos{},
    69  		},
    70  	},
    71  
    72  	fx.Annotated{
    73  		Group: "objs",
    74  		Target: Object{
    75  			Name:   "kernelchaos",
    76  			Object: &v1alpha1.KernelChaos{},
    77  		},
    78  	},
    79  
    80  	fx.Annotated{
    81  		Group: "objs",
    82  		Target: Object{
    83  			Name:   "jvmchaos",
    84  			Object: &v1alpha1.JVMChaos{},
    85  		},
    86  	},
    87  
    88  	fx.Annotated{
    89  		Group: "objs",
    90  		Target: Object{
    91  			Name:   "networkchaos",
    92  			Object: &v1alpha1.NetworkChaos{},
    93  		},
    94  	},
    95  
    96  	fx.Annotated{
    97  		Group: "objs",
    98  		Target: Object{
    99  			Name:   "podchaos",
   100  			Object: &v1alpha1.PodChaos{},
   101  		},
   102  	},
   103  
   104  	fx.Annotated{
   105  		Group: "objs",
   106  		Target: Object{
   107  			Name:   "stresschaos",
   108  			Object: &v1alpha1.StressChaos{},
   109  		},
   110  	},
   111  
   112  	fx.Annotated{
   113  		Group: "objs",
   114  		Target: Object{
   115  			Name:   "timechaos",
   116  			Object: &v1alpha1.TimeChaos{},
   117  		},
   118  	},
   119  
   120  	fx.Annotated{
   121  		Group: "objs",
   122  		Target: Object{
   123  			Name:   "gcpchaos",
   124  			Object: &v1alpha1.GCPChaos{},
   125  		},
   126  	},
   127  
   128  	fx.Annotated{
   129  		Group: "objs",
   130  		Target: Object{
   131  			Name:   "physicalmachinechaos",
   132  			Object: &v1alpha1.PhysicalMachineChaos{},
   133  		},
   134  	},
   135  
   136  	fx.Annotated{
   137  		Group: "objs",
   138  		Target: Object{
   139  			Name:   "azurechaos",
   140  			Object: &v1alpha1.AzureChaos{},
   141  		},
   142  	},
   143  
   144  	fx.Annotated{
   145  		Group: "objs",
   146  		Target: Object{
   147  			Name:   "blockchaos",
   148  			Object: &v1alpha1.BlockChaos{},
   149  		},
   150  	},
   151  )
   152  
   153  // WebhookObject only used for registration the
   154  type WebhookObject struct {
   155  	// Object should be the same as the kind of the chaos custom resource.
   156  	Object v1alpha1.WebhookObject
   157  	// Name indicates the name of the webhook. It would be used to dedicate enabling the webhook for this Kind of
   158  	// chaos custom resource or not.
   159  	Name string
   160  }
   161  
   162  // WebhookObjects is the list of all kind of chaos custom resource, following the registration pattern.
   163  // When you add a new kind of chaos custom resource, please add it to the list.
   164  var WebhookObjects = fx.Supply(
   165  	fx.Annotated{
   166  		Group: "webhookObjs",
   167  		Target: WebhookObject{
   168  			Name:   "physicalmachine",
   169  			Object: &v1alpha1.PhysicalMachine{},
   170  		},
   171  	},
   172  	fx.Annotated{
   173  		Group: "webhookObjs",
   174  		Target: WebhookObject{
   175  			Name:   "statuscheck",
   176  			Object: &v1alpha1.StatusCheck{},
   177  		},
   178  	},
   179  )
   180