public static List<String> toStringList(Collection<CaseInsensitiveString> strings) { return toStringList(strings.stream()); }
public static List<String> toStringList(CaseInsensitiveString... strings) { return toStringList(Arrays.stream(strings)); }
public List<GoDashboardPipeline> allPipelines(CruiseConfig config) { List<CaseInsensitiveString> allPipelineNames = config.getAllPipelineNames(); HashSet<CaseInsensitiveString> currentPipelineNames = new HashSet<>(allPipelineNames); Collection<CaseInsensitiveString> pipelinesToRemove = Sets.difference(lastKnownPipelineNames, currentPipelineNames); Collection<CaseInsensitiveString> pipelinesToAdd = Sets.difference(currentPipelineNames, lastKnownPipelineNames); if (!pipelinesToAdd.isEmpty()) { historyForDashboard.addAll(loadHistoryForPipelines(new ArrayList<>(CaseInsensitiveString.toStringList(pipelinesToAdd)))); } for (CaseInsensitiveString pipelineNameToRemove : new ArrayList<>(pipelinesToRemove)) { clearEntryFor(pipelineNameToRemove); } lastKnownPipelineNames = currentPipelineNames; LOGGER.debug("Loading permissions from authority"); final Map<CaseInsensitiveString, Permissions> pipelinesAndTheirPermissions = permissionsAuthority.pipelinesAndTheirPermissions(); final List<GoDashboardPipeline> pipelines = new ArrayList<>(1024); LOGGER.debug("Populating dashboard pipelines"); config.accept((PipelineGroupVisitor) group -> group.accept(pipelineConfig -> { long start = System.currentTimeMillis(); Permissions permissions = permissionsFor(pipelineConfig, pipelinesAndTheirPermissions); pipelines.add(createGoDashboardPipeline(pipelineConfig, permissions, historyForDashboard, group)); LOGGER.debug("It took {}ms to process pipeline {}", (System.currentTimeMillis() - start), pipelineConfig.getName()); })); LOGGER.debug("Done populating dashboard pipelines"); this.everLoadedCurrentState = true; return pipelines; }
@Override public boolean isValid(CruiseConfig preprocessedConfig) { List<CaseInsensitiveString> pipelinesAssociatedWithTemplate = preprocessedConfig.pipelinesAssociatedWithTemplate(templateConfig.name()); if (!pipelinesAssociatedWithTemplate.isEmpty()) { result.unprocessableEntity(cannotDeleteResourceBecauseOfDependentPipelines("template", templateConfig.name(), CaseInsensitiveString.toStringList(pipelinesAssociatedWithTemplate))); throw new GoConfigInvalidException(preprocessedConfig, String.format("The template '%s' is being referenced by pipeline(s): %s", templateConfig.name(), pipelinesAssociatedWithTemplate)); } return true; }
public GoDashboardPipeline pipelineFor(PipelineConfig pipelineConfig, PipelineConfigs groupConfig) { List<String> pipelineNames = CaseInsensitiveString.toStringList(Collections.singletonList(pipelineConfig.getName())); PipelineInstanceModels pipelineHistoryForDashboard = loadHistoryForPipelines(pipelineNames); syncHistoryForDashboard(pipelineHistoryForDashboard, pipelineConfig.name()); Permissions permissions = permissionsAuthority.permissionsForPipeline(pipelineConfig.name()); return createGoDashboardPipeline(pipelineConfig, permissions, pipelineHistoryForDashboard, groupConfig); }