Skip to content

Commit ab98f52

Browse files
authored
feat: add UI config for setting exhort backend url (#852)
1 parent 7dcc145 commit ab98f52

File tree

7 files changed

+16
-0
lines changed

7 files changed

+16
-0
lines changed

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@
188188
"markdownDescription": "Enable usage data and errors to be sent to Red Hat servers. Read our [privacy statement](https://developers.redhat.com/article/tool-data-collection).",
189189
"scope": "window"
190190
},
191+
"redHatDependencyAnalytics.backendUrl": {
192+
"type": "string",
193+
"default": "https://rhda.rhcloud.com",
194+
"markdownDescription": "Exhort backend URL to use for stack, component & image analysis.",
195+
"scope": "window"
196+
},
191197
"redHatDependencyAnalytics.matchManifestVersions": {
192198
"type": "boolean",
193199
"default": true,

src/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Minimatch } from 'minimatch';
1212
*/
1313
class Config {
1414
telemetryId: string | undefined;
15+
backendUrl: string | undefined;
1516
stackAnalysisCommand!: string;
1617
trackRecommendationAcceptanceCommand!: string;
1718
recommendationsEnabled!: boolean;
@@ -47,6 +48,7 @@ class Config {
4748
exhortImagePlatform!: string;
4849
excludePatterns!: Minimatch[];
4950

51+
private readonly DEFAULT_BACKEND_URL = 'https://rhda.rhcloud.com';
5052
private readonly DEFAULT_MVN_EXECUTABLE = 'mvn';
5153
private readonly DEFAULT_GRADLE_EXECUTABLE = 'gradle';
5254
private readonly DEFAULT_NPM_EXECUTABLE = 'npm';
@@ -97,6 +99,7 @@ class Config {
9799
this.trackRecommendationAcceptanceCommand = commands.TRACK_RECOMMENDATION_ACCEPTANCE_COMMAND;
98100
this.recommendationsEnabled = rhdaConfig.recommendations.enabled;
99101
this.utmSource = GlobalState.UTM_SOURCE;
102+
this.backendUrl = rhdaConfig.backendUrl || this.DEFAULT_BACKEND_URL;
100103
this.exhortProxyUrl = this.getEffectiveHttpProxyUrl();
101104
/* istanbul ignore next */
102105
this.matchManifestVersions = rhdaConfig.matchManifestVersions ? 'true' : 'false';
@@ -189,6 +192,7 @@ class Config {
189192
process.env['VSCEXT_TRUSTIFY_DA_PYTHON_PATH'] = this.exhortPythonPath;
190193
process.env['VSCEXT_TRUSTIFY_DA_PIP_PATH'] = this.exhortPipPath;
191194
process.env['VSCEXT_TELEMETRY_ID'] = this.telemetryId;
195+
process.env['VSCEXT_TRUSTIFY_DA_BACKEND_URL'] = this.backendUrl;
192196
process.env['VSCEXT_TRUSTIFY_DA_SYFT_PATH'] = this.exhortSyftPath;
193197
process.env['VSCEXT_TRUSTIFY_DA_SYFT_CONFIG_PATH'] = this.exhortSyftConfigPath;
194198
process.env['VSCEXT_TRUSTIFY_DA_SKOPEO_PATH'] = this.exhortSkopeoPath;

src/dependencyAnalysis/diagnostics.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ async function performDiagnostics(diagnosticFilePath: Uri, contents: string, pro
100100
try {
101101
// Define configuration options for the component analysis request
102102
const options: Options = {
103+
'TRUSTIFY_DA_BACKEND_URL': globalConfig.backendUrl,
103104
'TRUSTIFY_DA_TOKEN': globalConfig.telemetryId,
104105
'TRUSTIFY_DA_SOURCE': globalConfig.utmSource,
105106
'MATCH_MANIFEST_VERSIONS': globalConfig.matchManifestVersions,

src/imageAnalysis.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { DepOutputChannel } from './depOutputChannel';
1616
* Represents options for image analysis.
1717
*/
1818
interface IOptions extends Options {
19+
TRUSTIFY_DA_BACKEND_URL: string | undefined;
1920
TRUSTIFY_DA_TOKEN: string;
2021
TRUSTIFY_DA_SOURCE: string;
2122
TRUSTIFY_DA_SYFT_PATH: string;
@@ -174,6 +175,7 @@ class DockerImageAnalysis {
174175

175176
const options: IOptions = {
176177
'TRUSTIFY_DA_TOKEN': globalConfig.telemetryId ?? '',
178+
'TRUSTIFY_DA_BACKEND_URL': globalConfig.backendUrl,
177179
'TRUSTIFY_DA_SOURCE': globalConfig.utmSource,
178180
'TRUSTIFY_DA_SYFT_PATH': globalConfig.exhortSyftPath,
179181
'TRUSTIFY_DA_SYFT_CONFIG_PATH': globalConfig.exhortSyftConfigPath,

src/imageAnalysis/diagnostics.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class DiagnosticsPipeline extends AbstractDiagnosticsPipeline<ImageData> {
9191
async function performDiagnostics(diagnosticFilePath: Uri, contents: string, provider: IImageProvider) {
9292
try {
9393
const options: IOptions = {
94+
'TRUSTIFY_DA_BACKEND_URL': globalConfig.backendUrl,
9495
'TRUSTIFY_DA_TOKEN': globalConfig.telemetryId ?? '',
9596
'TRUSTIFY_DA_SOURCE': globalConfig.utmSource,
9697
'TRUSTIFY_DA_SYFT_PATH': globalConfig.exhortSyftPath,

src/stackAnalysis.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export async function executeStackAnalysis(manifestFilePath: string, outputChann
2121

2222
// set up configuration options for the stack analysis request
2323
const options: Options = {
24+
'TRUSTIFY_DA_BACKEND_URL': globalConfig.backendUrl,
2425
'TRUSTIFY_DA_TOKEN': globalConfig.telemetryId,
2526
'TRUSTIFY_DA_SOURCE': globalConfig.utmSource,
2627
'MATCH_MANIFEST_VERSIONS': globalConfig.matchManifestVersions,

test/imageAnalysis/collector.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ suite('Image Analysis Collector tests', () => {
5151
reqImages.forEach(image => image.platform = 'linux/amd64');
5252

5353
const options: IOptions = {
54+
'TRUSTIFY_DA_BACKEND_URL': globalConfig.backendUrl,
5455
'TRUSTIFY_DA_TOKEN': globalConfig.telemetryId ?? '',
5556
'TRUSTIFY_DA_SOURCE': globalConfig.utmSource,
5657
'TRUSTIFY_DA_SYFT_PATH': globalConfig.exhortSyftPath,

0 commit comments

Comments
 (0)