@@ -41,16 +41,17 @@ var (
4141 },
4242 }
4343
44- templateResourceObject , _ = template .ParseFS (templates , "resourceobject.tmpl" )
45- templateSchema , _ = template .ParseFS (templates , "schema.tmpl" )
46- templateCodec , _ = template .ParseFS (templates , "codec.tmpl" )
47- templateLineage , _ = template .ParseFS (templates , "lineage.tmpl" )
48- templateThemaCodec , _ = template .ParseFS (templates , "themacodec.tmpl" )
49- templateWrappedType , _ = template .ParseFS (templates , "wrappedtype.tmpl" )
50- templateTSType , _ = template .ParseFS (templates , "tstype.tmpl" )
51- templateConstants , _ = template .ParseFS (templates , "constants.tmpl" )
52- templateGoResourceClient , _ = template .ParseFS (templates , "resourceclient.tmpl" )
53- templateRuntimeObject , _ = template .ParseFS (templates , "runtimeobject.tmpl" )
44+ templateResourceObject , _ = template .ParseFS (templates , "resourceobject.tmpl" )
45+ templateSchema , _ = template .ParseFS (templates , "schema.tmpl" )
46+ templateCodec , _ = template .ParseFS (templates , "codec.tmpl" )
47+ templateLineage , _ = template .ParseFS (templates , "lineage.tmpl" )
48+ templateThemaCodec , _ = template .ParseFS (templates , "themacodec.tmpl" )
49+ templateWrappedType , _ = template .ParseFS (templates , "wrappedtype.tmpl" )
50+ templateTSType , _ = template .ParseFS (templates , "tstype.tmpl" )
51+ templateConstants , _ = template .ParseFS (templates , "constants.tmpl" )
52+ templateGoResourceClient , _ = template .ParseFS (templates , "resourceclient.tmpl" )
53+ templateGoVersionedRouteClient , _ = template .ParseFS (templates , "client.tmpl" )
54+ templateRuntimeObject , _ = template .ParseFS (templates , "runtimeobject.tmpl" )
5455
5556 templateBackendPluginRouter , _ = template .ParseFS (templates , "plugin/plugin.tmpl" )
5657 templateBackendPluginResourceHandler , _ = template .ParseFS (templates , "plugin/handler_resource.tmpl" )
@@ -588,19 +589,19 @@ type GoResourceClientMetadata struct {
588589 KindName string
589590 KindPrefix string
590591 Subresources []GoResourceClientSubresource
591- CustomRoutes []GoResourceClientCustomRoute
592+ CustomRoutes []GoClientCustomRoute
592593}
593594
594- type GoResourceClientCustomRoute struct {
595+ type GoClientCustomRoute struct {
595596 TypeName string
596597 Path string
597598 Method string
598599 HasParams bool
599600 HasBody bool
600- ParamValues []GoResourceClientParamValues
601+ ParamValues []GoCustomRouteParamValues
601602}
602603
603- type GoResourceClientParamValues struct {
604+ type GoCustomRouteParamValues struct {
604605 Key string
605606 FieldName string
606607}
@@ -615,17 +616,44 @@ func WriteGoResourceClient(metadata GoResourceClientMetadata, out io.Writer) err
615616 slices .SortFunc (metadata .Subresources , func (a , b GoResourceClientSubresource ) int {
616617 return strings .Compare (a .Subresource , b .Subresource )
617618 })
618- slices .SortFunc (metadata .CustomRoutes , func (a , b GoResourceClientCustomRoute ) int {
619+ slices .SortFunc (metadata .CustomRoutes , func (a , b GoClientCustomRoute ) int {
619620 return strings .Compare (fmt .Sprintf ("%s|%s" , a .Path , a .Method ), fmt .Sprintf ("%s|%s" , b .Path , b .Method ))
620621 })
621622 for i := 0 ; i < len (metadata .CustomRoutes ); i ++ {
622- slices .SortFunc (metadata .CustomRoutes [i ].ParamValues , func (a GoResourceClientParamValues , b GoResourceClientParamValues ) int {
623+ slices .SortFunc (metadata .CustomRoutes [i ].ParamValues , func (a GoCustomRouteParamValues , b GoCustomRouteParamValues ) int {
623624 return strings .Compare (a .FieldName , b .FieldName )
624625 })
625626 }
626627 return templateGoResourceClient .Execute (out , metadata )
627628}
628629
630+ type GoGroupVersionClientMetadata struct {
631+ PackageName string
632+ ClientName string
633+ NamespacedRoutes []GoClientCustomRoute
634+ ClusterRoutes []GoClientCustomRoute
635+ }
636+
637+ func WriteGroupVersionClient (metadata GoGroupVersionClientMetadata , out io.Writer ) error {
638+ slices .SortFunc (metadata .NamespacedRoutes , func (a , b GoClientCustomRoute ) int {
639+ return strings .Compare (fmt .Sprintf ("%s|%s" , a .Path , a .Method ), fmt .Sprintf ("%s|%s" , b .Path , b .Method ))
640+ })
641+ slices .SortFunc (metadata .ClusterRoutes , func (a , b GoClientCustomRoute ) int {
642+ return strings .Compare (fmt .Sprintf ("%s|%s" , a .Path , a .Method ), fmt .Sprintf ("%s|%s" , b .Path , b .Method ))
643+ })
644+ for i := 0 ; i < len (metadata .NamespacedRoutes ); i ++ {
645+ slices .SortFunc (metadata .NamespacedRoutes [i ].ParamValues , func (a GoCustomRouteParamValues , b GoCustomRouteParamValues ) int {
646+ return strings .Compare (a .FieldName , b .FieldName )
647+ })
648+ }
649+ for i := 0 ; i < len (metadata .ClusterRoutes ); i ++ {
650+ slices .SortFunc (metadata .ClusterRoutes [i ].ParamValues , func (a GoCustomRouteParamValues , b GoCustomRouteParamValues ) int {
651+ return strings .Compare (a .FieldName , b .FieldName )
652+ })
653+ }
654+ return templateGoVersionedRouteClient .Execute (out , metadata )
655+ }
656+
629657type RuntimeObjectWrapperMetadata struct {
630658 PackageName string
631659 WrapperTypeName string
0 commit comments