Add missing period_config root block to doc generator (#7981)

**What this PR does / why we need it**:
Update doc generator tool to validate if slice element is a root block.

Add missing `period_config` root block to doc generator tool.

**Special notes for your reviewer**:

**Checklist**
- [ ] Documentation updated
pull/7997/head
Susana Ferreira 2 years ago committed by GitHub
parent d36dd9edc4
commit d086c237df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 49
      docs/sources/configuration/_index.md
  2. 18
      pkg/storage/config/schema_config.go
  3. 28
      tools/doc-generator/parse/parser.go

@ -3610,6 +3610,55 @@ fifocache:
[async_cache_write_back_buffer_size: <int> | default = 500] [async_cache_write_back_buffer_size: <int> | default = 500]
``` ```
### period_config
The `period_config` block configures what index schemas should be used for from specific time periods.
```yaml
# The date of the first day that index buckets should be created. Use a date in
# the past if this is your only period_config, otherwise use a date when you
# want the schema to switch over. In YYYY-MM-DD format, for example: 2018-04-15.
[from: <daytime>]
# store and object_store below affect which <storage_config> key is used.
# Which store to use for the index. Either aws, aws-dynamo, gcp, bigtable,
# bigtable-hashed, cassandra, boltdb or boltdb-shipper.
[store: <string> | default = ""]
# Which store to use for the chunks. Either aws, azure, gcp, bigtable, gcs,
# cassandra, swift or filesystem. If omitted, defaults to the same value as
# store.
[object_store: <string> | default = ""]
# The schema version to use, current recommended schema is v11.
[schema: <string> | default = ""]
# Configures how the index is updated and stored.
index:
# Table prefix for all period tables.
[prefix: <string> | default = ""]
# Table period.
[period: <duration>]
# A map to be added to all managed tables.
[tags: <map of string to string>]
# Configured how the chunks are updated and stored.
chunks:
# Table prefix for all period tables.
[prefix: <string> | default = ""]
# Table period.
[period: <duration>]
# A map to be added to all managed tables.
[tags: <map of string to string>]
# How many shards will be created. Only used if schema is v10 or greater.
[row_shards: <int>]
```
### azure_storage_config ### azure_storage_config
The `azure_storage_config` block configures the connection to Azure object storage backend. The supported CLI flags `<prefix>` used to reference this configuration block are: The `azure_storage_config` block configures the connection to Azure object storage backend. The supported CLI flags `<prefix>` used to reference this configuration block are:

@ -91,13 +91,13 @@ type PeriodConfig struct {
// used when working with config // used when working with config
From DayTime `yaml:"from" doc:"description=The date of the first day that index buckets should be created. Use a date in the past if this is your only period_config, otherwise use a date when you want the schema to switch over. In YYYY-MM-DD format, for example: 2018-04-15."` From DayTime `yaml:"from" doc:"description=The date of the first day that index buckets should be created. Use a date in the past if this is your only period_config, otherwise use a date when you want the schema to switch over. In YYYY-MM-DD format, for example: 2018-04-15."`
// type of index client to use. // type of index client to use.
IndexType string `yaml:"store"` IndexType string `yaml:"store" doc:"description=store and object_store below affect which <storage_config> key is used.\nWhich store to use for the index. Either aws, aws-dynamo, gcp, bigtable, bigtable-hashed, cassandra, boltdb or boltdb-shipper. "`
// type of object client to use; if omitted, defaults to store. // type of object client to use; if omitted, defaults to store.
ObjectType string `yaml:"object_store"` ObjectType string `yaml:"object_store" doc:"description=Which store to use for the chunks. Either aws, azure, gcp, bigtable, gcs, cassandra, swift or filesystem. If omitted, defaults to the same value as store."`
Schema string `yaml:"schema"` Schema string `yaml:"schema" doc:"description=The schema version to use, current recommended schema is v11."`
IndexTables PeriodicTableConfig `yaml:"index"` IndexTables PeriodicTableConfig `yaml:"index" doc:"description=Configures how the index is updated and stored."`
ChunkTables PeriodicTableConfig `yaml:"chunks"` ChunkTables PeriodicTableConfig `yaml:"chunks" doc:"description=Configured how the chunks are updated and stored."`
RowShards uint32 `yaml:"row_shards"` RowShards uint32 `yaml:"row_shards" doc:"description=How many shards will be created. Only used if schema is v10 or greater."`
// Integer representation of schema used for hot path calculation. Populated on unmarshaling. // Integer representation of schema used for hot path calculation. Populated on unmarshaling.
schemaInt *int `yaml:"-"` schemaInt *int `yaml:"-"`
@ -369,9 +369,9 @@ func (cfg *PeriodConfig) VersionAsInt() (int, error) {
// PeriodicTableConfig is configuration for a set of time-sharded tables. // PeriodicTableConfig is configuration for a set of time-sharded tables.
type PeriodicTableConfig struct { type PeriodicTableConfig struct {
Prefix string Prefix string `yaml:"prefix" doc:"description=Table prefix for all period tables."`
Period time.Duration Period time.Duration `yaml:"period" doc:"description=Table period."`
Tags Tags Tags Tags `yaml:"tags" doc:"description=A map to be added to all managed tables."`
} }
// UnmarshalYAML implements the yaml.Unmarshaler interface. // UnmarshalYAML implements the yaml.Unmarshaler interface.

@ -256,16 +256,30 @@ func config(block *ConfigBlock, cfg interface{}, flags map[uintptr]*flag.Flag, r
_, isCustomType := getFieldCustomType(field.Type) _, isCustomType := getFieldCustomType(field.Type)
isSliceOfStructs := field.Type.Kind() == reflect.Slice && (field.Type.Elem().Kind() == reflect.Struct || field.Type.Elem().Kind() == reflect.Ptr) isSliceOfStructs := field.Type.Kind() == reflect.Slice && (field.Type.Elem().Kind() == reflect.Struct || field.Type.Elem().Kind() == reflect.Ptr)
if !isCustomType && isSliceOfStructs { if !isCustomType && isSliceOfStructs {
// Check if slice element type is a root block
// and add it to the blocks structure
rootName, rootDesc, isRoot := isRootBlock(field.Type.Elem(), rootBlocks)
if isRoot {
sliceElementBlock, err := config(nil, reflect.New(field.Type.Elem()).Interface(), flags, rootBlocks)
if err != nil {
return nil, errors.Wrapf(err, "couldn't inspect slice, element_type=%s", field.Type.Elem())
}
if len(sliceElementBlock) == 1 {
element = &ConfigBlock{
Name: rootName,
Desc: rootDesc,
Entries: sliceElementBlock[0].Entries,
}
blocks = append(blocks, element)
}
}
// Add slice element to current block
element = &ConfigBlock{ element = &ConfigBlock{
Name: fieldName, Name: fieldName,
Desc: getFieldDescription(cfg, field, ""), Desc: getFieldDescription(cfg, field, ""),
} }
kind = KindSlice kind = KindSlice
_, err = config(element, reflect.New(field.Type.Elem()).Interface(), flags, rootBlocks)
if err != nil {
return nil, errors.Wrapf(err, "couldn't inspect slice, element_type=%s", field.Type.Elem())
}
} }
} }
@ -338,6 +352,8 @@ func getFieldCustomType(t reflect.Type) (string, bool) {
return "url", true return "url", true
case reflect.TypeOf(time.Duration(0)).String(): case reflect.TypeOf(time.Duration(0)).String():
return "duration", true return "duration", true
case reflect.TypeOf(storage_config.DayTime{}).String():
return "daytime", true
case reflect.TypeOf(flagext.StringSliceCSV{}).String(): case reflect.TypeOf(flagext.StringSliceCSV{}).String():
return fieldString, true return fieldString, true
case reflect.TypeOf(flagext.CIDRSliceCSV{}).String(): case reflect.TypeOf(flagext.CIDRSliceCSV{}).String():
@ -421,6 +437,8 @@ func getCustomFieldType(t reflect.Type) (string, bool) {
return "url", true return "url", true
case reflect.TypeOf(time.Duration(0)).String(): case reflect.TypeOf(time.Duration(0)).String():
return "duration", true return "duration", true
case reflect.TypeOf(storage_config.DayTime{}).String():
return "daytime", true
case reflect.TypeOf(flagext.StringSliceCSV{}).String(): case reflect.TypeOf(flagext.StringSliceCSV{}).String():
return fieldString, true return fieldString, true
case reflect.TypeOf(flagext.CIDRSliceCSV{}).String(): case reflect.TypeOf(flagext.CIDRSliceCSV{}).String():

Loading…
Cancel
Save