Skip to content
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(1079): integrate deploy keys features with auth and pipeline routes [5] #2157

Merged
merged 16 commits into from Aug 6, 2020

Conversation

supra08
Copy link
Contributor

@supra08 supra08 commented Jul 20, 2020

Context

Fixes #1079

Objective

This PR adds functionality of handling of autoKeysGeneration visibility in the UI and its response to trigger it in the scm-github module.

References

#1079

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.

@supra08 supra08 changed the title Auto deploy keys feat(): integrate deploy keys features with auth and pipeline routes [5] Jul 23, 2020
@supra08 supra08 changed the title feat(): integrate deploy keys features with auth and pipeline routes [5] feat(1079): integrate deploy keys features with auth and pipeline routes [5] Jul 23, 2020
plugins/pipelines/create.js Outdated Show resolved Hide resolved
plugins/pipelines/create.js Outdated Show resolved Hide resolved
plugins/pipelines/create.js Outdated Show resolved Hide resolved
plugins/pipelines/create.js Outdated Show resolved Hide resolved
plugins/pipelines/create.js Outdated Show resolved Hide resolved
plugins/auth/contexts.js Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Aug 5, 2020

Coverage Status

Coverage decreased (-0.03%) to 96.612% when pulling 9f11578 on supra08:auto-deploy-keys into 39e8764 on screwdriver-cd:master.

test/plugins/auth.test.js Outdated Show resolved Hide resolved
plugins/pipelines/create.js Outdated Show resolved Hide resolved
plugins/pipelines/create.js Outdated Show resolved Hide resolved
plugins/pipelines/create.js Outdated Show resolved Hide resolved
plugins/pipelines/create.js Outdated Show resolved Hide resolved
plugins/auth/contexts.js Show resolved Hide resolved
plugins/pipelines/create.js Outdated Show resolved Hide resolved
@@ -113,6 +120,36 @@ module.exports = () => ({

return defaultCollection.update();
})
.then(() => {
if (autoKeysGeneration) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This boolean check if scm, such as github has ability to do autoKeysGeneration.

What if such scm, say bitbucket does not have such feature and autoKeysGeneration = true from the payload. How do we handle that case? Would there be:

  1. add a catch block
  2. add another if condition to check both payload sent from ui has autoKeysGeneration: true, as well as check if given SCM has such ability.

In UI, we can prevent user giving input for if scm does not have autoKeysGeneration feature, but we also need to sanitize and guard on API. I can see some power users would call this API directly.

Just a thought, what do you think?

Note:

From: #1079 (comment)

If we apply this feature to all SCMs: scm-github, scm-bitbucket, then we dont have such issue, just need to catch the errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I get the point. I didn't take the case of direct API calls.
Catch is definitely needed. And it will be handled by the not implemented promise rejection in scm base.
I am wondering if the 2nd point is needed because if autoKeysGeneration is set to true in the payload, it will be rejected in the addDeployKey method and eventually sent to the catch block.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. I meant either 1) or 2).

Since handled that case in 1), 2) is no longer necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright cool 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we already have a catch at end of Promise chain ?

@@ -145,7 +139,8 @@ module.exports = () => ({
value: privateDeployKeyB64,
allowInPR: false
});
});
})
.catch(err => reply(boom.boomify(err)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't this still execute rest of the Promise chain ?
I thought was this catch is not required, and let the err propagate to the final catch at 4237422#diff-1eb6375f360812e82460d42f926123b1R170

@jithine jithine merged commit b927922 into screwdriver-cd:master Aug 6, 2020
wahapo pushed a commit to sonic-screwdriver-cd/screwdriver that referenced this pull request Aug 13, 2020
…tes [5] (screwdriver-cd#2157)

* feat(): add autoKeysGeneration key value in auth contexts and pipelines creation

* feat(): add tests for autoKeysGeneration in auth contexts and pipeline creation

* fix(): fix deploy key secret name

* refactor(): change function names to autoDeployKeyGenerationEnabled

* refactor(): Update plugins/pipelines/create.js

Co-authored-by: Tiffany K <tiffanykyi@gmail.com>

* refactor(): Add return statements

* cleanup(): Remove commented code

* lint(): Add return statement corresponding to arrow function

* fix(): Make autoDeployKeyGenerationEnabled to that of non promise function

* fix(): Fix secret value in test

* fix(): Remove redundant usage of pipelineFactory

* refactor(): remove unreachable paths and change variable names

* cleanup(): remove straw console logs

* fix(): Remove unnecessary get secret test assertion

* fix(): Add necessary catch block

* fix(): remove unnecessary catch block

Co-authored-by: Tiffany K <tiffanykyi@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate and Use Deploy Keys
5 participants