Skip to content

Commit

Permalink
move disable to environs.java to get rid of env/stage name
Browse files Browse the repository at this point in the history
  • Loading branch information
liyaqin1 committed May 17, 2024
1 parent 73cf064 commit 935fc3b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,17 +283,6 @@ public void pindeployPipelineAction(@Context SecurityContext sc,
LOG.info(String.format("Successfully updated pindeploy pipeline for %s/%s by %s", envName, stageName, operator));
}

@POST
@Path("/pindeployPipeline/disable")
@RolesAllowed(TeletraanPrincipalRole.Names.EXECUTE)
@ResourceAuthZInfo(type = AuthZResource.Type.ENV_STAGE, idLocation = Location.PATH)
public void pindeployPipelineAction(@Context SecurityContext sc,
@NotEmpty @QueryParam("pipeline") String pipeline) throws Exception {
String operator = sc.getUserPrincipal().getName();
pindeployDAO.delete(pipeline);
LOG.info(String.format("Successfully disabled pindeploy pipeline %s by %s", pipeline, operator));
}

private void stageTypeValidate(EnvironBean origBean, EnvironBean newBean) throws Exception {
Map<EnvType, String> stageTypeCategory = new HashMap<>();
stageTypeCategory.put(EnvType.DEFAULT, "PRODUCTION");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.pinterest.deployservice.bean.EnvType;
import com.pinterest.deployservice.dao.EnvironDAO;
import com.pinterest.deployservice.dao.UserRolesDAO;
import com.pinterest.deployservice.dao.PindeployDAO;
import com.pinterest.deployservice.handler.EnvTagHandler;
import com.pinterest.deployservice.handler.EnvironHandler;
import com.pinterest.deployservice.handler.TagHandler;
Expand Down Expand Up @@ -75,12 +76,14 @@ public enum ActionType {
private EnvironHandler environHandler;
private TagHandler tagHandler;
private UserRolesDAO userRolesDAO;
private PindeployDAO pindeployDAO;

public Environs(@Context TeletraanServiceContext context) throws Exception {
environDAO = context.getEnvironDAO();
environHandler = new EnvironHandler(context);
tagHandler = new EnvTagHandler(context);
userRolesDAO = context.getUserRolesDAO();
pindeployDAO = context.getPindeployDAO();
}

@GET
Expand Down Expand Up @@ -204,4 +207,15 @@ public void action(@Context SecurityContext sc,
tagHandler.createTag(tagBean, operator);
LOG.info(String.format("Successfully updated actions %s for all envs by %s", actionType, operator));
}

@POST
@Path("/pindeployPipeline/disable")
@RolesAllowed(TeletraanPrincipalRole.Names.EXECUTE)
@ResourceAuthZInfo(type = AuthZResource.Type.ENV_STAGE, idLocation = Location.PATH)
public void pindeployPipelineAction(@Context SecurityContext sc,
@NotEmpty @QueryParam("pipeline") String pipeline) throws Exception {
String operator = sc.getUserPrincipal().getName();
pindeployDAO.delete(pipeline);
LOG.info(String.format("Successfully disabled pindeploy pipeline %s by %s", pipeline, operator));
}
}

0 comments on commit 935fc3b

Please sign in to comment.