Files
coder/scripts/check_enterprise_imports.sh
T
Cian Johnston 26740cf00d chore(scripts/rules.go): broaden scope of testingWithOwnerUser linter (#10548)
* Updated testingWithOwnerUser ruleguard rule to detect:
  a) Passing client from coderdenttest.New() to clitest.SetupConfig() similar to what already exists for AGPL code
  b) Usage of any method of the owner client from coderdenttest.New() - all usages of the owner client must be justified with a `//nolint:gocritic` comment.
* Fixed resulting linter complaints.
* Added new coderdtest helpers CreateGroup and UpdateTemplateMeta.
* Modified check_enterprise_import.sh to ignore scripts/rules.go.
2023-11-08 14:54:48 +00:00

25 lines
711 B
Bash
Executable File

#!/usr/bin/env bash
# This file checks all our AGPL licensed source files to be sure they don't
# import any enterprise licensed packages (the inverse is fine).
set -euo pipefail
# shellcheck source=scripts/lib.sh
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
cdroot
set +e
find . -regex ".*\.go" |
grep -v "./enterprise" |
grep -v ./scripts/auditdocgen/ --include="*.go" |
grep -v ./scripts/clidocgen/ --include="*.go" |
grep -v ./scripts/rules.go |
xargs grep -n "github.com/coder/coder/v2/enterprise"
# reverse the exit code because we want this script to fail if grep finds anything.
status=$?
set -e
if [ $status -eq 0 ]; then
error "AGPL code cannot import enterprise!"
fi
log "AGPL imports OK"