sigs.k8s.io/cluster-api@v1.7.1/cmd/clusterctl/client/tree/options.go (about) 1 /* 2 Copyright 2020 The Kubernetes 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 tree 18 19 // AddObjectOption define an option for the ObjectTree Add operation. 20 type AddObjectOption interface { 21 ApplyToAdd(*addObjectOptions) 22 } 23 24 type addObjectOptions struct { 25 MetaName string 26 GroupingObject bool 27 NoEcho bool 28 ZOrder int 29 } 30 31 func (o *addObjectOptions) ApplyOptions(opts []AddObjectOption) *addObjectOptions { 32 for _, opt := range opts { 33 opt.ApplyToAdd(o) 34 } 35 return o 36 } 37 38 // The ObjectMetaName option defines the meta name that should be used for the object in the presentation layer, 39 // e.g. control plane for KCP. 40 type ObjectMetaName string 41 42 // ApplyToAdd applies the given options. 43 func (n ObjectMetaName) ApplyToAdd(options *addObjectOptions) { 44 options.MetaName = string(n) 45 } 46 47 // The GroupingObject option makes this node responsible of triggering the grouping action 48 // when adding the node's children. 49 type GroupingObject bool 50 51 // ApplyToAdd applies the given options. 52 func (n GroupingObject) ApplyToAdd(options *addObjectOptions) { 53 options.GroupingObject = bool(n) 54 } 55 56 // The NoEcho options defines if the object should be hidden if the object's ready condition has the 57 // same Status, Severity and Reason of the parent's object ready condition (it is an echo). 58 type NoEcho bool 59 60 // ApplyToAdd applies the given options. 61 func (n NoEcho) ApplyToAdd(options *addObjectOptions) { 62 options.NoEcho = bool(n) 63 } 64 65 // The ZOrder options defines the sorting of child objects when the tree is printed. Objects are sorted by their z-order 66 // from highest to lowest, and then by their name in alphaebetical order if the z-order is the same. Objects with no 67 // z-order set are assumed to have a default z-order of 0. 68 type ZOrder int 69 70 // ApplyToAdd applies the given options. 71 func (z ZOrder) ApplyToAdd(options *addObjectOptions) { 72 options.ZOrder = int(z) 73 }