diff --git a/README.md b/README.md index 9324987..cb98462 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ Application Options: --list.query= Pairs of query and project UUIDs in the form: '@' [$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] @@ -52,7 +53,6 @@ Application Options: Help Options: -h, --help Show this help message - ``` Metrics diff --git a/azure-devops-client/main.go b/azure-devops-client/main.go index 44288f2..ee939c8 100644 --- a/azure-devops-client/main.go +++ b/azure-devops-client/main.go @@ -25,6 +25,7 @@ type AzureDevopsClient struct { RequestCount uint64 RequestRetries int + LimitProject int64 LimitBuildsPerProject int64 LimitBuildsPerDefinition int64 LimitReleasesPerDefinition int64 diff --git a/azure-devops-client/project.go b/azure-devops-client/project.go index f16d0a4..cdbec96 100644 --- a/azure-devops-client/project.go +++ b/azure-devops-client/project.go @@ -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) diff --git a/config/opts.go b/config/opts.go index 5229fda..7f38939 100644 --- a/config/opts.go +++ b/config/opts.go @@ -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"` diff --git a/main.go b/main.go index 4e275e8..cbc29aa 100644 --- a/main.go +++ b/main.go @@ -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