use of com.walmartlabs.concord.policyengine.WorkspaceRule in project concord by walmartlabs.
the class WorkspacePolicyApplier method apply.
@Override
public void apply(Payload payload, PolicyEngine policy) throws Exception {
ProcessKey processKey = payload.getProcessKey();
Path workDir = payload.getHeader(Payload.WORKSPACE_DIR);
CheckResult<WorkspaceRule, Path> result = policy.getWorkspacePolicy().check(workDir);
result.getWarn().forEach(i -> {
policyWarn.inc();
logManager.warn(processKey, appendMsg("Potential workspace policy violation (policy: {})", i.getMsg()), i.getRule());
});
result.getDeny().forEach(i -> {
policyDeny.inc();
logManager.error(processKey, appendMsg("Workspace policy violation", i.getMsg()), i.getRule());
});
if (!result.getDeny().isEmpty()) {
throw new ProcessException(processKey, "Found workspace policy violations");
}
}
Aggregations