Search in sources :

Example 1 with VcsAuthType

use of com.orion.ops.consts.app.VcsAuthType in project orion-ops by lijiahangmax.

the class ApplicationVcsServiceImpl method getVcsUsernamePassword.

@Override
public String[] getVcsUsernamePassword(ApplicationVcsDO vcs) {
    String username = null;
    String password = null;
    VcsAuthType authType = VcsAuthType.of(vcs.getVcsAuthType());
    if (VcsAuthType.PASSWORD.equals(authType)) {
        // 用户名
        String vscUsername = vcs.getVscUsername();
        if (!Strings.isBlank(vscUsername)) {
            username = vscUsername;
            password = ValueMix.decrypt(vcs.getVcsPassword());
        }
    } else {
        // token
        VcsTokenType tokenType = VcsTokenType.of(vcs.getVcsTokenType());
        switch(tokenType) {
            case GITHUB:
                username = Const.EMPTY;
                break;
            case GITEE:
                username = vcs.getVscUsername();
                break;
            case GITLAB:
                username = Const.OAUTH2;
                break;
            default:
                break;
        }
        password = ValueMix.decrypt(vcs.getVcsPrivateToken());
    }
    return new String[] { username, password };
}
Also used : VcsTokenType(com.orion.ops.consts.app.VcsTokenType) VcsAuthType(com.orion.ops.consts.app.VcsAuthType)

Example 2 with VcsAuthType

use of com.orion.ops.consts.app.VcsAuthType in project orion-ops by lijiahangmax.

the class ApplicationVcsController method addAppVcs.

/**
 * 添加版本仓库
 */
@RequestMapping("/add")
@EventLog(EventType.ADD_VCS)
public Long addAppVcs(@RequestBody ApplicationVcsRequest request) {
    Valid.allNotBlank(request.getName(), request.getUrl());
    VcsAuthType authType = Valid.notNull(VcsAuthType.of(request.getAuthType()));
    if (VcsAuthType.TOKEN.equals(authType)) {
        Valid.notNull(VcsTokenType.of(request.getTokenType()));
        Valid.notBlank(request.getPrivateToken());
    }
    return applicationVcsService.addAppVcs(request);
}
Also used : VcsAuthType(com.orion.ops.consts.app.VcsAuthType) EventLog(com.orion.ops.annotation.EventLog) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

VcsAuthType (com.orion.ops.consts.app.VcsAuthType)2 EventLog (com.orion.ops.annotation.EventLog)1 VcsTokenType (com.orion.ops.consts.app.VcsTokenType)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1