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

Warn when secret keys are not valid env var names #2039

Merged
merged 1 commit into from Sep 12, 2017

Conversation

jeff-phillips-18
Copy link
Member

fixes #2029

image

@beanh66

<label class="add-choice" for="mountVolume">
<input type="radio" ng-model="ctrl.addType" value="volume" ng-disabled="ctrl.disableInputs">
<label class="add-choice" for="volume">
<input id="volume" type="radio" ng-model="ctrl.addType" value="volume" ng-disabled="ctrl.disableInputs">
Copy link
Member

Choose a reason for hiding this comment

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

If the <label> element wraps the <input>, you don't need the for and id attributes.

Copy link
Member Author

Choose a reason for hiding this comment

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

If I remove it then clicking on the label does not toggle the radio. It's hard to click on just the little radio button.

Copy link
Member

Choose a reason for hiding this comment

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

Really? Hm. It seems to work here, but maybe browser specific?

https://getbootstrap.com/docs/3.3/css/#checkboxes-and-radios

OK to leave if it's needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right, dunno what I was doing wrong before...

</label>
<div class="alert alert-warning env-warning" ng-show="ctrl.invalidEnvVars.length">
<span class="pficon pficon-warning-triangle-o"></span>
<span>Some of the keys for secret <strong>{{ctrl.secret.metadata.name}}</strong> are not valid environment variable names and will not be added.</span>.
Copy link
Member

Choose a reason for hiding this comment

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

Looks like you have two periods

Environment variables
</label>
<div class="alert alert-warning env-warning" ng-show="ctrl.invalidEnvVars.length">
<span class="pficon pficon-warning-triangle-o"></span>
Copy link
Member

Choose a reason for hiding this comment

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

aria-hidden="true"

if (!keyValidator.test(nextKey)) {
ctrl.invalidEnvVars.push(nextKey);
}
});
Copy link
Member

Choose a reason for hiding this comment

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

If you only care if some key is invalid, this could be

ctrl.hasInvalidEnvVars = _.some(ctrl.secret.data, function(value, key) {
  return !keyValidator.test(key);
});

Otherwise, I'd probably avoid the extra keys call by using

_.each(ctrl.secret.data, function(value, key) {
  if (!keyValidator.test(key)) {
    ctrl.invalidEnvVars.push(key);
  }
});

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, I was going do do that but wasn't sure if we wanted to be able to list the invalid keys at some point. Thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

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

Still working on getting the validator to work correctly.
var keyValidator = new RegExp("[A-Za-z_][A-Za-z0-9_]*");

is allowing 'database-name' (as well as 'database=name')...

Copy link
Member

@spadgett spadgett Sep 11, 2017

Choose a reason for hiding this comment

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

Maybe

var keyValidator = new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe I've got it working with:

      var keyValidator = new RegExp("^[A-Za-z_]{1}[A-Za-z0-9_]{0,}$");

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 * OK instead of {0,}?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it is. Got carried away with some other attempts... ;)

@jeff-phillips-18
Copy link
Member Author

Believe I have addressed all of @spadgett's comments.

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.

LGTM, thanks @jeff-phillips-18

@beanh66
Copy link
Member

beanh66 commented Sep 11, 2017

Thanks @jeff-phillips-18 the new visuals look great 👍

@spadgett
Copy link
Member

[merge][severity: bug]

@openshift-bot
Copy link

[Test]ing while waiting on the merge queue

@openshift-bot
Copy link

Evaluated for origin web console test up to 381269a

@openshift-bot
Copy link

Origin Web Console Test Results: FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin_web_console/160/) (Base Commit: 375e384) (PR Branch Commit: 381269a)

@spadgett
Copy link
Member

[merge][severity: bug]

@spadgett
Copy link
Member

WebDriver flake

[merge][severity:bug]

@spadgett
Copy link
Member

[merge][severity:bug]

1 similar comment
@spadgett
Copy link
Member

[merge][severity:bug]

@openshift-bot
Copy link

Evaluated for origin web console merge up to 381269a

@openshift-bot
Copy link

openshift-bot commented Sep 12, 2017

Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin_web_console/168/) (Base Commit: ca54bec) (PR Branch Commit: 381269a) (Extended Tests: bug)

@openshift-bot openshift-bot merged commit 5647d19 into openshift:master Sep 12, 2017
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.

Should warn when secret keys are not valid env var names
4 participants