Skip to content

Conversation

@jhadvig
Copy link
Member

@jhadvig jhadvig commented Nov 27, 2018

From the bug description there are two issues:

  1. When a freshly created webhook secret is not available right away so the secret value of the trigger URL is undefined: .../buildconfigs/webhooks/undefined/generic
  2. When the referenced secrets is deleted, but still used in the buildConfig trigger
    Just met the issue one time after trying at least ten times. This requests the copy action taking place right after the secret is created and added as webhook.

Haven't found any reasonable precedence for showing warnings in the description list terms in the codebase(hopefully I haven't overlooked anything), so created a proposal that would cover both issues:
1

Marked the PR as WIP to open the design discussion, code is not ready for review...

cc'ing @openshift/team-ux-review

@spadgett PTAL

@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 27, 2018
</dt>
<dd>
<copy-to-clipboard clipboard-text="buildConfig.metadata.name | webhookURL : trigger.type : trigger.generic : project.metadata.name : webhookSecrets"></copy-to-clipboard>
<div ng-if="trigger.generic | isWebhookAvailable : webhookSecrets">
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this potentially a problem for all webhook types, not only generic webhooks?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah its definitely problem of all the webhook triggers... this is just a WIP

return null;
};
})
.filter('isWebhookAvailable', function(SecretsService) {
Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest having the webhookURL filter return an empty string instead of creating a separate filter.

@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 27, 2018
@jhadvig jhadvig changed the title [WIP] Bug 1652645 - Webhook urls in configuration page are invalid with undefined included Bug 1652645 - Webhook urls in configuration page are invalid with undefined included Nov 27, 2018
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 27, 2018
@jhadvig
Copy link
Member Author

jhadvig commented Nov 27, 2018

@spadgett I've updated the PR and removed the WIP flag.
Found out that the cleanest and easiest way is to create a wrapper copyWebhookTrigger directive, check for the webhook-url inside and render the "Not Available" together with the warning icon or the copyToClipboard directive.

PTAL

if (canIFilter(secretsVersion, 'list')) {
secret = SecretsService.getWebhookSecretValue(secret, webhookSecrets);
if (!secret) {
return '';
Copy link
Member Author

Choose a reason for hiding this comment

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

We could return secret, but was rather explicit with the return value here.

Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

One small comment, but I don't think it's an issue in practice. Tagging for merge. Thanks 👍

/lgtm

if (_.get(secret, 'secretReference.name') && webhookSecrets) {
var matchingSecret = _.find(webhookSecrets, {metadata:{name: secret.secretReference.name}});
return decodeSecretData(matchingSecret.data).WebHookSecretKey;
return _.has(matchingSecret, 'data') ? decodeSecretData(matchingSecret.data).WebHookSecretKey : '';
Copy link
Member

Choose a reason for hiding this comment

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

Prefer _.get so we never try to decode null values. (_.has only checks for undefined.)

Suggested change
return _.has(matchingSecret, 'data') ? decodeSecretData(matchingSecret.data).WebHookSecretKey : '';
return _.get(matchingSecret, 'data') ? decodeSecretData(matchingSecret.data).WebHookSecretKey : '';

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 27, 2018
@spadgett
Copy link
Member

We should fix in 3.10 and 3.11 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants