A shareable package of CircleCI configuration to integrate with scan-repository, written by configcat
PartnerCode AnalysisDeploymentUse CircleCI version 2.1 at the top of your .circleci/config.yml file.
1
version: 2.1Add the orbs stanza below your version, invoking the orb:
1
2
orbs:
scan-repository: configcat/scan-repository@1.11.1Use scan-repository elements in your existing workflows and jobs.
Opt-in to use of uncertified orbs on your organization’s Security settings page.
Executes the scan job with custom parameters.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
version: '2.1'
orbs:
configcat: configcat/scan-repository@1.11.1
workflows:
main:
jobs:
- configcat/scan:
alias-patterns: (\w+) = :CC_KEY,const (\w+) = feature_flags\.enabled\(:CC_KEY\)
commit-url-template: https://github.com/my/repo/commit/{commitHash}
config-id: PASTE-YOUR-CONFIG-ID-HERE
exclude-keys: |
flag_key_to_exclue_1 flag_key_to_exclue_2
file-url-template: >-
https://github.com/my/repo/blob/{commitHash}/{filePath}#L{lineNumber}
line-count: 3
sub-folder: src
timeout: 2000
usage-patterns: feature_flags\.enabled\(:CC_KEY\)
verbose: true
Executes the scan job with default parameters.
1
2
3
4
5
6
7
8
version: '2.1'
orbs:
configcat: configcat/scan-repository@1.11.1
workflows:
main:
jobs:
- configcat/scan:
config-id: PASTE-YOUR-CONFIG-ID-HERE
Find code references to ConfigCat feature flags or settings in your source code.
| PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
|---|---|---|---|---|
alias-patterns Comma delimited list of custom regex patterns used to search for additional aliases. | Comma delimited list of custom regex patterns used to search for additional aliases. | No | '' type: string | string |
api-host ConfigCat Management API host. | ConfigCat Management API host. | No | api.configcat.com type: string | string |
api-pass ConfigCat Management API basic authentication password. | ConfigCat Management API basic authentication password. | No | CONFIGCAT_API_PASS type: env_var_name | env_var_name |
api-user ConfigCat Management API basic authentication username. | ConfigCat Management API basic authentication username. | No | CONFIGCAT_API_USER type: env_var_name | env_var_name |
commit-url-template Template url used to generate VCS commit links. Available template parameters: commitHash. Example: https://github.com/my/repo/commit/{commitHash} | Template url used to generate VCS commit links. Available template parameters: commitHash. Example: https://github.com/my/repo/commit/{commitHash} | No | '' type: string | string |
config-id ID of the ConfigCat config to scan against. Required | ID of the ConfigCat config to scan against. | Yes | - type: string | string |
exclude-keys List of feature flag keys that must be excluded from the scan report. | List of feature flag keys that must be excluded from the scan report. | No | '' type: string | string |
file-url-template Template url used to generate VCS file links. Available template parameters: commitHash, filePath, lineNumber. Example: https://github.com/my/repo/blob/{commitHash}/{filePath}#L{lineNumber} | Template url used to generate VCS file links. Available template parameters: commitHash, filePath, lineNumber. Example: https://github.com/my/repo/blob/{commitHash}/{filePath}#L{lineNumber} | No | '' type: string | string |
line-count Context line count before and after the reference line (min: 1, max: 10) | Context line count before and after the reference line (min: 1, max: 10) | No | 4 type: integer | integer |
sub-folder Sub-folder to scan, relative to the repository root folder. | Sub-folder to scan, relative to the repository root folder. | No | '' type: string | string |
timeout Scan timeout in seconds (default: 1800, min: 60) | Scan timeout in seconds (default: 1800, min: 60) | No | 1800 type: integer | integer |
usage-patterns Comma delimited list of custom regex patterns that describe additional feature flag key usages. | Comma delimited list of custom regex patterns that describe additional feature flag key usages. | No | '' type: string | string |
verbose Turns on detailed logging. | Turns on detailed logging. | No | false type: boolean | boolean |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# This code is licensed from CircleCI to the user under the MIT license.
# See here for details: https://circleci.com/developer/orbs/licensing
version: 2.1
description: |
This Orb's responsibility is to discover ConfigCat feature flag usages in your source code and to upload them to ConfigCat.
display:
home_url: https://configcat.com
source_url: https://github.com/configcat/scan-repository-orb
jobs:
scan:
description: |
Find code references to ConfigCat feature flags or settings in your source code.
docker:
- image: configcat/cli:2.4.2
parameters:
alias-patterns:
default: ""
description: Comma delimited list of custom regex patterns used to search for additional aliases.
type: string
api-host:
default: api.configcat.com
description: ConfigCat Management API host.
type: string
api-pass:
default: CONFIGCAT_API_PASS
description: ConfigCat Management API basic authentication password.
type: env_var_name
api-user:
default: CONFIGCAT_API_USER
description: ConfigCat Management API basic authentication username.
type: env_var_name
commit-url-template:
default: ""
description: 'Template url used to generate VCS commit links. Available template parameters: commitHash. Example: https://github.com/my/repo/commit/{commitHash}'
type: string
config-id:
description: ID of the ConfigCat config to scan against.
type: string
exclude-keys:
default: ""
description: List of feature flag keys that must be excluded from the scan report.
type: string
file-url-template:
default: ""
description: 'Template url used to generate VCS file links. Available template parameters: commitHash, filePath, lineNumber. Example: https://github.com/my/repo/blob/{commitHash}/{filePath}#L{lineNumber}'
type: string
line-count:
default: 4
description: 'Context line count before and after the reference line (min: 1, max: 10)'
type: integer
sub-folder:
default: ""
description: Sub-folder to scan, relative to the repository root folder.
type: string
timeout:
default: 1800
description: 'Scan timeout in seconds (default: 1800, min: 60)'
type: integer
usage-patterns:
default: ""
description: Comma delimited list of custom regex patterns that describe additional feature flag key usages.
type: string
verbose:
default: false
description: Turns on detailed logging.
type: boolean
steps:
- checkout:
path: /repo
- run:
command: |
apk add openssh-client
if [[ -z "${<< parameters.api-user >>}" ]]; then
echo "Please, set the environment variable: '<< parameters.api-user >>'. Will stop now."
exit 1
fi
if [[ -z "${<< parameters.api-pass >>}" ]]; then
echo "Please, set the environment variable: '<< parameters.api-pass >>'. Will stop now."
exit 1
fi
EXCLUDE_KEYS="' '"
[ ! -z "${SCAN_EXCLUDE_KEYS}" ] && EXCLUDE_KEYS=${SCAN_EXCLUDE_KEYS}
configcat scan "/repo/<< parameters.sub-folder >>" \
--config-id=<< parameters.config-id >> \
--repo=${CIRCLE_PROJECT_REPONAME} \
--line-count=<< parameters.line-count >> \
--timeout=<< parameters.timeout >> \
--file-url-template="<< parameters.file-url-template >>" \
--commit-url-template="<< parameters.commit-url-template >>" \
--runner="ConfigCat CircleCI Orb v1.11.0" \
--upload \
--verbose=<< parameters.verbose >> \
--non-interactive \
--exclude-flag-keys ${EXCLUDE_KEYS}
environment:
CONFIGCAT_ALIAS_PATTERNS: << parameters.alias-patterns >>
CONFIGCAT_API_HOST: << parameters.api-host >>
CONFIGCAT_USAGE_PATTERNS: << parameters.usage-patterns >>
SCAN_EXCLUDE_KEYS: << parameters.exclude-keys >>
name: Scanning repository for references
examples:
complex:
description: |
Executes the scan job with custom parameters.
usage:
version: "2.1"
orbs:
configcat: configcat/scan-repository@1.11.1
workflows:
main:
jobs:
- configcat/scan:
alias-patterns: (\w+) = :CC_KEY,const (\w+) = feature_flags\.enabled\(:CC_KEY\)
commit-url-template: https://github.com/my/repo/commit/{commitHash}
config-id: PASTE-YOUR-CONFIG-ID-HERE
exclude-keys: |
flag_key_to_exclue_1 flag_key_to_exclue_2
file-url-template: https://github.com/my/repo/blob/{commitHash}/{filePath}#L{lineNumber}
line-count: 3
sub-folder: src
timeout: 2000
usage-patterns: feature_flags\.enabled\(:CC_KEY\)
verbose: true
simple:
description: |
Executes the scan job with default parameters.
usage:
version: "2.1"
orbs:
configcat: configcat/scan-repository@1.11.1
workflows:
main:
jobs:
- configcat/scan:
config-id: PASTE-YOUR-CONFIG-ID-HERE