(ctx context.Context, metadataURL string, useInternal bool)
| 204 | } |
| 205 | |
| 206 | func getTools(ctx context.Context, metadataURL string, useInternal bool) ([]commonParams.RunnerApplicationDownload, error) { |
| 207 | if metadataURL == "" { |
| 208 | metadataURL = appdefaults.GiteaRunnerReleasesURL |
| 209 | } |
| 210 | var latest GiteaEntityTool |
| 211 | var err error |
| 212 | if useInternal { |
| 213 | latest = nightlyGiteaRunner |
| 214 | } else { |
| 215 | latest, err = getReleasesFromURL(ctx, metadataURL) |
| 216 | if err != nil { |
| 217 | slog.ErrorContext(ctx, "failed to get tools from metadata URL", "error", err) |
| 218 | return nil, fmt.Errorf("failed to get tools: %w", err) |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | ret := []commonParams.RunnerApplicationDownload{} |
| 223 | |
| 224 | for _, asset := range latest.Assets { |
| 225 | arch, err := asset.GetArch() |
| 226 | if err != nil { |
| 227 | slog.InfoContext(ctx, "ignoring unrecognized tools arch", "tool", asset.Name) |
| 228 | continue |
| 229 | } |
| 230 | os, err := asset.GetOS() |
| 231 | if err != nil { |
| 232 | slog.InfoContext(ctx, "ignoring unrecognized tools os", "tool", asset.Name) |
| 233 | continue |
| 234 | } |
| 235 | if strings.HasSuffix(asset.DownloadURL, ".xz") || strings.HasSuffix(asset.DownloadURL, ".sha256") { |
| 236 | // filter out compressed files and sha256 sums. Windows does not have any way to uncompress |
| 237 | // .xz by default. |
| 238 | continue |
| 239 | } |
| 240 | slog.DebugContext(ctx, "found valid tools", "download_url", asset.DownloadURL, "os", os, "arch", arch, "file_name", asset.Name) |
| 241 | ret = append(ret, commonParams.RunnerApplicationDownload{ |
| 242 | OS: os, |
| 243 | Architecture: arch, |
| 244 | DownloadURL: &asset.DownloadURL, |
| 245 | Filename: &asset.Name, |
| 246 | }) |
| 247 | } |
| 248 | |
| 249 | return ret, nil |
| 250 | } |
no test coverage detected