Find all Flagship.io flags usage inside your codebase and send their usage to the Flagship platform
8.3K
Flagship Code Analyzer is a CLI and a docker image that can analyze your codebase and detect the usage of Flagship flags, in order to synchronize them with your Flag view in the platform.
export FLAGSHIP_CLIENT_ID=FLAGSHIP_MANAGEMENT_API_CLIENT_ID
export FLAGSHIP_CLIENT_SECRET=FLAGSHIP_MANAGEMENT_API_CLIENT_SECRET
export ACCOUNT_ID=FLAGSHIP_ACCOUNT_ID
export ENVIRONMENT_ID=FLAGSHIP_ENVIRONMENT_ID
export REPOSITORY_URL=https://gitlab.com/org/repo
export REPOSITORY_BRANCH=master
export DIRECTORY=./
./code-analyzer
docker run -v $(pwd)/your_repo:/your_repo -e FLAGSHIP_CLIENT_ID=FLAGSHIP_MANAGEMENT_API_CLIENT_ID -e FLAGSHIP_CLIENT_SECRET=FLAGSHIP_MANAGEMENT_API_CLIENT_SECRET -e ACCOUNT_ID=FLAGSHIP_ACCOUNT_ID -e ENVIRONMENT_ID=your_env_id -e REPOSITORY_URL=https://gitlab.com/org/repo -e REPOSITORY_BRANCH=master -e DIRECTORY=/your_repo flagshipio/code-analyzer
This environment variable contains the Flagship client id necessary to authenticate request and send flags infos to the Flagship Platform
FLAGSHIP_CLIENT_ID=FLAGSHIP_MANAGEMENT_API_CLIENT_IDThis environment variable contains the Flagship client secret necessary to authenticate request and send flags infos to the Flagship Platform
FLAGSHIP_CLIENT_SECRET=FLAGSHIP_MANAGEMENT_API_CLIENT_SECRETThis environment variable contains the Flagship account ID to synchronize flags usage for the matching environment
ACCOUNT_ID=your_flagship_env_idThis environment variable contains the Flagship environment ID to synchronize flags usage for the matching environment
ENVIRONMENT_ID=your_flagship_env_idThis environment variable should be set to the root URL of your repository, and is used to track the links of the files where your flags are used
REPOSITORY_URL=https://gitlab.com/org/repoThis environment variable should be set to the branch of the code you want to analyse, and is used to track the links of the files where your flags are used
REPOSITORY_BRANCH=masterThis environment variable should contain a comma separated list of glob to exclude
FILES_TO_EXCLUDE=".git/*,go.mod,go.sum,main.go,internal/*,example/*"This environment variable should contain the directory you want to analyse
DIRECTORY="."You can use the code analyzer to push flags references to your Flagship environment when code is pushed to a specific branch or tag
analyze_flag_references:
image: flagshipio/code-analyzer:master
stage: analyze
variables:
REPOSITORY_URL: $CI_PROJECT_URL
REPOSITORY_BRANCH: $CI_COMMIT_BRANCH
FLAGSHIP_CLIENT_ID: FLAGSHIP_MANAGEMENT_API_CLIENT_ID
FLAGSHIP_CLIENT_SECRET: FLAGSHIP_MANAGEMENT_API_CLIENT_SECRET
ACCOUNT_ID: YOUR_ACCOUNT_ID
ENVIRONMENT_ID: YOUR_ENVIRONMENT_ID
script:
- /root/code-analyser
only:
- master
This repository needs go v1.13+ to work
go mod download
go run *.go in the example folder to run the codemake test
Content type
Image
Digest
sha256:c96e62033…
Size
6.3 MB
Last updated
about 2 years ago
docker pull flagshipio/code-analyzer:v0.9.3