Skip to content

Commit e01c946

Browse files
cbat98Charlie B
andauthored
Add Continuation Token Support For Releases (#113)
* Added temp list for response values * Generate continuation token url from header value * Cycle through continuation tokens until none received * Add counter variable to metric * Unmarshal into first time round * Tidy up * Remove counter * Remove list len print cmd * Removed extra length output * Fixed casing on Dockerfile `as` statements --------- Co-authored-by: Charlie B <[email protected]>
1 parent 00197b2 commit e01c946

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#############################################
22
# Build
33
#############################################
4-
FROM --platform=$BUILDPLATFORM golang:1.23-alpine as build
4+
FROM --platform=$BUILDPLATFORM golang:1.23-alpine AS build
55

66
RUN apk upgrade --no-cache --force
77
RUN apk add --update build-base make git
@@ -21,7 +21,7 @@ RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build
2121
#############################################
2222
# Test
2323
#############################################
24-
FROM gcr.io/distroless/static as test
24+
FROM gcr.io/distroless/static AS test
2525
USER 0:0
2626
WORKDIR /app
2727
COPY --from=build /go/src/github.com/webdevops/azure-devops-exporter/azure-devops-exporter .
@@ -30,7 +30,7 @@ RUN ["./azure-devops-exporter", "--help"]
3030
#############################################
3131
# Final-static
3232
#############################################
33-
FROM gcr.io/distroless/static as final-static
33+
FROM gcr.io/distroless/static AS final-static
3434
ENV LOG_JSON=1
3535
WORKDIR /
3636
COPY --from=test /app .

azure-devops-client/release.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ func (c *AzureDevopsClient) ListReleaseHistory(project string, minTime time.Time
185185
url.QueryEscape(minTime.Format(time.RFC3339)),
186186
url.QueryEscape(int64ToString(c.LimitReleasesPerProject)),
187187
)
188+
188189
response, err := c.restVsrm().R().Get(url)
189190
if err := c.checkResponse(response, err); err != nil {
190191
error = err
@@ -197,5 +198,33 @@ func (c *AzureDevopsClient) ListReleaseHistory(project string, minTime time.Time
197198
return
198199
}
199200

201+
continuationToken := response.Header().Get("x-ms-continuationtoken")
202+
203+
for continuationToken != "" {
204+
continuationUrl := fmt.Sprintf(
205+
"%v&continuationToken=%v",
206+
url,
207+
continuationToken,
208+
)
209+
210+
response, err = c.restVsrm().R().Get(continuationUrl)
211+
if err := c.checkResponse(response, err); err != nil {
212+
error = err
213+
return
214+
}
215+
216+
var tmpList ReleaseList
217+
err = json.Unmarshal(response.Body(), &tmpList)
218+
if err != nil {
219+
error = err
220+
return
221+
}
222+
223+
list.Count += tmpList.Count
224+
list.List = append(list.List, tmpList.List...)
225+
226+
continuationToken = response.Header().Get("x-ms-continuationtoken")
227+
}
228+
200229
return
201230
}

0 commit comments

Comments
 (0)