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

Method getProjectRelease

module/publish/iml.go:145–299  ·  view source on GitHub ↗
(ctx context.Context, projectID string, commitId string)

Source from the content-addressed store, hash-verified

143}
144
145func (i *imlPublishModule) getProjectRelease(ctx context.Context, projectID string, commitId string) (*gateway.ProjectRelease, error) {
146 commits, err := i.releaseService.GetCommits(ctx, commitId)
147 if err != nil {
148 return nil, err
149 }
150 apiIds := make([]string, 0, len(commits))
151 apiProxyCommitIds := make([]string, 0, len(commits))
152 upstreamCommitIds := make([]string, 0, len(commits))
153 strategyCommitIds := make([]string, 0, len(commits))
154 for _, c := range commits {
155 switch c.Type {
156 case release.CommitApiProxy:
157 apiIds = append(apiIds, c.Target)
158 apiProxyCommitIds = append(apiProxyCommitIds, c.Commit)
159 case release.CommitUpstream:
160 upstreamCommitIds = append(upstreamCommitIds, c.Commit)
161 case release.CommitStrategy:
162 strategyCommitIds = append(strategyCommitIds, c.Commit)
163 }
164 }
165 serviceInfo, err := i.serviceService.Get(ctx, projectID)
166 if err != nil {
167 return nil, err
168 }
169
170 apiInfos, err := i.apiService.ListInfo(ctx, apiIds...)
171 if err != nil {
172 return nil, err
173 }
174
175 proxyCommits, err := i.apiService.ListProxyCommit(ctx, apiProxyCommitIds...)
176 if err != nil {
177 return nil, err
178 }
179 proxyCommitMap := utils.SliceToMapO(proxyCommits, func(c *commit.Commit[api.Proxy]) (string, *api.Proxy) {
180 return c.Target, c.Data
181 })
182
183 version := commitId
184 r := &gateway.ProjectRelease{
185 Id: projectID,
186 Version: version,
187 }
188 upstreamProxyHeaders := make([]*gateway.ProxyHeader, 0)
189 var upstreamRelease *gateway.UpstreamRelease
190 if len(upstreamCommitIds) > 0 {
191 upstreamCommits, err := i.upstreamService.ListCommit(ctx, upstreamCommitIds...)
192 if err != nil {
193 return nil, err
194 }
195 for _, c := range upstreamCommits {
196 upstreamRelease = &gateway.UpstreamRelease{
197 BasicItem: &gateway.BasicItem{
198 ID: c.Target,
199 Version: version,
200 MatchLabels: map[string]string{
201 "serviceId": projectID,
202 },

Callers 2

GetProjectReleaseMethod · 0.95
getReleaseInfoMethod · 0.95

Calls 9

GetDriverMethod · 0.80
GetCommitsMethod · 0.65
GetMethod · 0.65
ListInfoMethod · 0.65
ListProxyCommitMethod · 0.65
ListCommitMethod · 0.65
ListStrategyCommitMethod · 0.65
ToReleaseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected