-
Notifications
You must be signed in to change notification settings - Fork 170
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(1769): [5] Add processHooks endpoint for queue-service cooperation #2622
feat(1769): [5] Add processHooks endpoint for queue-service cooperation #2622
Conversation
If you change the key name of screwdriver/plugins/events/create.js Line 149 in 6f83ce1
|
plugins/processHooks/index.js
Outdated
const joi = require('joi'); | ||
const { startHookEvent } = require('../webhooks/helper'); | ||
|
||
const DEFAULT_MAX_BYTES = 1048576; |
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.
is this used?
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.
This is not used. I removed them.
plugins/webhooks/index.js
Outdated
// disregard skip ci for pull request events | ||
return pullRequestEvent(pluginOptions, request, h, parsed, token); | ||
} | ||
return await startHookEvent(pluginOptions, request, h, parsed); |
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.
I don't know well about scope of this PR. Can we start event directly instead of calling queue service API when /webhook
is called?
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.
Yes. The scope of this PR is to implement commonly referenced helpers.
The process of calling the quese-service API will be implemented in another context.
Co-authored-by: Hiroki Takatsuka <3445553+tk3fftk@users.noreply.github.com>
…ic-screwdriver-cd/screwdriver into use-queueservice-for-webhook
plugins/webhooks/index.js
Outdated
// disregard skip ci for pull request events | ||
return pullRequestEvent(pluginOptions, request, h, parsed, token); | ||
} | ||
return await startHookEvent(pluginOptions, request, h, parsed); |
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.
Since pluginOptions
is stored in parsed.pluginOptions
, shouldn't 3 arguments, request, h, parsed
, be enough?
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.
I fixed it.
plugins/webhooks/helper.js
Outdated
* @method startHookEvent | ||
* @param {Hapi.request} request Request from user | ||
* @param {Object} h Response toolkit | ||
* @param {Object} webhookConfig Parsed request.payload by scm webhook |
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.
Does it store pluginOptions
as well as request.payload
?
In the requestHook API, it's not passing webhookConfig.pluginOptions
as an argument, is that ok?
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.
Yes. I fixed the documentation of startHookEvent.
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.
I think we should add and migrate some test for helper.js
from webhooks.test.js
because this PR separates function and another PR will make some current webhooks test outdated.
plugins/webhooks/helper.js
Outdated
} | ||
|
||
/** | ||
* Start pipeline events from scm webhook config |
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.
same here but I don't know the same is correct.
* Start pipeline events from scm webhook config | |
* Start pipeline events with scm webhook config via queue-service |
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.
I fixed it.
Since this function is not necessarily called via queue-service, the phrase via queue-service
has been omitted.
scmUri = await scm.parseUrl({ checkoutUrl, token, scmContext }); | ||
} | ||
webhookConfig.changedFiles = await scm.getChangedFiles({ | ||
webhookConfig, |
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.
this might not be able to omit because the name is different.
webhookConfig, | |
payload: webhookConfig, |
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.
and does webhookConfig
contain request.payload
?
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.
The argument of getChangedFiles
will turn into webhookConfig
at this PR.
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.
make sense
|
||
if (type === 'pr') { | ||
// disregard skip ci for pull request events | ||
return pullRequestEvent(webhookConfig.pluginOptions, request, h, webhookConfig, 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.
return pullRequestEvent(webhookConfig.pluginOptions, request, h, webhookConfig, token); | |
return pullRequestEvent(pluginOptions: webhookConfig.pluginOptions, request, h, webhookConfig, 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.
Since the argument of this function is not an object literal, it should be left as it is.
In addition, some of the tests run by the webhooks plugin have been moved to helper tests. |
Context
We implemented a worker that retrieves a queue and requests the API last time.
I add an endpoint that will receive the webhookConfig sent by the worker.
The scope of this PR is to implement commonly referenced helpers.
The process of calling the quese-service API will be implemented in another context.
Objective
/processHooks
that receives the webhookConfig sent by the worker and starts the event./webhooks
are shared as helper.References
Please do not merge this PR until after the following PRs have been merged.
#1769 (comment)
License
I confirm that this contribution is made under a BSD license and that I have the authority necessary to make this contribution on behalf of its copyright owner.