Skip to content
This repository has been archived by the owner on Jan 5, 2021. It is now read-only.

bazel detector #373

Merged
merged 78 commits into from
Jan 16, 2019
Merged

bazel detector #373

merged 78 commits into from
Jan 16, 2019

Conversation

stevebillings
Copy link

This PR adds the new bazel tool. Here's the overview:

Behavior of the bazel tool (the ExternalId extraction part) is driven by a set of rules. Given how flexible and extensible bazel is, we assume that some customers will need to be able to tweak these rules for their environment and bazel extensions. BazelExternalIdExtractionSimpleRule is intended to represent an relatively easily-tweakable rule. Unfortunately I don't think we know nearly enough yet to be at all confident that SimpleRule exposes the right details. I assume our understanding (and SimpleRule) is likely to change, so I have not yet added the properties to allow the user to tweak it's values.

SimpleRules are converted into FullRules (BazelExternalIdExtractionFullRule), and FullRules are what actually drive the ExternalId extraction behavior. These can be overridden by the user, but they are complex, and the user must provide a json file to overwrite them. I'm pretty sure that I'll be providing those json files to customers as they run into problems with the hard-coded default rules. Early on as we're trying to get this working for early customers, I think it'll be important to have the ability swap in a new set of rules. Whether we leave that capability in detect forever is an open question.

So here's the flow (BazelExtractor): SimpleRules -> FullRules -> ExternalIds -> BDIO dependencies.

Steve Billings added 30 commits December 19, 2018 14:49
# Conflicts:
#	hub-detect/src/main/groovy/com/blackducksoftware/integration/hub/detect/workflow/diagnostic/RelevantFileTracker.java
#	hub-detect/src/main/groovy/com/blackducksoftware/integration/hub/detect/workflow/profiling/BomToolAggregateTimings.java
#	hub-detect/src/main/groovy/com/blackducksoftware/integration/hub/detect/workflow/report/util/ReportConstants.java
@coveralls
Copy link

coveralls commented Jan 14, 2019

Coverage Status

Coverage increased (+1.4%) to 30.493% when pulling fc1038a on sb_bazelDetector into ceb7284 on master.

@AcceptableValues(value = { "DETECTOR", "DOCKER" }, caseSensitive = true, strict = true, isCommaSeparatedList = true)
DETECT_PROJECT_TOOL("detect.project.tool", "5.0.0", PropertyType.STRING, PropertyAuthority.None, "DETECTOR,DOCKER"),
@AcceptableValues(value = { "DETECTOR", "DOCKER", "BAZEL" }, caseSensitive = true, strict = true, isCommaSeparatedList = true)
DETECT_PROJECT_TOOL("detect.project.tool", "5.0.0", PropertyType.STRING, PropertyAuthority.None, "DOCKER,DETECTOR,BAZEL"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was the docker and detector order deliberately swapped?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was making the ordering in the help match the default ordering. Thought it might avoid some potential confusion.

if (dockerToolResult.resultType == DockerToolResult.DockerToolResultType.FAILURE) {
eventSystem.publishEvent(Event.ExitCode, new ExitCodeRequest(ExitCodeType.FAILURE_GENERAL_ERROR, dockerToolResult.errorMessage));
}
ToolRunner toolRunner = new ToolRunner(eventSystem, detectContext.getBean(DockerDetector.class, detectorEnvironment));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, but you should retrieve the DetectorFactory and ask it to create the detectors. But since these are technically 'not detectors' I don't know what we want.

DetectorFactory detectorFactory = detectContext.getBean(DetectorFactory.class);
detectorFactory.createDocker();

} catch (ExecutableRunnerException e) {
logger.debug(String.format("Bazel version threw exception: %s", e.getMessage()));
return new ExecutableNotFoundDetectorResult("bazel");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably move this to the executable finder if it is just a version check.

if (!hasLookedForSystemBazel) {
final String userProvidedBazelPath = detectConfiguration.getProperty(DetectProperty.DETECT_BAZEL_PATH, PropertyAuthority.None);
resolvedBazel = executableFinder.getExecutablePathOrOverride(ExecutableType.BAZEL, true, environment.getDirectory(), userProvidedBazelPath);
hasLookedForSystemBazel = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it might fit the CacheableExecutableFinder model - might not need it's own class. But this is perfectly fine.

Steve Billings added 8 commits January 15, 2019 17:21
…- if a project order is not supplied and a decision is needed, detect will error out. (picking up Jordan's change from master).
# Conflicts:
#	detect-configuration/src/main/java/com/blackducksoftware/integration/hub/detect/DetectTool.java
#	hub-detect/src/main/groovy/com/blackducksoftware/integration/hub/detect/lifecycle/run/RunManager.java
@stevebillings stevebillings merged commit f8e077f into master Jan 16, 2019
@stevebillings stevebillings deleted the sb_bazelDetector branch January 16, 2019 19:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants