Exemple #1
0
 GoAcl readAclBy(String pipelineName, String stageName) {
   PipelineConfig pipelineConfig = pipelineConfigNamed(new CaseInsensitiveString(pipelineName));
   StageConfig stageConfig = pipelineConfig.findBy(new CaseInsensitiveString(stageName));
   AdminsConfig adminsConfig = stageConfig.getApproval().getAuthConfig();
   List<CaseInsensitiveString> users = getAuthorizedUsers(adminsConfig);
   return new GoAcl(users);
 }
Exemple #2
0
 public List<CaseInsensitiveString> pipelines(String group) {
   PipelineConfigs configs = getCurrentConfig().pipelines(group);
   List<CaseInsensitiveString> pipelines = new ArrayList<>();
   for (PipelineConfig config : configs) {
     pipelines.add(config.name());
   }
   return pipelines;
 }
Exemple #3
0
 public List<PipelineConfig> downstreamPipelinesOf(String pipelineName) {
   List<PipelineConfig> dependencies = new ArrayList<>();
   for (PipelineConfig config : getAllPipelineConfigs()) {
     if (config.dependsOn(new CaseInsensitiveString(pipelineName))) {
       dependencies.add(config);
     }
   }
   return dependencies;
 }
Exemple #4
0
 private List<String> invertSelections(List<String> selectedPipelines) {
   List<String> unselectedPipelines = new ArrayList<>();
   List<PipelineConfig> pipelineConfigList = cruiseConfig().getAllPipelineConfigs();
   for (PipelineConfig pipelineConfig : pipelineConfigList) {
     String pipelineName = CaseInsensitiveString.str(pipelineConfig.name());
     if (!selectedPipelines.contains(pipelineName)) {
       unselectedPipelines.add(pipelineName);
     }
   }
   return unselectedPipelines;
 }
Exemple #5
0
 private PipelineConfigDependencyGraph findUpstream(PipelineConfig currentPipeline) {
   List<PipelineConfigDependencyGraph> graphs = new ArrayList<>();
   for (CaseInsensitiveString name : currentPipeline.upstreamPipelines()) {
     PipelineConfig pipelineConfig = getCurrentConfig().pipelineConfigByName(name);
     graphs.add(findUpstream(pipelineConfig));
   }
   return new PipelineConfigDependencyGraph(
       currentPipeline, graphs.toArray(new PipelineConfigDependencyGraph[0]));
 }
Exemple #6
0
 public JobConfigIdentifier translateToActualCase(JobConfigIdentifier identifier) {
   PipelineConfig pipelineConfig =
       getCurrentConfig()
           .pipelineConfigByName(new CaseInsensitiveString(identifier.getPipelineName()));
   String translatedPipelineName = CaseInsensitiveString.str(pipelineConfig.name());
   StageConfig stageConfig =
       pipelineConfig.findBy(new CaseInsensitiveString(identifier.getStageName()));
   if (stageConfig == null) {
     throw new StageNotFoundException(
         new CaseInsensitiveString(identifier.getPipelineName()),
         new CaseInsensitiveString(identifier.getStageName()));
   }
   String translatedStageName = CaseInsensitiveString.str(stageConfig.name());
   JobConfig plan = stageConfig.jobConfigByInstanceName(identifier.getJobName(), true);
   if (plan == null) {
     throw new JobNotFoundException(
         identifier.getPipelineName(), identifier.getStageName(), identifier.getJobName());
   }
   String translatedJobName = plan.translatedName(identifier.getJobName());
   return new JobConfigIdentifier(translatedPipelineName, translatedStageName, translatedJobName);
 }
Exemple #7
0
 public boolean isPipelineEditableViaUI(String pipelineName) {
   PipelineConfig pipelineConfig =
       this.pipelineConfigNamed(new CaseInsensitiveString(pipelineName));
   if (pipelineConfig == null) return false;
   return isOriginLocal(pipelineConfig.getOrigin());
 }