(ctx context.Context)
| 35 | } |
| 36 | |
| 37 | func (i *imlUpstreamModule) ExportAll(ctx context.Context) ([]*upstream_dto.ExportUpstream, error) { |
| 38 | latestCommits, err := i.upstreamService.ListLatestCommit(ctx, cluster.DefaultClusterID) |
| 39 | if err != nil { |
| 40 | return nil, err |
| 41 | } |
| 42 | commitMap := utils.SliceToMap(latestCommits, func(c *commit.Commit[upstream.Config]) string { |
| 43 | return c.Target |
| 44 | }) |
| 45 | list, err := i.upstreamService.List(ctx) |
| 46 | if err != nil { |
| 47 | return nil, err |
| 48 | } |
| 49 | items := make([]*upstream_dto.ExportUpstream, 0, len(list)) |
| 50 | for _, u := range list { |
| 51 | c, ok := commitMap[u.UUID] |
| 52 | if !ok { |
| 53 | continue |
| 54 | } |
| 55 | |
| 56 | items = append(items, &upstream_dto.ExportUpstream{ |
| 57 | ID: u.UUID, |
| 58 | Name: u.Name, |
| 59 | Service: u.Service, |
| 60 | Upstream: upstream_dto.FromClusterConfig(c.Data), |
| 61 | }) |
| 62 | } |
| 63 | return items, nil |
| 64 | } |
| 65 | |
| 66 | func (i *imlUpstreamModule) Get(ctx context.Context, pid string) (upstream_dto.UpstreamConfig, error) { |
| 67 | _, err := i.serviceService.Check(ctx, pid, asServer) |
nothing calls this directly
no test coverage detected