@@ -395,14 +395,26 @@ class ScmRouter extends Scm {
395395 }
396396
397397 /**
398- * Get an array of scm context (e.g. [github:github.com, gitlab:mygitlab])
398+ * Get an array of scm contexts (e.g. [github:github.com, gitlab:mygitlab])
399399 * @method _getScmContexts
400400 * @return {Array }
401401 */
402402 _getScmContexts ( ) {
403403 return Object . keys ( this . scms ) ;
404404 }
405405
406+ /**
407+ * Get an scm context given a hostname (e.g. github:github.com)
408+ * @method _getScmContext
409+ * @param {Object } config
410+ * @param {String } [config.hostname] Hostname for scmContext (e.g. github.com)
411+ * @return {String } Full scmContext (e.g. github:github.com)
412+ */
413+ _getScmContext ( { hostname } ) {
414+ return Object . keys ( this . scms ) . find ( scmContext =>
415+ scmContext . split ( ':' ) [ 1 ] === hostname ) ;
416+ }
417+
406418 /**
407419 * Determine a scm module can handle the received webhook
408420 * @method _canHandleWebhook
@@ -427,6 +439,21 @@ class ScmRouter extends Scm {
427439 return this . scms [ config . scmContext ] . getDisplayName ( ) ;
428440 }
429441
442+ /**
443+ * Get read only config
444+ * @method getReadOnlyInfo
445+ * @param {Object } config Configuration
446+ * @param {String } config.scmContext Name of scm context
447+ * @return {Object } Read only config of scmContext (e.g.: {
448+ * "enabled": true,
449+ * "username": 'headless-user',
450+ * "accessToken": 'token'
451+ * })
452+ */
453+ getReadOnlyInfo ( config ) {
454+ return this . scms [ config . scmContext ] . getReadOnlyInfo ( ) ;
455+ }
456+
430457 /**
431458 * Get branch info of scmContext
432459 * @method _getBranchList
0 commit comments