Search in sources :

Example 16 with ReleaseDTO

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;
}
Also used : BadRequestException(com.ctrip.framework.apollo.common.exception.BadRequestException) ConfigPublishEvent(com.ctrip.framework.apollo.portal.listener.ConfigPublishEvent) ReleaseDTO(com.ctrip.framework.apollo.common.dto.ReleaseDTO) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 17 with ReleaseDTO

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);
}
Also used : ConfigPublishEvent(com.ctrip.framework.apollo.portal.listener.ConfigPublishEvent) ReleaseDTO(com.ctrip.framework.apollo.common.dto.ReleaseDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ReleaseDTO (com.ctrip.framework.apollo.common.dto.ReleaseDTO)17 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 ReleaseHistoryDTO (com.ctrip.framework.apollo.common.dto.ReleaseHistoryDTO)4 ConfigPublishEvent (com.ctrip.framework.apollo.portal.listener.ConfigPublishEvent)4 ItemDTO (com.ctrip.framework.apollo.common.dto.ItemDTO)3 BadRequestException (com.ctrip.framework.apollo.common.exception.BadRequestException)3 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)3 NamespaceDTO (com.ctrip.framework.apollo.common.dto.NamespaceDTO)2 NamespaceBO (com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Instance (com.ctrip.framework.apollo.biz.entity.Instance)1 InstanceConfig (com.ctrip.framework.apollo.biz.entity.InstanceConfig)1 Release (com.ctrip.framework.apollo.biz.entity.Release)1 InstanceService (com.ctrip.framework.apollo.biz.service.InstanceService)1 ReleaseService (com.ctrip.framework.apollo.biz.service.ReleaseService)1 AppDTO (com.ctrip.framework.apollo.common.dto.AppDTO)1 ClusterDTO (com.ctrip.framework.apollo.common.dto.ClusterDTO)1 InstanceConfigDTO (com.ctrip.framework.apollo.common.dto.InstanceConfigDTO)1 InstanceDTO (com.ctrip.framework.apollo.common.dto.InstanceDTO)1