[codegen/nodejs] Fix k8s index.ts generation
@@ -39,7 +39,7 @@ import (
)
// Match k8s version suffix. Examples include "/v1beta1" and "/v1alpha2".
-var k8sVersionSuffix = regexp.MustCompile(`/v\d+((alpha|beta)\d+)?$`)
+var k8sVersionSuffix = regexp.MustCompile(`/(v\d+((alpha|beta)\d+)?)$`)
type typeDetails struct {
outputType bool
@@ -1155,9 +1155,10 @@ func (mod *modContext) genIndex(exports []string) string {
for _, mod := range mod.children {
child := mod.mod
if mod.compatibility == kubernetes20 {
- // Trim version suffix from child modules. Nested versions will have their own index.ts file.
- if match := k8sVersionSuffix.FindStringIndex(child); len(match) != 0 {
- child = child[:match[0]]
+ // Extract version suffix from child modules. Nested versions will have their own index.ts file.
+ // Example: apps/v1beta1 -> v1beta1
+ if match := k8sVersionSuffix.FindStringSubmatchIndex(child); len(match) != 0 {
+ child = child[match[2]:match[3]]
}
}
children.Add(child)
