@@ -17,8 +17,14 @@ var pluginsFS embed.FS
1717
1818// binary represents a binary executable provided by the runtime
1919type binary struct {
20- Name string `yaml:"name"`
21- Path string `yaml:"path"`
20+ Name string `yaml:"name"`
21+ Path interface {} `yaml:"path"` // Can be either string or map[string]string
22+ }
23+
24+ // binaryPath represents OS-specific paths for a binary
25+ type binaryPath struct {
26+ Darwin string `yaml:"darwin"`
27+ Linux string `yaml:"linux"`
2228}
2329
2430// pluginConfig holds the structure of the plugin.yaml file
@@ -48,6 +54,7 @@ type extensionConfig struct {
4854// templateData holds the data to be used in template substitution
4955type templateData struct {
5056 Version string
57+ MajorVersion string
5158 FileName string
5259 OS string
5360 Arch string
@@ -118,14 +125,31 @@ func processRuntime(config RuntimeConfig, runtimesDir string) (*RuntimeInfo, err
118125
119126 // Process binary paths
120127 for _ , binary := range plugin .Config .Binaries {
121- binaryPath := path .Join (installDir , binary .Path )
128+ var binaryPath string
129+
130+ switch path := binary .Path .(type ) {
131+ case string :
132+ // If path is a simple string, use it directly
133+ binaryPath = path
134+ case map [string ]interface {}:
135+ // If path is a map, get the OS-specific path
136+ if osPath , ok := path [runtime .GOOS ]; ok {
137+ binaryPath = osPath .(string )
138+ } else {
139+ return nil , fmt .Errorf ("no binary path specified for OS %s" , runtime .GOOS )
140+ }
141+ default :
142+ return nil , fmt .Errorf ("invalid path format for binary %s" , binary .Name )
143+ }
144+
145+ fullPath := path .Join (installDir , binaryPath )
122146
123147 // Add file extension for Windows executables
124- if runtime .GOOS == "windows" && ! strings .HasSuffix (binaryPath , ".exe" ) {
125- binaryPath += ".exe"
148+ if runtime .GOOS == "windows" && ! strings .HasSuffix (fullPath , ".exe" ) {
149+ fullPath += ".exe"
126150 }
127151
128- info .Binaries [binary .Name ] = binaryPath
152+ info .Binaries [binary .Name ] = fullPath
129153 }
130154
131155 return info , nil
@@ -172,6 +196,14 @@ func (p *runtimePlugin) getExtension(goos string) string {
172196 return p .Config .Download .Extension .Default
173197}
174198
199+ // getMajorVersion extracts the major version from a version string (e.g. "17.0.10" -> "17")
200+ func (p * runtimePlugin ) getMajorVersion (version string ) string {
201+ if idx := strings .Index (version , "." ); idx != - 1 {
202+ return version [:idx ]
203+ }
204+ return version
205+ }
206+
175207// GetFileName generates the filename based on the template in plugin.yaml
176208func (p * runtimePlugin ) getFileName (version string ) string {
177209 goos := runtime .GOOS
@@ -185,6 +217,7 @@ func (p *runtimePlugin) getFileName(version string) string {
185217 // Prepare template data
186218 data := templateData {
187219 Version : version ,
220+ MajorVersion : p .getMajorVersion (version ),
188221 OS : mappedOS ,
189222 Arch : mappedArch ,
190223 ReleaseVersion : releaseVersion ,
@@ -230,6 +263,7 @@ func (p *runtimePlugin) getDownloadURL(version string) string {
230263 // Prepare template data
231264 data := templateData {
232265 Version : version ,
266+ MajorVersion : p .getMajorVersion (version ),
233267 FileName : fileName ,
234268 OS : mappedOS ,
235269 Arch : mappedArch ,
0 commit comments