MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / ExportAll

Method ExportAll

module/upstream/iml.go:37–64  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

35}
36
37func (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
66func (i *imlUpstreamModule) Get(ctx context.Context, pid string) (upstream_dto.UpstreamConfig, error) {
67 _, err := i.serviceService.Check(ctx, pid, asServer)

Callers

nothing calls this directly

Calls 2

ListLatestCommitMethod · 0.65
ListMethod · 0.65

Tested by

no test coverage detected