Skip to content

Commit

Permalink
configurable project limit
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Blaschke <[email protected]>
  • Loading branch information
mblaschke committed Aug 23, 2020
1 parent 10e9d35 commit 48329c9
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Application Options:
--list.query= Pairs of query and project UUIDs in the form: '<queryId>@<projectId>' [$AZURE_DEVOPS_QUERIES]
--request.concurrency= Number of concurrent requests against dev.azure.com (default: 10) [$REQUEST_CONCURRENCY]
--request.retries= Number of retried requests against dev.azure.com (default: 3) [$REQUEST_RETRIES]
--limit.project= Limit number of projects (default: 100) [$LIMIT_PROJECT]
--limit.builds-per-project= Limit builds per project (default: 100) [$LIMIT_BUILDS_PER_PROJECT]
--limit.builds-per-definition= Limit builds per definition (default: 10) [$LIMIT_BUILDS_PER_DEFINITION]
--limit.releases-per-project= Limit releases per project (default: 100) [$LIMIT_RELEASES_PER_PROJECT]
Expand All @@ -52,7 +53,6 @@ Application Options:
Help Options:
-h, --help Show this help message
```

Metrics
Expand Down
1 change: 1 addition & 0 deletions azure-devops-client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type AzureDevopsClient struct {
RequestCount uint64
RequestRetries int

LimitProject int64
LimitBuildsPerProject int64
LimitBuildsPerDefinition int64
LimitReleasesPerDefinition int64
Expand Down
3 changes: 2 additions & 1 deletion azure-devops-client/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ func (c *AzureDevopsClient) ListProjects() (list ProjectList, error error) {
c.concurrencyLock()

url := fmt.Sprintf(
"_apis/projects?$top=300&api-version=%v",
"_apis/projects?$top=%v&api-version=%v",
c.LimitProject,
url.QueryEscape(c.ApiVersion),
)
response, err := c.rest().R().Get(url)
Expand Down
1 change: 1 addition & 0 deletions config/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type (
}

Limit struct {
Project int64 `long:"limit.project" env:"LIMIT_PROJECT" description:"Limit number of projects" default:"100"`
BuildsPerProject int64 `long:"limit.builds-per-project" env:"LIMIT_BUILDS_PER_PROJECT" description:"Limit builds per project" default:"100"`
BuildsPerDefinition int64 `long:"limit.builds-per-definition" env:"LIMIT_BUILDS_PER_DEFINITION" description:"Limit builds per definition" default:"10"`
ReleasesPerProject int64 `long:"limit.releases-per-project" env:"LIMIT_RELEASES_PER_PROJECT" description:"Limit releases per project" default:"100"`
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ func initAzureDevOpsConnection() {
AzureDevopsClient.SetRetries(opts.Request.Retries)
AzureDevopsClient.SetUserAgent(fmt.Sprintf("azure-devops-exporter/%v", gitTag))

AzureDevopsClient.LimitProject = opts.Limit.Project
AzureDevopsClient.LimitBuildsPerProject = opts.Limit.BuildsPerProject
AzureDevopsClient.LimitBuildsPerDefinition = opts.Limit.BuildsPerDefinition
AzureDevopsClient.LimitReleasesPerDefinition = opts.Limit.ReleasesPerDefinition
Expand Down

0 comments on commit 48329c9

Please sign in to comment.