github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/pkg/cli/create/template/http_chaos_template.cue (about)

     1  // Copyright (C) 2022-2023 ApeCloud Co., Ltd
     2  //
     3  // This file is part of KubeBlocks project
     4  //
     5  // This program is free software: you can redistribute it and/or modify
     6  // it under the terms of the GNU Affero General Public License as published by
     7  // the Free Software Foundation, either version 3 of the License, or
     8  // (at your option) any later version.
     9  //
    10  // This program is distributed in the hope that it will be useful
    11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13  // GNU Affero General Public License for more details.
    14  //
    15  // You should have received a copy of the GNU Affero General Public License
    16  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    17  
    18  // required, command line input options for parameters and flags
    19  options: {
    20  	namespace: string
    21  	selector: {}
    22  	mode:     string
    23  	value:    string
    24  	duration: string
    25  
    26  	target: string
    27  	port:   int32
    28  	path:   string
    29  	method: string
    30  	code?:  int32
    31  
    32  	abort?: bool
    33  	delay?: string
    34  	replace?: {}
    35  	patch?: {}
    36  }
    37  
    38  // required, k8s api resource content
    39  content: {
    40  	kind:       "HTTPChaos"
    41  	apiVersion: "chaos-mesh.org/v1alpha1"
    42  	metadata: {
    43  		generateName: "http-chaos-"
    44  		namespace:    options.namespace
    45  	}
    46  	spec: {
    47  		selector: options.selector
    48  		mode:     options.mode
    49  		value:    options.value
    50  		duration: options.duration
    51  
    52  		target: options.target
    53  		port:   options.port
    54  		path:   options.path
    55  		method: options.method
    56  		if options.code != _|_ {
    57  			code: options.code
    58  		}
    59  
    60  		if options.abort != _|_ {
    61  			abort: options.abort
    62  		}
    63  
    64  		if options.delay != _|_ {
    65  			delay: options.delay
    66  		}
    67  
    68  		if len(options.replace) != 0 {
    69  			replace: options.replace
    70  		}
    71  
    72  		if len(options.patch["body"]) != 0 {
    73  			patch: options.patch
    74  		}
    75  	}
    76  }