You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow running code references in a specific subdirectory (#471)
This PR adds a new configuration option for specifying a location of the
`.launchdarkly/coderefs.yaml` config file if it's not located in the
root. This allows a monorepo to specify multiple config files, and will
require individual invocation:
```
ld-find-code-refs \
--accessToken=<TOKEN> \
--repoName=<REPO_NAME> \
--dir="<LOCAL_DIR>" \
--subdirectory="path/to/subdirectory" \
--projKey="<PROJ_KEY>"
```
Copy file name to clipboardExpand all lines: build/metadata/github-actions/README.md
+14-13Lines changed: 14 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -83,19 +83,20 @@ Once your workflow has been created, the best way to confirm that the workflow i
83
83
84
84
If the action fails, there may be a problem with your configuration. To investigate, dig into the action's logs to view any error messages.
85
85
86
-
<!-- action-docs-inputs -->
86
+
<!-- action-docs-inputs source="action.yml" -->
87
87
## Inputs
88
88
89
-
| parameter | description | required | default |
89
+
| name | description | required | default |
90
90
| --- | --- | --- | --- |
91
-
| accessToken | A token with write access to the LaunchDarkly project. | `true` | |
92
-
| allowTags | Enable storing references for tags. Lists the tag as a branch. | `false` | false |
93
-
| baseUri | The base URL of the LaunchDarkly server for this configuration. | `false` | https://app.launchdarkly.com |
94
-
| contextLines | The number of context lines above and below a code reference for the job to send to LaunchDarkly. By default, the flag finder will not send any context lines to LaunchDarkly. If < 0, it will send no source code to LaunchDarkly. If 0, it will send only the lines containing flag references. If > 0, it will send that number of context lines above and below the flag reference. You may provide a maximum of 5 context lines. | `false` | 2 |
| ignoreServiceErrors | If enabled, the scanner will terminate with exit code 0 when the LaunchDarkly API is unreachable or returns an unexpected response. | `false` | false |
97
-
| lookback | Set the number of commits to search in history for whether you removed a feature flag from code. You may set to 0 to disable this feature. Setting this option to a high value will increase search time. | `false` | 10 |
98
-
| projKey | Key of the LaunchDarkly project associated with this repository. Found under Account Settings -> Projects in the LaunchDarkly dashboard. Cannot be combined with `projects` block in configuration file. | `false` | |
99
-
| repoName | The repository name. Defaults to the current GitHub repository. | `false` | |
100
-
| prune | There is a known issue where the GitHub Action will not prune deleted branch data in private repos. Only enable this if you are running the action in a public repo. | `false` | false |
101
-
<!-- action-docs-inputs -->
91
+
| `accessToken` | <p>A token with write access to the LaunchDarkly project.</p> | `true` | `""` |
92
+
| `allowTags` | <p>Enable storing references for tags. Lists the tag as a branch.</p> | `false` | `false` |
93
+
| `baseUri` | <p>The base URL of the LaunchDarkly server for this configuration.</p> | `false` | `https://app.launchdarkly.com` |
94
+
| `contextLines` | <p>The number of context lines above and below a code reference for the job to send to LaunchDarkly. By default, the flag finder will not send any context lines to LaunchDarkly. If < 0, it will send no source code to LaunchDarkly. If 0, it will send only the lines containing flag references. If > 0, it will send that number of context lines above and below the flag reference. You may provide a maximum of 5 context lines.</p> | `false` | `2` |
| `ignoreServiceErrors` | <p>If enabled, the scanner will terminate with exit code 0 when the LaunchDarkly API is unreachable or returns an unexpected response.</p> | `false` | `false` |
97
+
| `lookback` | <p>Set the number of commits to search in history for whether you removed a feature flag from code. You may set to 0 to disable this feature. Setting this option to a high value will increase search time.</p> | `false` | `10` |
98
+
| `projKey` | <p>Key of the LaunchDarkly project associated with this repository. Found under Account Settings -> Projects in the LaunchDarkly dashboard. Cannot be combined with <code>projects</code> block in configuration file.</p> | `false` | `""` |
99
+
| `repoName` | <p>The repository name. Defaults to the current GitHub repository.</p> | `false` | `""` |
100
+
| `prune` | <p>There is a known issue where the GitHub Action will not prune deleted branch data in private repos. Only enable this if you are running the action in a public repo.</p> | `false` | `false` |
101
+
| `subdirectory` | <p>The subdirectory to run the action in.</p> | `false` | `""` |
Copy file name to clipboardExpand all lines: build/metadata/github-actions/action.yml
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,9 @@ inputs:
42
42
default: "false"
43
43
description: "There is a known issue where the GitHub Action will not prune deleted branch data in private repos. Only enable this if you are running the action in a public repo."
44
44
required: false
45
+
subdirectory:
46
+
description: "The subdirectory to run the action in."
Copy file name to clipboardExpand all lines: docs/CONFIGURATION.md
+9-3Lines changed: 9 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,21 +29,24 @@ ld-find-code-refs [flags]
29
29
30
30
Flags:
31
31
```
32
-
-t, --accessToken string LaunchDarkly personal access token with write-level access.
32
+
-t, --accessToken string LaunchDarkly personal access token with write-level access.
33
33
34
34
--allowTags Enables storing references for tags. The tag will be listed as a branch.
35
35
36
36
-U, --baseUri string LaunchDarkly base URI. (default "https://app.launchdarkly.com")
37
37
38
38
-b, --branch string The currently checked out branch. If not provided, branch name will be auto-detected. Provide this option when using CI systems that leave the repository in a detached HEAD state.
39
+
39
40
--commitUrlTemplate string If provided, LaunchDarkly will attempt to generate links to your VCS service provider per commit. Example: https://github.com/launchdarkly/ld-find-code-refs/commit/${sha}. Allowed template variables: 'branchName', 'sha'. If "commitUrlTemplate" is not provided, but "repoUrl" is provided and "repoType" is not custom, LaunchDarkly will attempt to automatically generate source code links for the given "repoType".
41
+
40
42
-C, --contextLines int The number of context lines to send to LaunchDarkly. If < 0, no source code will be sent to LaunchDarkly. If 0, only the lines containing flag references will be sent. If > 0, will send that number of context lines above and below the flag reference. A maximum of 5 context lines may be provided. (default 2)
41
43
42
44
--debug Enables verbose debug logging
43
45
44
46
-B, --defaultBranch string The default branch. The LaunchDarkly UI will default to this branch. If not provided, will fallback to 'main'. (default "main")
45
47
46
48
-d, --dir string Path to existing checkout of the repository.
49
+
47
50
--dryRun If enabled, the scanner will run without sending code references to LaunchDarkly. Combine with the outDir option to output code references to a CSV.
48
51
49
52
-h, --help help for ld-find-code-refs
@@ -63,15 +66,18 @@ Flags:
63
66
-r, --repoName string Repository name. Will be displayed in LaunchDarkly. Case insensitive. Repository names must only contain letters, numbers, '.', '_' or '-'."
64
67
65
68
-T, --repoType string The repo service provider. Used to correctly categorize repositories in the LaunchDarkly UI. Acceptable values: bitbucket|custom|github|gitlab. (default "custom")
66
-
69
+
67
70
-u, --repoUrl string The URL for the repository. If provided and "repoType" is not custom, LaunchDarkly will attempt to automatically generate source code links for the given "repoType".
68
71
69
72
-R, --revision string Use this option to scan non-git codebases. The current revision of the repository to be scanned. If set, the version string for the scanned repository will not be inferred, and branch garbage collection will be disabled. The "branch" option is required when "revision" is set.
70
73
74
+
--subdirectory string If the .launchdarkly/coderefs.yaml file is not in the root of the repository, provide the path to the configuration file relative to the root.
75
+
Code references will only run on this provided subdirectory.
76
+
71
77
-s, --updateSequenceId int An integer representing the order number of code reference updates. Used to version updates across concurrent executions of the flag finder. If not provided, data will always be updated. If provided, data will only be updated if the existing "updateSequenceId" is less than the new "updateSequenceId". Examples: the time a "git push" was initiated, CI build number, the current unix timestamp. (default -1)
72
78
73
79
--userAgent string (Internal) Platform where code references is run.
usage: `Use this option to scan non-git codebases. The current revision of the repository to be scanned. If set, the version string for the scanned repository will not be inferred, and branch garbage collection will be disabled. The "branch" option is required when "revision" is set.`,
144
144
},
145
+
{
146
+
name: "subdirectory",
147
+
defaultValue: "",
148
+
usage: `If the .launchdarkly/coderefs.yaml file is not in the root of
149
+
the repository, provide the path to the subdirectory containing the configuration,
150
+
relative to the root. Code references will only run on this provided subdirectory.
151
+
This allows a monorepo to have multiple configuration files, one per subdirectory.`,
0 commit comments