Skip to content

Commit 793e54d

Browse files
committed
remove variable and build arg paths
1 parent af69fc4 commit 793e54d

File tree

3 files changed

+1
-43
lines changed

3 files changed

+1
-43
lines changed

src/Microsoft.ComponentDetection.Common/ComponentDetectionConfigFileService.cs

-38
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,19 @@ namespace Microsoft.ComponentDetection.Common;
1010
/// <inheritdoc />
1111
public class ComponentDetectionConfigFileService : IComponentDetectionConfigFileService
1212
{
13-
private const string ComponentDetectionConfigFileEnvVar = "ComponentDetection.ComponentDetectionConfigFile";
1413
private readonly IFileUtilityService fileUtilityService;
15-
private readonly IEnvironmentVariableService environmentVariableService;
1614
private readonly IPathUtilityService pathUtilityService;
1715
private readonly ComponentDetectionConfigFile componentDetectionConfig;
1816
private readonly ILogger<FastDirectoryWalkerFactory> logger;
1917
private bool serviceInitComplete;
2018

2119
public ComponentDetectionConfigFileService(
2220
IFileUtilityService fileUtilityService,
23-
IEnvironmentVariableService environmentVariableService,
2421
IPathUtilityService pathUtilityService,
2522
ILogger<FastDirectoryWalkerFactory> logger)
2623
{
2724
this.fileUtilityService = fileUtilityService;
2825
this.pathUtilityService = pathUtilityService;
29-
this.environmentVariableService = environmentVariableService;
3026
this.logger = logger;
3127
this.componentDetectionConfig = new ComponentDetectionConfigFile();
3228
this.serviceInitComplete = false;
@@ -40,12 +36,6 @@ public ComponentDetectionConfigFile GetComponentDetectionConfig()
4036

4137
public async Task InitAsync(string explicitConfigPath, string rootDirectoryPath = null)
4238
{
43-
await this.LoadFromEnvironmentVariableAsync();
44-
if (!string.IsNullOrEmpty(explicitConfigPath))
45-
{
46-
await this.LoadComponentDetectionConfigAsync(explicitConfigPath);
47-
}
48-
4939
if (!string.IsNullOrEmpty(rootDirectoryPath))
5040
{
5141
await this.LoadComponentDetectionConfigFilesFromRootDirectoryAsync(rootDirectoryPath);
@@ -65,18 +55,6 @@ private async Task LoadComponentDetectionConfigFilesFromRootDirectoryAsync(strin
6555
}
6656
}
6757

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-
8058
private async Task LoadComponentDetectionConfigAsync(string configFile)
8159
{
8260
if (!this.fileUtilityService.Exists(configFile))
@@ -87,25 +65,9 @@ private async Task LoadComponentDetectionConfigAsync(string configFile)
8765
var configFileInfo = new FileInfo(configFile);
8866
var fileContents = await this.fileUtilityService.ReadAllTextAsync(configFileInfo);
8967
var newConfig = this.ParseComponentDetectionConfig(fileContents);
90-
this.MergeComponentDetectionConfig(newConfig);
9168
this.logger.LogInformation("Loaded component detection config file from {ConfigFile}", configFile);
9269
}
9370

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-
10971
/// <summary>
11072
/// Reads the component detection config from a file path.
11173
/// </summary>

src/Microsoft.ComponentDetection.Orchestrator/Commands/BaseSettings.cs

-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ public abstract class BaseSettings : CommandSettings
3737
[CommandOption("--Output")]
3838
public string Output { get; set; }
3939

40-
[Description("File path for a ComponentDetection.yml config file with more instructions for detection")]
41-
[CommandOption("--ComponentDetectionConfigFile")]
42-
public string ComponentDetectionConfigFile { get; set; }
43-
4440
/// <inheritdoc />
4541
public override ValidationResult Validate()
4642
{

src/Microsoft.ComponentDetection.Orchestrator/Commands/ScanCommand.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public ScanCommand(
4444
public override async Task<int> ExecuteAsync(CommandContext context, ScanSettings settings)
4545
{
4646
this.fileWritingService.Init(settings.Output);
47-
await this.componentDetectionConfigFileService.InitAsync(settings.ComponentDetectionConfigFile, settings.SourceDirectory.FullName);
47+
await this.componentDetectionConfigFileService.InitAsync(settings.SourceDirectory.FullName);
4848
var result = await this.scanExecutionService.ExecuteScanAsync(settings);
4949
this.WriteComponentManifest(settings, result);
5050
return 0;

0 commit comments

Comments
 (0)