(ctx context.Context, serviceId string, baseRelease string)
| 111 | } |
| 112 | |
| 113 | func (m *imlServiceDiff) DiffForLatest(ctx context.Context, serviceId string, baseRelease string) (*service_diff.Diff, bool, error) { |
| 114 | serviceInfo, err := m.serviceService.Get(ctx, serviceId) |
| 115 | if err != nil { |
| 116 | return nil, false, fmt.Errorf("get service info failed:%w", err) |
| 117 | } |
| 118 | apis, err := m.apiService.ListForService(ctx, serviceId) |
| 119 | if err != nil { |
| 120 | return nil, false, err |
| 121 | } |
| 122 | if len(apis) < 1 { |
| 123 | return nil, false, fmt.Errorf("api not found") |
| 124 | } |
| 125 | |
| 126 | apiIds := utils.SliceToSlice(apis, func(i *api.API) string { |
| 127 | return i.UUID |
| 128 | }) |
| 129 | apiInfos, err := m.apiService.ListInfo(ctx, apiIds...) |
| 130 | if err != nil { |
| 131 | return nil, false, err |
| 132 | } |
| 133 | request := make([]*commit.Commit[api.Request], 0, len(apiInfos)) |
| 134 | for _, apiInfo := range apiInfos { |
| 135 | request = append(request, &commit.Commit[api.Request]{ |
| 136 | Target: apiInfo.UUID, |
| 137 | Key: "request", |
| 138 | Data: &api.Request{ |
| 139 | Name: apiInfo.Name, |
| 140 | Path: apiInfo.Path, |
| 141 | Methods: apiInfo.Methods, |
| 142 | Protocols: apiInfo.Protocols, |
| 143 | Match: apiInfo.Match, |
| 144 | Disable: apiInfo.Disable, |
| 145 | Upstream: apiInfo.Upstream, |
| 146 | }, |
| 147 | }) |
| 148 | |
| 149 | } |
| 150 | proxy, err := m.apiService.ListLatestCommitProxy(ctx, apiIds...) |
| 151 | if err != nil { |
| 152 | return nil, false, fmt.Errorf("diff for api commit %v", err) |
| 153 | } |
| 154 | apiDocCommits, err := m.apiDocService.ListLatestDocCommit(ctx, serviceId) |
| 155 | if err != nil { |
| 156 | return nil, false, err |
| 157 | } |
| 158 | |
| 159 | upstreamCommits, err := m.upstreamService.ListLatestCommit(ctx, cluster.DefaultClusterID, serviceId) |
| 160 | if err != nil { |
| 161 | return nil, false, err |
| 162 | } |
| 163 | if len(upstreamCommits) == 0 && serviceInfo.Kind == service.RestService { |
| 164 | return nil, false, fmt.Errorf("upstream not found") |
| 165 | } |
| 166 | |
| 167 | strategyCommits, err := m.latestStrategyCommits(ctx, serviceId) |
| 168 | if err != nil { |
| 169 | return nil, false, err |
| 170 | } |
nothing calls this directly
no test coverage detected