use of com.ctrip.framework.apollo.common.dto.ReleaseDTO in project apollo by ctripcorp.
the class ReleaseController method createGrayRelease.
@PreAuthorize(value = "@permissionValidator.hasReleaseNamespacePermission(#appId, #namespaceName)")
@RequestMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/releases", method = RequestMethod.POST)
public ReleaseDTO createGrayRelease(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @PathVariable String branchName, @RequestBody NamespaceReleaseModel model) {
checkModel(Objects.nonNull(model));
model.setAppId(appId);
model.setEnv(env);
model.setClusterName(branchName);
model.setNamespaceName(namespaceName);
if (model.isEmergencyPublish() && !portalConfig.isEmergencyPublishAllowed(Env.valueOf(env))) {
throw new BadRequestException(String.format("Env: %s is not supported emergency publish now", env));
}
ReleaseDTO createdRelease = releaseService.publish(model);
ConfigPublishEvent event = ConfigPublishEvent.instance();
event.withAppId(appId).withCluster(clusterName).withNamespace(namespaceName).withReleaseId(createdRelease.getId()).setGrayPublishEvent(true).setEnv(Env.valueOf(env));
publisher.publishEvent(event);
return createdRelease;
}
use of com.ctrip.framework.apollo.common.dto.ReleaseDTO in project apollo by ctripcorp.
the class ReleaseController method rollback.
@RequestMapping(path = "/envs/{env}/releases/{releaseId}/rollback", method = RequestMethod.PUT)
public void rollback(@PathVariable String env, @PathVariable long releaseId) {
releaseService.rollback(Env.valueOf(env), releaseId);
ReleaseDTO release = releaseService.findReleaseById(Env.valueOf(env), releaseId);
if (Objects.isNull(release)) {
return;
}
ConfigPublishEvent event = ConfigPublishEvent.instance();
event.withAppId(release.getAppId()).withCluster(release.getClusterName()).withNamespace(release.getNamespaceName()).withPreviousReleaseId(releaseId).setRollbackEvent(true).setEnv(Env.valueOf(env));
publisher.publishEvent(event);
}
Aggregations