(ctx context.Context, namespace, name, ref, currentUser string)
| 464 | } |
| 465 | |
| 466 | func (c *ModelComponent) SDKModelInfo(ctx context.Context, namespace, name, ref, currentUser string) (*types.SDKModelInfo, error) { |
| 467 | model, err := c.ms.FindByPath(ctx, namespace, name) |
| 468 | if err != nil { |
| 469 | return nil, fmt.Errorf("failed to find model, error: %w", err) |
| 470 | } |
| 471 | |
| 472 | allow, _ := c.AllowReadAccessRepo(ctx, model.Repository, currentUser) |
| 473 | if !allow { |
| 474 | return nil, ErrUnauthorized |
| 475 | } |
| 476 | |
| 477 | var pipelineTag, libraryTag string |
| 478 | var tags []string |
| 479 | for _, tag := range model.Repository.Tags { |
| 480 | tags = append(tags, tag.Name) |
| 481 | if tag.Category == "task" { |
| 482 | pipelineTag = tag.Name |
| 483 | } |
| 484 | if tag.Category == "framework" { |
| 485 | libraryTag = tag.Name |
| 486 | } |
| 487 | } |
| 488 | |
| 489 | filePaths, err := getFilePaths(namespace, name, "", types.ModelRepo, c.git.GetRepoFileTree) |
| 490 | if err != nil { |
| 491 | return nil, fmt.Errorf("failed to get all %s files, error: %w", types.ModelRepo, err) |
| 492 | } |
| 493 | |
| 494 | var sdkFiles []types.SDKFile |
| 495 | for _, filePath := range filePaths { |
| 496 | sdkFiles = append(sdkFiles, types.SDKFile{Filename: filePath}) |
| 497 | } |
| 498 | |
| 499 | if ref == "" { |
| 500 | ref = model.Repository.DefaultBranch |
| 501 | } |
| 502 | getLastCommitReq := gitserver.GetRepoLastCommitReq{ |
| 503 | Namespace: namespace, |
| 504 | Name: name, |
| 505 | Ref: ref, |
| 506 | RepoType: types.ModelRepo, |
| 507 | } |
| 508 | lastCommit, err := c.git.GetRepoLastCommit(ctx, getLastCommitReq) |
| 509 | if err != nil { |
| 510 | slog.Error("failed to get last commit", slog.String("namespace", namespace), slog.String("name", name), slog.String("ref", ref), slog.Any("error", err)) |
| 511 | return nil, fmt.Errorf("failed to get last commit, error: %w", err) |
| 512 | } |
| 513 | |
| 514 | relatedRepos, _ := c.relatedRepos(ctx, model.RepositoryID, currentUser) |
| 515 | relatedSpaces := relatedRepos[types.SpaceRepo] |
| 516 | spaceNames := make([]string, len(relatedSpaces)) |
| 517 | for idx, s := range relatedSpaces { |
| 518 | spaceNames[idx] = s.Name |
| 519 | } |
| 520 | |
| 521 | resModel := &types.SDKModelInfo{ |
| 522 | ID: model.Repository.Path, |
| 523 | Author: model.Repository.User.Username, |
nothing calls this directly
no test coverage detected