Skip to content

Commit 39bdf64

Browse files
Fixed indexers generation
1 parent 903757e commit 39bdf64

File tree

7 files changed

+35
-9
lines changed

7 files changed

+35
-9
lines changed

tools/.DS_Store

6 KB
Binary file not shown.

tools/openapi2crd/config.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ spec:
3838
openapi:
3939
- name: v20250312
4040
package: go.mongodb.org/atlas-sdk/v20250312005/admin
41+
- name: v20250313
42+
package: go.mongodb.org/atlas-sdk/v20250312006/admin
4143

4244
crd:
4345
- gvk:
@@ -60,7 +62,17 @@ spec:
6062
skipProperties:
6163
- $.apiKey
6264
- $.organization.links
63-
65+
- majorVersion: v20250313
66+
openAPIRef:
67+
name: v20250313
68+
entry:
69+
schema: "CreateOrganizationRequest"
70+
status:
71+
schema: "CreateOrganizationResponse"
72+
filters:
73+
skipProperties:
74+
- $.apiKey
75+
- $.organization.links
6476
- gvk:
6577
version: v1
6678
kind: Group

tools/openapi2crd/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ require (
7474
github.com/stretchr/objx v0.5.2 // indirect
7575
github.com/subosito/gotenv v1.2.0 // indirect
7676
github.com/x448/float16 v0.8.4 // indirect
77+
go.mongodb.org/atlas-sdk/v20250312006 v20250312006.1.0 // indirect
7778
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
7879
go.opentelemetry.io/otel v1.28.0 // indirect
7980
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect

tools/openapi2crd/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ go.etcd.io/etcd/client/v3 v3.5.16 h1:sSmVYOAHeC9doqi0gv7v86oY/BTld0SEFGaxsU9eRhE
388388
go.etcd.io/etcd/client/v3 v3.5.16/go.mod h1:X+rExSGkyqxvu276cr2OwPLBaeqFu1cIl4vmRjAD/50=
389389
go.mongodb.org/atlas-sdk/v20250312005 v20250312005.0.0 h1:uKOtHXCP/Gwuj+IF1hsKtIAxNSVjKNo+o4Z+ulgCEXw=
390390
go.mongodb.org/atlas-sdk/v20250312005 v20250312005.0.0/go.mod h1:UeRE741z+kDGH00qQasZmthQxJMeA6PmAtY/2dStW+Q=
391+
go.mongodb.org/atlas-sdk/v20250312006 v20250312006.1.0 h1:PcVxslw4G7/I9SbUi5y81i4YZnL1dKRnGpeHVyNSTh4=
392+
go.mongodb.org/atlas-sdk/v20250312006 v20250312006.1.0/go.mod h1:UZYSaCimjGs3j+wMwgHSKUSIvoJXzmy/xrer0t5TLgo=
391393
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
392394
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
393395
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=

tools/output

Whitespace-only changes.

tools/scaffolder/Makefile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
21
build:
32
go build -o bin/scaffolder cmd/main.go
43

5-
generate:
6-
controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./pkg/api/..."
4+
list: build
5+
./bin/scaffolder --input ../openapi2crd/result.yaml --list
6+
7+
generate: build
8+
./bin/scaffolder --input ../openapi2crd/result.yaml --crd $(CRD_NAME) \
9+
--indexer-out ../../internal/indexer \
10+
--controller-out ../../internal/controller \
11+
--translation-out ../../internal/translation
12+
13+

tools/scaffolder/internal/generate/indexers.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,8 @@ func ParseReferenceFields(resultPath, crdKind string) ([]ReferenceField, error)
6565
continue
6666
}
6767

68-
if refs != nil {
69-
return refs, nil
70-
}
68+
// We found the target CRD, return the references (even if empty)
69+
return refs, nil
7170
}
7271

7372
return nil, fmt.Errorf("CRD kind '%s' not found in result file", crdKind)
@@ -103,9 +102,13 @@ func parseNextCRDReferences(scanner *bufio.Scanner, targetKind string) ([]Refere
103102
if buffer.Len() > 0 {
104103
refs, err := extractReferencesFromCRD(buffer.Bytes(), targetKind)
105104
if err != nil {
106-
return nil, err
105+
// Ignore "not target CRD" errors, just like in the loop above
106+
if err.Error() != "not target CRD" {
107+
return nil, err
108+
}
109+
} else {
110+
return refs, nil
107111
}
108-
return refs, nil
109112
}
110113

111114
return nil, io.EOF
@@ -130,6 +133,7 @@ func extractReferencesFromCRD(content []byte, targetKind string) ([]ReferenceFie
130133
}
131134
}
132135

136+
// Return empty slice for CRDs with no references (this is valid)
133137
return references, nil
134138
}
135139

0 commit comments

Comments
 (0)