@@ -10,23 +10,19 @@ namespace Microsoft.ComponentDetection.Common;
10
10
/// <inheritdoc />
11
11
public class ComponentDetectionConfigFileService : IComponentDetectionConfigFileService
12
12
{
13
- private const string ComponentDetectionConfigFileEnvVar = "ComponentDetection.ComponentDetectionConfigFile" ;
14
13
private readonly IFileUtilityService fileUtilityService ;
15
- private readonly IEnvironmentVariableService environmentVariableService ;
16
14
private readonly IPathUtilityService pathUtilityService ;
17
15
private readonly ComponentDetectionConfigFile componentDetectionConfig ;
18
16
private readonly ILogger < FastDirectoryWalkerFactory > logger ;
19
17
private bool serviceInitComplete ;
20
18
21
19
public ComponentDetectionConfigFileService (
22
20
IFileUtilityService fileUtilityService ,
23
- IEnvironmentVariableService environmentVariableService ,
24
21
IPathUtilityService pathUtilityService ,
25
22
ILogger < FastDirectoryWalkerFactory > logger )
26
23
{
27
24
this . fileUtilityService = fileUtilityService ;
28
25
this . pathUtilityService = pathUtilityService ;
29
- this . environmentVariableService = environmentVariableService ;
30
26
this . logger = logger ;
31
27
this . componentDetectionConfig = new ComponentDetectionConfigFile ( ) ;
32
28
this . serviceInitComplete = false ;
@@ -40,12 +36,6 @@ public ComponentDetectionConfigFile GetComponentDetectionConfig()
40
36
41
37
public async Task InitAsync ( string explicitConfigPath , string rootDirectoryPath = null )
42
38
{
43
- await this . LoadFromEnvironmentVariableAsync ( ) ;
44
- if ( ! string . IsNullOrEmpty ( explicitConfigPath ) )
45
- {
46
- await this . LoadComponentDetectionConfigAsync ( explicitConfigPath ) ;
47
- }
48
-
49
39
if ( ! string . IsNullOrEmpty ( rootDirectoryPath ) )
50
40
{
51
41
await this . LoadComponentDetectionConfigFilesFromRootDirectoryAsync ( rootDirectoryPath ) ;
@@ -65,18 +55,6 @@ private async Task LoadComponentDetectionConfigFilesFromRootDirectoryAsync(strin
65
55
}
66
56
}
67
57
68
- private async Task LoadFromEnvironmentVariableAsync ( )
69
- {
70
- if ( this . environmentVariableService . DoesEnvironmentVariableExist ( ComponentDetectionConfigFileEnvVar ) )
71
- {
72
- var possibleConfigFilePath = this . environmentVariableService . GetEnvironmentVariable ( ComponentDetectionConfigFileEnvVar ) ;
73
- if ( this . fileUtilityService . Exists ( possibleConfigFilePath ) )
74
- {
75
- await this . LoadComponentDetectionConfigAsync ( possibleConfigFilePath ) ;
76
- }
77
- }
78
- }
79
-
80
58
private async Task LoadComponentDetectionConfigAsync ( string configFile )
81
59
{
82
60
if ( ! this . fileUtilityService . Exists ( configFile ) )
@@ -87,25 +65,9 @@ private async Task LoadComponentDetectionConfigAsync(string configFile)
87
65
var configFileInfo = new FileInfo ( configFile ) ;
88
66
var fileContents = await this . fileUtilityService . ReadAllTextAsync ( configFileInfo ) ;
89
67
var newConfig = this . ParseComponentDetectionConfig ( fileContents ) ;
90
- this . MergeComponentDetectionConfig ( newConfig ) ;
91
68
this . logger . LogInformation ( "Loaded component detection config file from {ConfigFile}" , configFile ) ;
92
69
}
93
70
94
- /// <summary>
95
- /// Merges two component detection configs, giving precedence to values already set in the first file.
96
- /// </summary>
97
- /// <param name="newConfig">The new config file to be merged into the existing config set.</param>
98
- private void MergeComponentDetectionConfig ( ComponentDetectionConfigFile newConfig )
99
- {
100
- foreach ( ( var name , var value ) in newConfig . Variables )
101
- {
102
- if ( ! this . componentDetectionConfig . Variables . ContainsKey ( name ) )
103
- {
104
- this . componentDetectionConfig . Variables [ name ] = value ;
105
- }
106
- }
107
- }
108
-
109
71
/// <summary>
110
72
/// Reads the component detection config from a file path.
111
73
/// </summary>
0 commit comments