github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/internal/config/help.go (about) 1 // Copyright (c) 2015-2021 MinIO, Inc. 2 // 3 // This file is part of MinIO Object Storage stack 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 package config 19 20 // HelpKV - implements help messages for keys 21 // with value as description of the keys. 22 type HelpKV struct { 23 Key string `json:"key"` 24 Type string `json:"type"` 25 Description string `json:"description"` 26 Optional bool `json:"optional"` 27 28 // Indicates if the value contains sensitive info that shouldn't be exposed 29 // in certain apis (such as Health Diagnostics/Callhome) 30 Sensitive bool `json:"-"` 31 32 // Indicates if the value is a secret such as a password that shouldn't be 33 // exposed by the server 34 Secret bool `json:"-"` 35 36 // Indicates if sub-sys supports multiple targets. 37 MultipleTargets bool `json:"multipleTargets"` 38 } 39 40 // HelpKVS - implement order of keys help messages. 41 type HelpKVS []HelpKV 42 43 // Lookup - lookup a key from help kvs. 44 func (hkvs HelpKVS) Lookup(key string) (HelpKV, bool) { 45 for _, hkv := range hkvs { 46 if hkv.Key == key { 47 return hkv, true 48 } 49 } 50 return HelpKV{}, false 51 } 52 53 // DefaultComment used across all sub-systems. 54 const DefaultComment = "optionally add a comment to this setting" 55 56 // Region help is documented in default config 57 var ( 58 SiteHelp = HelpKVS{ 59 HelpKV{ 60 Key: NameKey, 61 Type: "string", 62 Description: `name for the site e.g. "cal-rack0"`, 63 Optional: true, 64 }, 65 HelpKV{ 66 Key: RegionKey, 67 Type: "string", 68 Description: `name of the location of the server e.g. "us-west-1"`, 69 Optional: true, 70 }, 71 HelpKV{ 72 Key: Comment, 73 Type: "sentence", 74 Description: DefaultComment, 75 Optional: true, 76 }, 77 } 78 79 RegionHelp = HelpKVS{ 80 HelpKV{ 81 Key: RegionName, 82 Type: "string", 83 Description: `[DEPRECATED] name of the location of the server e.g. "us-west-rack2"`, 84 Optional: true, 85 }, 86 HelpKV{ 87 Key: Comment, 88 Type: "sentence", 89 Description: DefaultComment, 90 Optional: true, 91 }, 92 } 93 ) 94 95 // DefaultHelpPostfix - Helper function to add (default: $value) messages in config help 96 func DefaultHelpPostfix(subsystem KVS, key string) string { 97 val, found := subsystem.Lookup(key) 98 if !found || val == "" { 99 return "" 100 } 101 return " (default: '" + val + "')" 102 }