Skip to content

Commit 86e8290

Browse files
chore(updater): bump pkg/dist/*.yml (2025-07-09) (#334)
Co-authored-by: Murad Biashimov <[email protected]>
1 parent c1aeab0 commit 86e8290

File tree

6 files changed

+55
-52
lines changed

6 files changed

+55
-52
lines changed

.golangci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ linters:
1313
- gocyclo
1414
- gofmt
1515
- goimports
16-
- gomnd
16+
- mnd
1717
- gosec
1818
- gosimple
1919
- govet
@@ -40,7 +40,7 @@ linters-settings:
4040
min-len: 2
4141
min-occurrences: 2
4242
govet:
43-
check-shadowing: true
43+
shadowing: true
4444
lll:
4545
line-length: 120
4646
tab-width: 4

.trunk/trunk.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ lint:
2525
- pkg/dist/*.yml
2626
runtimes:
2727
enabled:
28-
- go@1.22.4
28+
- go@1.24.1
2929
3030
3131
actions:

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/aiven/go-api-schemas
22

3-
go 1.22
3+
go 1.24
44

55
require (
66
github.com/google/go-cmp v0.7.0

internal/gen/gen.go

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"fmt"
77
"log"
8+
"maps"
89
"os"
910
"path/filepath"
1011
"regexp"
@@ -133,6 +134,19 @@ func toUserConfig(src *schema) (*types.UserConfigSchema, error) { // nolint: fun
133134
return nil, err
134135
}
135136

137+
// Convert "null" type to a "nullable" boolean field.
138+
// It is easier to ask a bool field and cast a single "type" instead of a list.
139+
normTypes = slices.DeleteFunc(normTypes, func(s string) bool {
140+
if s != "null" {
141+
return false
142+
}
143+
src.Nullable = true
144+
return true
145+
})
146+
147+
// Only mark required fields as nullable since optional fields can't be null in Go.
148+
src.Nullable = src.isRequired && src.Nullable
149+
136150
uc := types.UserConfigSchema{
137151
Properties: make(map[string]types.UserConfigSchema),
138152
Title: src.Title,
@@ -143,6 +157,7 @@ func toUserConfig(src *schema) (*types.UserConfigSchema, error) { // nolint: fun
143157
MaxLength: src.MaxLength,
144158
MaxItems: src.MaxItems,
145159
Pattern: src.Pattern,
160+
Nullable: src.Nullable,
146161
UserError: or(src.XUserError, src.UserError),
147162
Secure: or(src.XSecure, src.Secure),
148163
CreateOnly: or(src.XCreateOnly, src.CreateOnly),
@@ -213,18 +228,6 @@ func toUserConfig(src *schema) (*types.UserConfigSchema, error) { // nolint: fun
213228
return &uc, nil
214229
}
215230

216-
func distinct[T comparable](list []T) []T {
217-
seen := make(map[T]bool)
218-
result := make([]T, 0, len(list))
219-
for _, v := range list {
220-
if !seen[v] {
221-
seen[v] = true
222-
result = append(result, v)
223-
}
224-
}
225-
return result
226-
}
227-
228231
// or returns the first non-zero value.
229232
func or[T comparable](args ...T) T {
230233
var zero T
@@ -237,44 +240,45 @@ func or[T comparable](args ...T) T {
237240
}
238241

239242
func normalizeType(s *schema) ([]string, error) {
240-
result := make([]string, 0)
243+
result := make(map[string]bool)
241244
switch t := s.Type.(type) {
242245
case string:
243246
return []string{t}, nil
244247
case []any:
245248
for _, v := range t {
246-
if v == "null" {
247-
s.Nullable = true
248-
} else {
249-
result = append(result, fmt.Sprintf("%v", v))
250-
}
249+
result[fmt.Sprintf("%v", v)] = true
251250
}
252251
case nil:
253252
default:
254253
return nil, fmt.Errorf("unknown type %T", s.Type)
255254
}
256255

257-
// Golang supports null for required fields only
258-
if s.isRequired && s.Nullable {
259-
result = append(result, "null")
260-
}
261-
262256
for _, v := range s.AnyOf {
263257
if v.Type != nil {
264258
vType, err := normalizeType(v)
265259
if err != nil {
266260
return nil, err
267261
}
268262

269-
result = append(result, vType...)
263+
for _, t := range vType {
264+
result[t] = true
265+
}
270266
}
271267
}
272268

269+
// Fixes the case when there is no type defined
273270
if len(result) == 0 {
274-
result = append(result, "string")
271+
result["string"] = true
272+
}
273+
274+
// Prioritize number over integer, because number is more general, and Go can't have both.
275+
if result["number"] && result["integer"] {
276+
delete(result, "integer")
275277
}
276278

277-
return distinct(result), nil
279+
keys := slices.Collect(maps.Keys(result))
280+
slices.Sort(keys)
281+
return keys, nil
278282
}
279283

280284
func formatValue(t string, v any) any {

internal/pkg/types/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type UserConfigSchema struct {
4343
Example interface{} `yaml:"example,omitempty"`
4444
UserError string `yaml:"user_error,omitempty"`
4545
Secure bool `yaml:"_secure,omitempty"`
46+
Nullable bool `yaml:"nullable,omitempty"`
4647
}
4748

4849
// GenerationResult represents the result of a generation.

pkg/dist/service_types.yml

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ alloydbomni:
7575
items:
7676
title: CIDR address block, either as a string, or in a dict with an optional description field
7777
type:
78-
- string
7978
- object
79+
- string
8080
required:
8181
- network
8282
properties:
@@ -802,8 +802,8 @@ cassandra:
802802
items:
803803
title: CIDR address block, either as a string, or in a dict with an optional description field
804804
type:
805-
- string
806805
- object
806+
- string
807807
required:
808808
- network
809809
properties:
@@ -915,8 +915,8 @@ clickhouse:
915915
items:
916916
title: CIDR address block, either as a string, or in a dict with an optional description field
917917
type:
918-
- string
919918
- object
919+
- string
920920
required:
921921
- network
922922
properties:
@@ -1052,8 +1052,8 @@ dragonfly:
10521052
items:
10531053
title: CIDR address block, either as a string, or in a dict with an optional description field
10541054
type:
1055-
- string
10561055
- object
1056+
- string
10571057
required:
10581058
- network
10591059
properties:
@@ -1233,8 +1233,8 @@ flink:
12331233
items:
12341234
title: CIDR address block, either as a string, or in a dict with an optional description field
12351235
type:
1236-
- string
12371236
- object
1237+
- string
12381238
required:
12391239
- network
12401240
properties:
@@ -1854,8 +1854,8 @@ grafana:
18541854
items:
18551855
title: CIDR address block, either as a string, or in a dict with an optional description field
18561856
type:
1857-
- string
18581857
- object
1858+
- string
18591859
required:
18601860
- network
18611861
properties:
@@ -2104,8 +2104,8 @@ influxdb:
21042104
items:
21052105
title: CIDR address block, either as a string, or in a dict with an optional description field
21062106
type:
2107-
- string
21082107
- object
2108+
- string
21092109
required:
21102110
- network
21112111
properties:
@@ -2233,8 +2233,8 @@ kafka:
22332233
items:
22342234
title: CIDR address block, either as a string, or in a dict with an optional description field
22352235
type:
2236-
- string
22372236
- object
2237+
- string
22382238
required:
22392239
- network
22402240
properties:
@@ -3104,8 +3104,8 @@ kafka_connect:
31043104
items:
31053105
title: CIDR address block, either as a string, or in a dict with an optional description field
31063106
type:
3107-
- string
31083107
- object
3108+
- string
31093109
required:
31103110
- network
31113111
properties:
@@ -3417,8 +3417,8 @@ kafka_mirrormaker:
34173417
items:
34183418
title: CIDR address block, either as a string, or in a dict with an optional description field
34193419
type:
3420-
- string
34213420
- object
3421+
- string
34223422
required:
34233423
- network
34243424
properties:
@@ -3551,8 +3551,8 @@ m3aggregator:
35513551
items:
35523552
title: CIDR address block, either as a string, or in a dict with an optional description field
35533553
type:
3554-
- string
35553554
- object
3555+
- string
35563556
required:
35573557
- network
35583558
properties:
@@ -3625,8 +3625,8 @@ m3db:
36253625
items:
36263626
title: CIDR address block, either as a string, or in a dict with an optional description field
36273627
type:
3628-
- string
36293628
- object
3629+
- string
36303630
required:
36313631
- network
36323632
properties:
@@ -4017,8 +4017,8 @@ mysql:
40174017
items:
40184018
title: CIDR address block, either as a string, or in a dict with an optional description field
40194019
type:
4020-
- string
40214020
- object
4021+
- string
40224022
required:
40234023
- network
40244024
properties:
@@ -4637,8 +4637,8 @@ opensearch:
46374637
items:
46384638
title: CIDR address block, either as a string, or in a dict with an optional description field
46394639
type:
4640-
- string
46414640
- object
4641+
- string
46424642
required:
46434643
- network
46444644
properties:
@@ -4884,12 +4884,10 @@ opensearch:
48844884
cluster.filecache.remote_data_ratio:
48854885
title: The limit of how much total remote data can be referenced
48864886
description: Defines a limit of how much total remote data can be referenced as a ratio of the size of the disk reserved for the file cache. This is designed to be a safeguard to prevent oversubscribing a cluster. Defaults to 0.
4887-
type:
4888-
- integer
4889-
- number
4887+
type: number
48904888
minimum: 0
48914889
maximum: 100
4892-
example: "5"
4890+
example: "5.0"
48934891
cluster.remote_store:
48944892
type: object
48954893
properties:
@@ -5881,8 +5879,8 @@ pg:
58815879
items:
58825880
title: CIDR address block, either as a string, or in a dict with an optional description field
58835881
type:
5884-
- string
58855882
- object
5883+
- string
58865884
required:
58875885
- network
58885886
properties:
@@ -6702,8 +6700,8 @@ redis:
67026700
items:
67036701
title: CIDR address block, either as a string, or in a dict with an optional description field
67046702
type:
6705-
- string
67066703
- object
6704+
- string
67076705
required:
67086706
- network
67096707
properties:
@@ -6949,8 +6947,8 @@ thanos:
69496947
items:
69506948
title: CIDR address block, either as a string, or in a dict with an optional description field
69516949
type:
6952-
- string
69536950
- object
6951+
- string
69546952
required:
69556953
- network
69566954
properties:
@@ -7153,8 +7151,8 @@ valkey:
71537151
items:
71547152
title: CIDR address block, either as a string, or in a dict with an optional description field
71557153
type:
7156-
- string
71577154
- object
7155+
- string
71587156
required:
71597157
- network
71607158
properties:

0 commit comments

Comments
 (0)