public PipelineConfigs removePipeline(String pipelineName, CruiseConfig cruiseConfig) { String groupName = cruiseConfig.getGroups().findGroupNameByPipeline(new CaseInsensitiveString(pipelineName)); PipelineConfigs groups = cruiseConfig.getGroups().findGroup(groupName); groups.remove(cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipelineName))); return groups; }
public void removePipeline(String pipelineName) { CruiseConfig cruiseConfig = loadForEdit(); PipelineConfigs groups = removePipeline(pipelineName, cruiseConfig); if (groups.isEmpty()) { cruiseConfig.getGroups().remove(groups); } writeConfigFile(cruiseConfig); }
public void setViewPermissionForGroup(String groupName, String username) { CruiseConfig cruiseConfig = loadForEdit(); PipelineConfigs group = cruiseConfig.getGroups().findGroup(groupName); group .getAuthorization() .getViewConfig() .add(new AdminUser(new CaseInsensitiveString(username))); writeConfigFile(cruiseConfig); }
public void blockPipelineGroupExceptFor(String pipelineGroupName, String roleName) { CruiseConfig config = loadForEdit(); PipelineConfigs configs = config.getGroups().findGroup(pipelineGroupName); Authorization authorization = new Authorization( new OperationConfig(new AdminRole(new CaseInsensitiveString(roleName))), new ViewConfig(new AdminRole(new CaseInsensitiveString(roleName)))); configs.setAuthorization(authorization); writeConfigFile(config); }
public void setOperatePermissionForGroup(String groupName, String... userNames) { CruiseConfig cruiseConfig = loadForEdit(); Admin[] admins = AdminUserMother.adminUsers(userNames); for (Admin admin : admins) { cruiseConfig .getGroups() .findGroup(groupName) .getAuthorization() .getOperationConfig() .add(admin); } writeConfigFile(cruiseConfig); }
public void addAuthorizedUserForPipelineGroup(String user) { CruiseConfig cruiseConfig = loadForEdit(); PipelineConfigs group = cruiseConfig.getGroups().first(); group.getAuthorization().getViewConfig().add(new AdminUser(new CaseInsensitiveString(user))); writeConfigFile(cruiseConfig); }