-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(2437): Add method to get read-only flag [2] #87
Conversation
index.js
Outdated
/** | ||
* Set token correctly if is read-only SCM | ||
* @param {Object} config | ||
* @param {String} [token] SCM token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra param declaration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
index.js
Outdated
*/ | ||
getConfig(config) { | ||
const newConfig = config; | ||
const readOnlyToken = Hoek.reach(this.config, 'readOnly.accessToken'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we fetch the readonly config
if (newConfig && readOnlyConfig.enabled && readOnlyConfig.accessToken) {
index.js
Outdated
*/ | ||
getConfig(config) { | ||
const newConfig = config; | ||
const readOnlyToken = Hoek.reach(this.config, 'readOnly.accessToken'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config already contains a username
& commentUserToken
. Is this newly added readOnly access token end up being same as commentUserToken
? Should we have just one token ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So here are my thoughts about that:
- ideally it'd be nice to have just one token but the
commentUserToken
is supposed to be strictly used for PR comments - if we want to overload it, I can change this; might cause breaking changes?
- also having a separate username is nice so that it's clear that everything in that section is for readOnly purpose, like this:
scms:
gitlab:
username: username
commentUserToken: commentToken
readOnly:
enabled: true
username: readOnlyUsername
accessToken: readOnlyToken
If you want just one of everything, could have something like this:
scms:
gitlab:
username: username
commentUserToken: token
readOnlyEnabled: true
@@ -4,6 +4,11 @@ | |||
const assert = require('chai').assert; | |||
const token = 'token'; | |||
const testParseHook = require('./data/parseHookOutput.json'); | |||
const readOnlyConfig = { | |||
enabled: true, | |||
username: 'headlessbot', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in practice will this user end up same as "sd-buildbot"
? If so should we reuse the user refined in scm config section
Context
We need to get data from the SCM config: read-only flag, scmContext.
Objective
This PR:
getReadOnlyInfo()
method to return read-only SCM configgetConfig()
method to inject read-only token if read-only enabledgetScmContext()
method to getscmContext
based onhostname
getWebhooksEventsMapping()
References
Related to screwdriver-cd/screwdriver#2437
License
I confirm that this contribution is made under the terms of the license found in the root directory of this repository's source tree and that I have the authority necessary to make this contribution on behalf of its copyright owner.