func()

in cmd/tc-collector/artifactDownloader.go [34:64]


func (t *Collector) findAndDownloadStartUpReports(ctx context.Context, build Build, artifacts []Artifact, result *[]ArtifactItem) error {
	for _, artifact := range artifacts {
		name := path.Base(artifact.Url)
		if strings.HasSuffix(artifact.Url, ".json") && strings.HasPrefix(name, "startup-stats") ||
			strings.HasSuffix(name, ".performance.json") ||
			strings.HasSuffix(artifact.Url, ".json") && (strings.Contains(artifact.Url, "metrics") && name != "action.invoked.json" && name != "spans.json" && name != "fleet_backend.json") ||
			strings.HasSuffix(name, "-ijperf.json") ||
			t.config.DbName == "jbr" && strings.HasSuffix(name, ".txt") ||
			t.config.DbName == "qodana" && (name == "open-telemetry.json" || name == "metrics.json") {
			artifactUrlString := t.serverUrl + strings.Replace(strings.TrimPrefix(artifact.Url, "/app/rest"), "/artifacts/metadata/", "/artifacts/content/", 1)
			report, err := t.downloadStartUpReportWithRetries(ctx, build, artifactUrlString)
			if err != nil {
				t.logger.Error("Failed to download artifact, skipping", "buildTypeId", build.Type, "buildId", build.Id, "artifact", artifactUrlString, "error", err)
				continue
			}

			*result = append(*result, ArtifactItem{
				data: report,
				path: artifactUrlString,
			})
			continue
		}

		err := t.findAndDownloadStartUpReports(ctx, build, artifact.Children.File, result)
		if err != nil {
			return err
		}
	}

	return nil
}