Skip to content

Add support for programmatically excluding repos via external service config

Warren Gifford requested to merge sg/extsvc into master

Created by: slimsag

This PR adds support for querying repositories by name (e.g. /secretrepos/) and passing that list of repositories into a command that adds them to the exclude list in the external service configuration.

For example, it is possible to write this script now to add all repositories with /secretrepos/ in their name to the exclusion list of all external services:

# Determine which repositories we will exclude.
repos_to_exclude=$(src -config=./src-config.json repos list -first="-1" -names-without-host -query="/secretrepos/")

# Determine which external service configurations we need to update.
extsvcs=$(src -config=./src-config.json extsvc list -f '{{range .Nodes}}{{.id}} {{end}}')

# edit the configuration to exclude the repositories
echo "$extsvcs" | xargs -n1 -I {} src -config=./src-config.json extsvc edit -id '{}' -exclude-repos "$repos_to_exclude"

Previously we maintained backwards compatibility for setRepositoryEnablement in the GraphQL API which was used for this purpose, but because it resulted in updating the config once per repository it became VERY slow (unusable slow). This approach is much faster as you can add thousands at once instead of individually.

For https://app.hubspot.com/contacts/2762526/company/407948923

Merge request reports

Loading