Skip to content

Commit 9fe40a1

Browse files
committed
fix(osgen): treat ISM/KNN/LTR/ML/PPL/SM/UBI/WLM as acronyms
Go identifier convention requires acronyms to be all-uppercase (the generator already does this for API, HTTP, JSON, URL, etc.). The OpenSearch plugin-namespace acronyms were missing from the table, so the generated surface emitted IsmPolicy, KnnStats, MlModel, SmPolicy, and similar mis-cased identifiers. Add the missing entries to the acronyms map so titleSegment expands them: ISM Index State Management KNN k-Nearest Neighbors LTR Learning to Rank ML Machine Learning PPL Piped Processing Language SM Snapshot Management UBI User Behavior Insights WLM Workload Management Matching is whole-segment only (segments are split on '.' and '_' before lookup), so words like "smile" are unaffected; a regression test pins this. The rename takes effect on the next code generation, which rewrites the affected *_gen.go identifiers (e.g. IsmPolicy -> ISMPolicy) in one pass. Closes opensearch-project#863 Signed-off-by: Sean Chittenden <sean.chittenden@crowdstrike.com>
1 parent 8001980 commit 9fe40a1

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

cmd/osgen/naming.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,24 @@ var acronyms = map[string]string{
8989
"https": "HTTPS",
9090
"id": "ID",
9191
"ip": "IP",
92+
"ism": "ISM", // Index State Management
9293
"json": "JSON",
93-
"pit": "PIT",
94+
"knn": "KNN", // k-Nearest Neighbors
95+
"ltr": "LTR", // Learning to Rank
96+
"ml": "ML", // Machine Learning
97+
"pit": "PIT", // Point In Time
98+
"ppl": "PPL", // Piped Processing Language
99+
"sm": "SM", // Snapshot Management
94100
"sql": "SQL",
95101
"ssl": "SSL",
96102
"tcp": "TCP",
97103
"tls": "TLS",
98104
"ttl": "TTL",
105+
"ubi": "UBI", // User Behavior Insights
99106
"uri": "URI",
100107
"url": "URL",
101108
"uuid": "UUID",
109+
"wlm": "WLM", // Workload Management
102110
"xml": "XML",
103111
}
104112

cmd/osgen/naming_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ func TestTitleSegment(t *testing.T) {
3333
{name: "ssl acronym", input: "ssl", want: "SSL"},
3434
{name: "api acronym", input: "api", want: "API"},
3535
{name: "json acronym", input: "json", want: "JSON"},
36+
{name: "ism acronym", input: "ism", want: "ISM"},
37+
{name: "knn acronym", input: "knn", want: "KNN"},
38+
{name: "ltr acronym", input: "ltr", want: "LTR"},
39+
{name: "ml acronym", input: "ml", want: "ML"},
40+
{name: "ppl acronym", input: "ppl", want: "PPL"},
41+
{name: "sm acronym", input: "sm", want: "SM"},
42+
{name: "ubi acronym", input: "ubi", want: "UBI"},
43+
{name: "wlm acronym", input: "wlm", want: "WLM"},
44+
{name: "whole-segment only, not substring", input: "smile", want: "Smile"},
3645
{name: "empty", input: "", want: ""},
3746
{name: "mixed case id", input: "ID", want: "ID"},
3847
{name: "mixed case uuid", input: "UUID", want: "UUID"},
@@ -276,6 +285,8 @@ func TestSchemaTypeName(t *testing.T) {
276285
{name: "group._common cluster", schemaKey: "cluster._common___ComponentTemplate", want: "ClusterComponentTemplate"},
277286
{name: "acronyms", schemaKey: "security._common___SSLInfo", want: "SecuritySSLInfo"},
278287
{name: "sql plugin", schemaKey: "sql._common___SQLQuery", want: "SQLQuery"},
288+
{name: "ism plugin acronym", schemaKey: "ism._common___Policy", want: "ISMPolicy"},
289+
{name: "knn plugin acronym", schemaKey: "knn._common___Stats", want: "KNNStats"},
279290
{name: "de-stutter empty result kept", schemaKey: "cluster.health___Health", want: "ClusterHealthHealth"},
280291

281292
// Idiomatic abbreviations: M-prefix initialisms, compound nouns,

0 commit comments

Comments
 (0)