Skip to content

Commit 2ee5609

Browse files
committed
run make modernize
Signed-off-by: Charlie Le <[email protected]>
1 parent 011d192 commit 2ee5609

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

tools/doc-generator/json_schema_writer.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ func (w *JSONSchemaWriter) WriteSchema(blocks []*configBlock) error {
2323
return encoder.Encode(schema)
2424
}
2525

26-
func (w *JSONSchemaWriter) generateJSONSchema(blocks []*configBlock) map[string]interface{} {
27-
schema := map[string]interface{}{
26+
func (w *JSONSchemaWriter) generateJSONSchema(blocks []*configBlock) map[string]any {
27+
schema := map[string]any{
2828
"$schema": "https://json-schema.org/draft/2020-12/schema",
2929
"$id": "https://raw.githubusercontent.com/cortexproject/cortex/master/schemas/cortex-config-schema.json",
3030
"title": "Cortex Configuration Schema",
3131
"description": "JSON Schema for Cortex configuration file",
3232
"type": "object",
33-
"properties": map[string]interface{}{},
34-
"definitions": map[string]interface{}{},
33+
"properties": map[string]any{},
34+
"definitions": map[string]any{},
3535
}
3636

37-
properties := schema["properties"].(map[string]interface{})
38-
definitions := schema["definitions"].(map[string]interface{})
37+
properties := schema["properties"].(map[string]any)
38+
definitions := schema["definitions"].(map[string]any)
3939

4040
// Process each config block
4141
for _, block := range blocks {
@@ -51,15 +51,15 @@ func (w *JSONSchemaWriter) generateJSONSchema(blocks []*configBlock) map[string]
5151
return schema
5252
}
5353

54-
func (w *JSONSchemaWriter) processBlockEntries(block *configBlock, properties map[string]interface{}, definitions map[string]interface{}) {
54+
func (w *JSONSchemaWriter) processBlockEntries(block *configBlock, properties map[string]any, definitions map[string]any) {
5555
for _, entry := range block.entries {
5656
switch entry.kind {
5757
case "field":
5858
properties[entry.name] = w.generateFieldSchema(entry)
5959
case "block":
6060
if entry.root {
6161
// Root blocks are referenced via $ref
62-
properties[entry.name] = map[string]interface{}{
62+
properties[entry.name] = map[string]any{
6363
"$ref": fmt.Sprintf("#/definitions/%s", entry.block.name),
6464
}
6565
// Add the block to definitions if not already there
@@ -74,17 +74,17 @@ func (w *JSONSchemaWriter) processBlockEntries(block *configBlock, properties ma
7474
}
7575
}
7676

77-
func (w *JSONSchemaWriter) generateBlockSchema(block *configBlock) map[string]interface{} {
78-
obj := map[string]interface{}{
77+
func (w *JSONSchemaWriter) generateBlockSchema(block *configBlock) map[string]any {
78+
obj := map[string]any{
7979
"type": "object",
80-
"properties": map[string]interface{}{},
80+
"properties": map[string]any{},
8181
}
8282

8383
if block.desc != "" {
8484
obj["description"] = block.desc
8585
}
8686

87-
properties := obj["properties"].(map[string]interface{})
87+
properties := obj["properties"].(map[string]any)
8888

8989
for _, entry := range block.entries {
9090
switch entry.kind {
@@ -93,7 +93,7 @@ func (w *JSONSchemaWriter) generateBlockSchema(block *configBlock) map[string]in
9393
case "block":
9494
if entry.root {
9595
// Reference to another root block
96-
properties[entry.name] = map[string]interface{}{
96+
properties[entry.name] = map[string]any{
9797
"$ref": fmt.Sprintf("#/definitions/%s", entry.block.name),
9898
}
9999
} else {
@@ -106,8 +106,8 @@ func (w *JSONSchemaWriter) generateBlockSchema(block *configBlock) map[string]in
106106
return obj
107107
}
108108

109-
func (w *JSONSchemaWriter) generateFieldSchema(entry *configEntry) map[string]interface{} {
110-
prop := map[string]interface{}{
109+
func (w *JSONSchemaWriter) generateFieldSchema(entry *configEntry) map[string]any {
110+
prop := map[string]any{
111111
"type": w.getJSONType(entry.fieldType),
112112
}
113113

@@ -143,7 +143,7 @@ func (w *JSONSchemaWriter) generateFieldSchema(entry *configEntry) map[string]in
143143
if strings.HasPrefix(entry.fieldType, "list of ") {
144144
prop["type"] = "array"
145145
itemType := strings.TrimPrefix(entry.fieldType, "list of ")
146-
prop["items"] = map[string]interface{}{
146+
prop["items"] = map[string]any{
147147
"type": w.getJSONType(itemType),
148148
}
149149
}
@@ -185,7 +185,7 @@ func (w *JSONSchemaWriter) getJSONType(goType string) string {
185185
}
186186
}
187187

188-
func (w *JSONSchemaWriter) parseDefaultValue(defaultStr, goType string) interface{} {
188+
func (w *JSONSchemaWriter) parseDefaultValue(defaultStr, goType string) any {
189189
if defaultStr == "" {
190190
return nil
191191
}
@@ -206,11 +206,11 @@ func (w *JSONSchemaWriter) parseDefaultValue(defaultStr, goType string) interfac
206206
default:
207207
// Handle special cases
208208
if defaultStr == "[]" {
209-
return []interface{}{}
209+
return []any{}
210210
}
211211
if strings.HasPrefix(defaultStr, "[") && strings.HasSuffix(defaultStr, "]") {
212212
// Try to parse as JSON array
213-
var arr []interface{}
213+
var arr []any
214214
if err := json.Unmarshal([]byte(defaultStr), &arr); err == nil {
215215
return arr
216216
}

0 commit comments

Comments
 (0)