github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/pkg/cli/create/template/network_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 action: string 22 selector: {} 23 mode: string 24 value: string 25 duration: string 26 27 direction: string 28 externalTargets?: [...] 29 target?: {} 30 31 loss?: {} 32 delay?: {} 33 duplicate?: {} 34 corrupt?: {} 35 bandwidth?: {} 36 } 37 38 // required, k8s api resource content 39 content: { 40 kind: "NetworkChaos" 41 apiVersion: "chaos-mesh.org/v1alpha1" 42 metadata: { 43 generateName: "network-chaos-" 44 namespace: options.namespace 45 } 46 spec: { 47 selector: options.selector 48 mode: options.mode 49 value: options.value 50 action: options.action 51 duration: options.duration 52 53 direction: options.direction 54 55 if options.externalTargets != _|_ { 56 externalTargets: options.externalTargets 57 } 58 59 if options.target["mode"] != _|_ || len(options.target["selector"]) != 0 { 60 target: options.target 61 } 62 63 if options.loss["loss"] != _|_ { 64 loss: options.loss 65 } 66 67 if options.delay["latency"] != _|_ { 68 delay: options.delay 69 } 70 71 if options.corrupt["corrupt"] != _|_ { 72 corrupt: options.corrupt 73 } 74 75 if options.duplicate["duplicate"] != _|_ { 76 duplicate: options.duplicate 77 } 78 79 if options.bandwidth["rate"] != _|_ { 80 bandwidth: options.bandwidth 81 } 82 } 83 }