@broadcom/endevor-bridge-for-git-for-zowe-cli
Version:
Endevor Bridge for Git plug-in for Zowe CLI
134 lines • 5.63 kB
JavaScript
"use strict";
/*
* Copyright (c) 2019 Broadcom. All Rights Reserved. The term
* "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
*
* This software and all information contained therein is
* confidential and proprietary and shall not be duplicated,
* used, disclosed, or disseminated in any way except as
* authorized by the applicable license agreement, without the
* express written permission of Broadcom. All authorized
* reproductions must be marked with this language.
*
* EXCEPT AS SET FORTH IN THE APPLICABLE LICENSE AGREEMENT, TO
* THE EXTENT PERMITTED BY APPLICABLE LAW, BROADCOM PROVIDES THIS
* SOFTWARE WITHOUT WARRANTY OF ANY KIND, INCLUDING WITHOUT
* LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL BROADCOM
* BE LIABLE TO THE END USER OR ANY THIRD PARTY FOR ANY LOSS OR
* DAMAGE, DIRECT OR INDIRECT, FROM THE USE OF THIS SOFTWARE,
* INCLUDING WITHOUT LIMITATION, LOST PROFITS, BUSINESS
* INTERRUPTION, GOODWILL, OR LOST DATA, EVEN IF BROADCOM IS
* EXPRESSLY ADVISED OF SUCH LOSS OR DAMAGE.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.EBGSession = void 0;
const imperative_1 = require("@zowe/imperative");
const api_1 = require("../../api");
/**
* Utility Methods for Endevor Bridge for Git Session
*/
class EBGSession extends api_1.OptionUtils {
/**
* Creates the Endevor Bridge for Git connection session if and only if all the required options are provided
*
* @param args command arguments
* @param profile Endevor Bridge for Git profile
*/
createSession(args, profile) {
const session = {
type: "basic",
protocol: this.getOption(true, EBGSession.EBG_OPTION_PROTOCOL, args, profile, null, EBGSession.DEFAULT_PROTOCOL),
hostname: this.getOption(true, EBGSession.EBG_OPTION_HOST, args, profile),
port: Number(this.getOption(true, EBGSession.EBG_OPTION_PORT, args, profile)),
user: this.getOption(true, EBGSession.EBG_OPTION_USER, args, profile),
password: this.getOption(true, EBGSession.EBG_OPTION_GIT_PERSONAL_ACCESS_TOKEN, args, profile),
rejectUnauthorized: this.getOption(true, EBGSession.EBG_OPTION_REJECT_UNAUTHORIZED, args, profile, null, EBGSession.DEFAULT_REJECT_UNAUTHORIZED),
basePath: EBGSession.DEFAULT_BASE_PATH
};
if (!this.optionValidator.isMissingOptions(EBGSession.EBG_SESSION_OPTION_GROUP)) {
return new imperative_1.Session(session);
}
}
}
exports.EBGSession = EBGSession;
EBGSession.PROFILE_TYPE = "ebg";
EBGSession.EBG_SESSION_OPTION_GROUP = "Endevor Bridge for Git connection options (alternatively use an 'ebg' profile)";
EBGSession.DEFAULT_PROTOCOL = imperative_1.AbstractSession.DEFAULT_PROTOCOL;
EBGSession.DEFAULT_REJECT_UNAUTHORIZED = false;
EBGSession.DEFAULT_BASE_PATH = "rest/evcs/v1";
/**
* Option used in profile creation and commands for protocol for Endevor Bridge for Git
*/
EBGSession.EBG_OPTION_PROTOCOL = {
name: "protocol", aliases: ["prot"],
description: "The Endevor Bridge for Git SCM protocol. " + api_1.OptionUtils.defaultValueDescription(EBGSession.DEFAULT_PROTOCOL),
type: "string",
required: true,
group: EBGSession.EBG_SESSION_OPTION_GROUP,
defaultValue: EBGSession.DEFAULT_PROTOCOL,
allowableValues: { values: ["http", "https"], caseSensitive: false }
};
/**
* Option used in profile creation and commands for hostname for Endevor Bridge for Git
*/
EBGSession.EBG_OPTION_HOST = {
name: "host", aliases: ["H"],
description: "The Endevor Bridge for Git hostname.",
type: "string",
required: true,
group: EBGSession.EBG_SESSION_OPTION_GROUP
};
/**
* Option used in profile creation and commands for port for Endevor Bridge for Git
*/
EBGSession.EBG_OPTION_PORT = {
name: "port", aliases: ["P"],
description: "The Endevor Bridge for Git port.",
type: "number",
required: true,
group: EBGSession.EBG_SESSION_OPTION_GROUP
};
/**
* Option used in profile creation and commands for username / ID for Endevor Bridge for Git
*/
EBGSession.EBG_OPTION_USER = {
name: "user", aliases: ["u"],
description: "Endevor Bridge for Git username (your git username).",
type: "string",
required: true,
group: EBGSession.EBG_SESSION_OPTION_GROUP
};
/**
* Option used in profile creation and commands for password/passphrase for Endevor Bridge for Git
*/
EBGSession.EBG_OPTION_GIT_PERSONAL_ACCESS_TOKEN = {
name: "token", aliases: ["t"],
description: "Git personal access token (it can be obtained from your Git Enterprise Server).",
type: "string",
required: true,
group: EBGSession.EBG_SESSION_OPTION_GROUP,
};
/**
* Option used in profile creation and commands for rejectUnauthorized setting for connecting to Endevor Bridge for Git
*/
EBGSession.EBG_OPTION_REJECT_UNAUTHORIZED = {
name: "reject-unauthorized", aliases: ["ru"],
description: "Reject self-signed certificates. " +
api_1.OptionUtils.defaultValueDescription(false),
type: "boolean",
group: EBGSession.EBG_SESSION_OPTION_GROUP
};
/**
* Options related to connecting to Endevor Bridge for Git
* These options can be filled in if the user creates a profile
*/
EBGSession.EBG_CONNECTION_OPTIONS = [
EBGSession.EBG_OPTION_PROTOCOL,
EBGSession.EBG_OPTION_HOST,
EBGSession.EBG_OPTION_PORT,
EBGSession.EBG_OPTION_USER,
EBGSession.EBG_OPTION_GIT_PERSONAL_ACCESS_TOKEN,
EBGSession.EBG_OPTION_REJECT_UNAUTHORIZED
];
//# sourceMappingURL=EBGSession.js.map