forked from hyperledger/firefly-common
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.go
706 lines (616 loc) · 20.1 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
// Copyright © 2022 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package config
import (
"bytes"
"context"
"encoding/json"
"fmt"
"math"
"os"
"reflect"
"sort"
"strings"
"sync"
"time"
"github.com/hyperledger/firefly-common/pkg/fftypes"
"github.com/hyperledger/firefly-common/pkg/i18n"
"github.com/hyperledger/firefly-common/pkg/log"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
lumberjack "gopkg.in/natefinch/lumberjack.v2"
)
var ffc = AddRootKey
// The following keys can be access from the root configuration.
// Plugins are responsible for defining their own keys using the Config interface
var (
// Lang is the language to use for translation
Lang = ffc("lang")
// LogForceColor forces color to be enabled, even if we do not detect a TTY
LogForceColor = ffc("log.forceColor")
// LogLevel is the logging level
LogLevel = ffc("log.level")
// LogNoColor forces color to be disabled, even if we detect a TTY
LogNoColor = ffc("log.noColor")
// LogTimeFormat is a string format for timestamps
LogTimeFormat = ffc("log.timeFormat")
// LogUTC sets log timestamps to the UTC timezone
LogUTC = ffc("log.utc")
// LogFilename sets logging to file
LogFilename = ffc("log.filename")
// LogFilesize sets the size to roll logs at
LogFilesize = ffc("log.filesize")
// LogMaxBackups sets the maximum number of old files to keep
LogMaxBackups = ffc("log.maxBackups")
// LogMaxAge sets the maximum age at which to roll
LogMaxAge = ffc("log.maxAge")
// LogCompress sets whether to compress backups
LogCompress = ffc("log.compress")
// LogIncludeCodeInfo enables the report caller for including the calling file and line number
LogIncludeCodeInfo = ffc("log.includeCodeInfo")
// LogJSONEnabled enables JSON formatted logs rather than text
LogJSONEnabled = ffc("log.json.enabled")
// LogJSONTimestampField configures the JSON key containing the timestamp of the log
LogJSONTimestampField = ffc("log.json.fields.timestamp")
// LogJSONLevelField configures the JSON key containing the log level
LogJSONLevelField = ffc("log.json.fields.level")
// LogJSONMessageField configures the JSON key containing the log message
LogJSONMessageField = ffc("log.json.fields.message")
// LogJSONFuncField configures the JSON key containing the calling function
LogJSONFuncField = ffc("log.json.fields.func")
// LogJSONFileField configures the JSON key containing the calling file
LogJSONFileField = ffc("log.json.fields.file")
)
type KeySet interface {
AddKnownKey(key string, defValue ...interface{})
}
type sectionParent interface {
AddChild(key string, defValue ...interface{})
}
// Section represents a section of the global configuration, at a nested point in the config hierarchy.
// Note that all keys are added to a GLOBAL map, so this cannot be used for per-instance customization.
type Section interface {
KeySet
SetDefault(key string, defValue interface{})
SubSection(name string) Section
SubArray(name string) ArraySection
Set(key string, value interface{})
Resolve(key string) string
GetString(key string) string
GetBool(key string) bool
GetInt(key string) int
GetInt64(key string) int64
GetFloat64(key string) float64
GetByteSize(key string) int64
GetUint(key string) uint
GetDuration(key string) time.Duration
GetStringSlice(key string) []string
GetObject(key string) fftypes.JSONObject
GetObjectArray(key string) fftypes.JSONObjectArray
Get(key string) interface{}
}
// ArraySection represents an array of options at a particular layer in the config.
// This allows specifying the schema of keys that exist for every entry, and the defaults,
// as well as querying how many entries exist and iterating through them.
type ArraySection interface {
KeySet
ArraySize() int
ArrayEntry(i int) Section
SubSection(name string) Section
}
// RootKey key are the known configuration keys
type RootKey string
func RootConfigReset(setServiceDefaults ...func()) {
keysMutex.Lock() // must only call viper directly here (as we already hold the lock)
defer keysMutex.Unlock()
viper.Reset()
viper.SetDefault(string(Lang), "en")
viper.SetDefault(string(LogLevel), "info")
viper.SetDefault(string(LogTimeFormat), "2006-01-02T15:04:05.000Z07:00")
viper.SetDefault(string(LogUTC), false)
viper.SetDefault(string(LogFilesize), "100m")
viper.SetDefault(string(LogMaxAge), "24h")
viper.SetDefault(string(LogMaxBackups), 2)
viper.SetDefault(string(LogIncludeCodeInfo), false)
viper.SetDefault(string(LogJSONEnabled), false)
viper.SetDefault(string(LogJSONTimestampField), "@timestamp")
viper.SetDefault(string(LogJSONLevelField), "level")
viper.SetDefault(string(LogJSONMessageField), "message")
viper.SetDefault(string(LogJSONFuncField), "func")
viper.SetDefault(string(LogJSONFileField), "file")
// We set the service defaults within our mutex
for _, fn := range setServiceDefaults {
fn()
}
i18n.SetLang(viper.GetString(string(Lang)))
}
// ReadConfig initializes the config
func ReadConfig(cfgSuffix, cfgFile string) error {
keysMutex.Lock() // must only call viper directly here (as we already hold the lock)
defer keysMutex.Unlock()
// Set precedence order for reading config location
viper.SetEnvPrefix("firefly")
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.AutomaticEnv()
viper.SetConfigType("yaml")
if cfgFile != "" {
f, err := os.Open(cfgFile)
if err == nil {
defer f.Close()
err = viper.ReadConfig(f)
}
return err
}
viper.SetConfigName(fmt.Sprintf("firefly.%s", cfgSuffix))
viper.AddConfigPath("/etc/firefly/")
viper.AddConfigPath("$HOME/.firefly")
viper.AddConfigPath(".")
return viper.ReadInConfig()
}
func MergeConfig(configRecords []*fftypes.ConfigRecord) error {
keysMutex.Lock()
defer keysMutex.Unlock()
for _, c := range configRecords {
s := viper.New()
s.SetConfigType("json")
var val interface{}
if c.Value != nil {
if err := json.Unmarshal([]byte(*c.Value), &val); err != nil {
return err
}
}
switch v := val.(type) {
case map[string]interface{}:
_ = s.ReadConfig(bytes.NewBuffer([]byte(*c.Value)))
for _, k := range s.AllKeys() {
value := s.Get(k)
if reflect.TypeOf(value).Kind() == reflect.Slice {
configSlice := value.([]interface{})
for i := range configSlice {
viper.Set(fmt.Sprintf("%s.%s.%d", c.Key, k, i), configSlice[i])
}
} else {
viper.Set(fmt.Sprintf("%s.%s", c.Key, k), value)
}
}
case []interface{}:
_ = s.ReadConfig(bytes.NewBuffer([]byte(*c.Value)))
for i := range v {
viper.Set(fmt.Sprintf("%s.%d", c.Key, i), v[i])
}
default:
viper.Set(c.Key, v)
}
}
return nil
}
var knownKeys = map[string]bool{} // All config keys go here, including those defined in sub-sections
var keysMutex sync.Mutex
var root = &configSection{}
// AddRootKey adds a root key, used to define the keys that are used within the core
func AddRootKey(k string) RootKey {
root.AddKnownKey(k)
return RootKey(k)
}
// GetKnownKeys gets the known keys
func GetKnownKeys() []string {
keysMutex.Lock()
defer keysMutex.Unlock()
keys := make([]string, 0, len(knownKeys))
for k := range knownKeys {
keys = append(keys, k)
}
sort.Strings(keys)
return keys
}
// configSection is the main config structure passed to plugins, and used for root to wrap viper
type configSection struct {
prefix string
parent sectionParent
arrayEntry bool
}
// configArray is a point in the config that supports an array
type configArray struct {
base string
parent sectionParent
defaults map[string][]interface{}
}
// RootSection creates a new configuration section starting from the config root
func RootSection(prefix string) Section {
return &configSection{
prefix: strings.TrimSuffix(prefix, "."),
}
}
// RootArray creates a new configuration array starting from the config root
func RootArray(prefix string) ArraySection {
return &configArray{
base: strings.TrimSuffix(prefix, "."),
defaults: make(map[string][]interface{}),
}
}
func keyName(prefix, name string) string {
if prefix != "" {
return prefix + "." + name
}
return name
}
func (c *configSection) prefixKey(k string) string {
// Caller responsible for holding lock when calling
key := keyName(c.prefix, k)
if !knownKeys[key] {
panic(fmt.Sprintf("Undefined configuration key '%s'", key))
}
return key
}
func (c *configSection) SubSection(name string) Section {
return &configSection{
prefix: keyName(c.prefix, name),
parent: c,
}
}
func (c *configArray) SubSection(name string) Section {
cp := &configSection{
prefix: keyName(c.base+"[]", name),
parent: c,
}
return cp
}
// If any parent is an array entry, retrieve fully-qualified defaults via its array parent
func getArrayEntryDefaults(p sectionParent) map[string][]interface{} {
switch c := p.(type) {
case *configArray:
return getArrayEntryDefaults(c.parent)
case *configSection:
if !c.arrayEntry {
return getArrayEntryDefaults(c.parent)
}
arrayParent := c.parent.(*configArray)
defaults := make(map[string][]interface{})
for k, v := range arrayParent.defaults {
defaults[c.prefix+"."+k] = v
}
return defaults
default:
return nil
}
}
func (c *configSection) SubArray(name string) ArraySection {
a := &configArray{
base: keyName(c.prefix, name),
parent: c,
defaults: make(map[string][]interface{}),
}
// Get defaults from any enclosing array entry, and copy over any applicable to this subtree
// This is necessary to propagate known keys for arrays within arrays
prefix := a.base + "[]."
for key, val := range getArrayEntryDefaults(c) {
if strings.HasPrefix(key, prefix) {
a.defaults[strings.TrimPrefix(key, prefix)] = val
}
}
return a
}
func (c *configArray) ArraySize() int {
val := viper.Get(c.base)
vt := reflect.TypeOf(val)
if vt != nil && (vt.Kind() == reflect.Slice || vt.Kind() == reflect.Map) {
return reflect.ValueOf(val).Len()
}
return 0
}
// ArrayEntry must only be called after the config has been loaded
func (c *configArray) ArrayEntry(i int) Section {
cp := &configSection{
prefix: keyName(c.base, fmt.Sprintf("%d", i)),
parent: c,
arrayEntry: true,
}
for knownKey, defValue := range c.defaults {
cp.AddKnownKey(knownKey, defValue...)
// Sadly Viper can't handle defaults inside the array, when
// a value is set. So here we check/set the defaults.
if defValue != nil && cp.Get(knownKey) == nil {
if len(defValue) == 1 {
cp.Set(knownKey, defValue[0])
} else if len(defValue) > 0 {
cp.Set(knownKey, defValue)
}
}
}
return cp
}
func (c *configArray) AddKnownKey(k string, defValue ...interface{}) {
keysMutex.Lock()
defer keysMutex.Unlock()
// Put a simulated key in the known keys array, to pop into the help info.
key := keyName(c.base+"[]", k)
knownKeys[key] = true
c.AddChild(key, defValue...)
}
func (c *configSection) AddKnownKey(k string, defValue ...interface{}) {
key := keyName(c.prefix, k)
if len(defValue) == 1 {
c.SetDefault(k, defValue[0])
} else if len(defValue) > 0 {
c.SetDefault(k, defValue)
}
keysMutex.Lock()
defer keysMutex.Unlock()
knownKeys[key] = true
if c.parent != nil {
c.parent.AddChild(key, defValue...)
}
}
func (c *configArray) AddChild(k string, defValue ...interface{}) {
// When a child is added anywhere below this array, add it to the defaults map
prefix := c.base + "[]."
if strings.HasPrefix(k, prefix) {
c.defaults[strings.TrimPrefix(k, prefix)] = defValue
}
// Also bubble it upwards
if c.parent != nil {
c.parent.AddChild(k, defValue...)
}
}
func (c *configSection) AddChild(k string, defValue ...interface{}) {
// When a child is added anywhere below this key, just bubble it upwards
if c.parent != nil {
c.parent.AddChild(k, defValue...)
}
}
func (c *configSection) SetDefault(k string, defValue interface{}) {
key := keyName(c.prefix, k)
viper.SetDefault(key, defValue)
c.AddChild(key, defValue)
}
func GetConfig() fftypes.JSONObject {
keysMutex.Lock()
defer keysMutex.Unlock()
conf := fftypes.JSONObject{}
_ = viper.Unmarshal(&conf)
return conf
}
// GetString gets a configuration string
func GetString(key RootKey) string {
return root.GetString(string(key))
}
func (c *configSection) GetString(key string) string {
keysMutex.Lock()
defer keysMutex.Unlock()
return viper.GetString(c.prefixKey(key))
}
// GetStringSlice gets a configuration string array
func GetStringSlice(key RootKey) []string {
return root.GetStringSlice(string(key))
}
func (c *configSection) GetStringSlice(key string) []string {
keysMutex.Lock()
defer keysMutex.Unlock()
return viper.GetStringSlice(c.prefixKey(key))
}
// GetBool gets a configuration bool
func GetBool(key RootKey) bool {
return root.GetBool(string(key))
}
func (c *configSection) GetBool(key string) bool {
keysMutex.Lock()
defer keysMutex.Unlock()
return viper.GetBool(c.prefixKey(key))
}
// GetDuration gets a configuration time duration with consistent semantics
func GetDuration(key RootKey) time.Duration {
return root.GetDuration(string(key))
}
func (c *configSection) GetDuration(key string) time.Duration {
keysMutex.Lock()
defer keysMutex.Unlock()
return fftypes.ParseToDuration(viper.GetString(c.prefixKey(key)))
}
// GetByteSize get a size in bytes
func GetByteSize(key RootKey) int64 {
return root.GetByteSize(string(key))
}
func (c *configSection) GetByteSize(key string) int64 {
keysMutex.Lock()
defer keysMutex.Unlock()
return fftypes.ParseToByteSize(viper.GetString(c.prefixKey(key)))
}
// GetUint gets a configuration uint
func GetUint(key RootKey) uint {
return root.GetUint(string(key))
}
func (c *configSection) GetUint(key string) uint {
keysMutex.Lock()
defer keysMutex.Unlock()
return viper.GetUint(c.prefixKey(key))
}
// GetInt gets a configuration uint
func GetInt(key RootKey) int {
return root.GetInt(string(key))
}
func (c *configSection) GetInt(key string) int {
keysMutex.Lock()
defer keysMutex.Unlock()
return viper.GetInt(c.prefixKey(key))
}
// GetInt64 gets a configuration uint
func GetInt64(key RootKey) int64 {
return root.GetInt64(string(key))
}
func (c *configSection) GetInt64(key string) int64 {
keysMutex.Lock()
defer keysMutex.Unlock()
return viper.GetInt64(c.prefixKey(key))
}
// GetFloat64 gets a configuration uint
func GetFloat64(key RootKey) float64 {
return root.GetFloat64(string(key))
}
func (c *configSection) GetFloat64(key string) float64 {
keysMutex.Lock()
defer keysMutex.Unlock()
return viper.GetFloat64(c.prefixKey(key))
}
// GetObject gets a configuration map
func GetObject(key RootKey) fftypes.JSONObject {
return root.GetObject(string(key))
}
func (c *configSection) GetObject(key string) fftypes.JSONObject {
keysMutex.Lock()
defer keysMutex.Unlock()
return fftypes.JSONObject(viper.GetStringMap(c.prefixKey(key)))
}
// GetObjectArray gets an array of configuration maps
func GetObjectArray(key RootKey) fftypes.JSONObjectArray {
return root.GetObjectArray(string(key))
}
func (c *configSection) GetObjectArray(key string) fftypes.JSONObjectArray {
keysMutex.Lock()
defer keysMutex.Unlock()
v, _ := fftypes.ToJSONObjectArray(viper.Get(c.prefixKey(key)))
return v
}
// Get gets a configuration in raw form
func Get(key RootKey) interface{} {
return root.Get(string(key))
}
func (c *configSection) Get(key string) interface{} {
keysMutex.Lock()
defer keysMutex.Unlock()
return viper.Get(c.prefixKey(key))
}
// Set allows runtime setting of config (used in unit tests)
func Set(key RootKey, value interface{}) {
root.Set(string(key), value)
}
func (c *configSection) Set(key string, value interface{}) {
keysMutex.Lock()
defer keysMutex.Unlock()
viper.Set(c.prefixKey(key), value)
}
// Resolve gives the fully qualified path of a key
func (c *configSection) Resolve(key string) string {
keysMutex.Lock()
defer keysMutex.Unlock()
return c.prefixKey(key)
}
// SetupLogging initializes logging
func SetupLogging(ctx context.Context) {
log.SetFormatting(log.Formatting{
DisableColor: GetBool(LogNoColor),
ForceColor: GetBool(LogForceColor),
TimestampFormat: GetString(LogTimeFormat),
UTC: GetBool(LogUTC),
IncludeCodeInfo: GetBool(LogIncludeCodeInfo),
JSONEnabled: GetBool(LogJSONEnabled),
JSONTimestampField: GetString(LogJSONTimestampField),
JSONLevelField: GetString(LogJSONLevelField),
JSONMessageField: GetString(LogJSONMessageField),
JSONFuncField: GetString(LogJSONFuncField),
JSONFileField: GetString(LogJSONFileField),
})
logFilename := GetString(LogFilename)
if logFilename != "" {
lumberjack := &lumberjack.Logger{
Filename: logFilename,
MaxSize: int(math.Ceil(float64(GetByteSize(LogFilesize)) / 1024 / 1024)), /* round up in megabytes */
MaxBackups: GetInt(LogMaxBackups),
MaxAge: int(math.Ceil(float64(GetDuration(LogMaxAge)) / float64(time.Hour) / 24)), /* round up in days */
Compress: GetBool(LogCompress),
}
logrus.SetOutput(lumberjack)
}
log.SetLevel(GetString(LogLevel))
log.L(ctx).Debugf("Log level: %s", logrus.GetLevel())
}
func GenerateConfigMarkdown(ctx context.Context, keys []string) ([]byte, error) {
b := bytes.NewBuffer([]byte{})
rootKeyHeaderLevel := 2
b.WriteString(configDocHeader)
configObjects := make(map[string][]string)
configObjectNames := make([]string, 0)
for _, fullKey := range keys {
splitKey := strings.Split(fullKey, ".")
if len(splitKey) > 1 {
configObjectName := strings.Join(splitKey[:len(splitKey)-1], ".")
keyName := splitKey[len(splitKey)-1]
if _, ok := configObjects[configObjectName]; !ok {
configObjects[configObjectName] = make([]string, 0)
configObjectNames = append(configObjectNames, configObjectName)
}
configObjects[configObjectName] = append(configObjects[configObjectName], keyName)
}
}
sort.Strings(configObjectNames)
for _, configObjectName := range configObjectNames {
rowsInTable := []string{}
sort.Strings(configObjects[configObjectName])
for _, key := range configObjects[configObjectName] {
fullKey := fmt.Sprintf("%s.%s", configObjectName, key)
description, fieldType := getDescriptionForConfigKey(ctx, fullKey)
if fieldType != i18n.IgnoredType {
row := fmt.Sprintf("\n|%s|%s|%s|`%v`", key, description, fieldType, Get(RootKey(fullKey)))
rowsInTable = append(rowsInTable, row)
}
}
if len(rowsInTable) > 0 {
b.WriteString(fmt.Sprintf("\n\n%s %s", strings.Repeat("#", rootKeyHeaderLevel), configObjectName))
b.WriteString("\n\n|Key|Description|Type|Default Value|")
b.WriteString("\n|---|-----------|----|-------------|")
for _, row := range rowsInTable {
b.WriteString(row)
}
}
}
return b.Bytes(), nil
}
func getDescriptionForConfigKey(ctx context.Context, key string) (string, string) {
configDescriptionKey := "config." + key
description := i18n.Expand(ctx, i18n.MessageKey(configDescriptionKey))
fieldType, ok := i18n.GetFieldType(configDescriptionKey)
if description != configDescriptionKey && ok {
return description, fieldType
}
return getGlobalDescriptionforConfigKey(ctx, key)
}
func getGlobalDescriptionforConfigKey(ctx context.Context, key string) (string, string) {
// No specific description was found, look for a global
splitKey := strings.Split(key, ".")
// Walk through the key structure starting with the most specific key possible, working to the most generic
for i := 0; i < len(splitKey); i++ {
configDescriptionKey := "config.global." + strings.Join(splitKey[i:], ".")
description := i18n.Expand(ctx, i18n.MessageKey(configDescriptionKey))
fieldType, ok := i18n.GetFieldType(configDescriptionKey)
if description != configDescriptionKey && ok {
return description, fieldType
}
}
panic(fmt.Sprintf("Translation for config key '%s' was not found", key))
}
const configDocHeader = `---
layout: default
title: pages.reference
parent: Reference
nav_order: 2
---
# Configuration Reference
{: .no_toc }
<!-- ## Table of contents
{: .no_toc .text-delta }
1. TOC
{:toc} -->
---
`