-
Notifications
You must be signed in to change notification settings - Fork 231
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
Add/Edit env vars from secrets and config maps #1090
Conversation
@benjaminapetersen, @jwforres, I need an assist getting KVE running. I'm not receiving any errors, but the editor isn't rendering. Not sure how to troubleshoot. |
@rhamilto did you add the JS files to index.html? |
Thanks, @spadgett. I had overlooked the addition. |
@@ -286,6 +302,36 @@ | |||
} | |||
}); | |||
|
|||
var findReferenceValue = function(entry) { |
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.
Think its possible to break this one down a bit? There are a lot of return
s at various levels. Might be helpful to clarify (via function names) what is going on?
} | ||
}; | ||
console.log('configMapObj', configMapObj); | ||
entry.valueAlt = 'Set to the key ' + from.key + ' in config map <a ng-if="\'configMaps\' | canI : \'get\'" ng-href="{{configMapObj | navigateResourceURL}}">' + from.name + '</a>'; |
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.
@benjaminapetersen or @jwforres, this doesn't create a valid href, and I'm not sure why. Help?
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.
Looking into using $compile
to get the filters to render correctly.
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.
did a rough pass through
secretsArray.unshift(""); | ||
}); | ||
}); | ||
// TODO: make valueFromObjects properly |
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 you explain this TODO better for someone else looking at this later
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.
^ @benjaminapetersen, I'm thinking this comment can simply be deleted?
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.
agree... i don't think that has meaning anymore.
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.
Comment removed.
return _.isArray(input) ? | ||
input : | ||
_.map(input, function(value, key){ | ||
return {name: key, value: value}; |
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.
how is this handling valueFrom? same question in applicationGenerator
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.
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 just a switch for backwards compatibility.
- if it gets a hash, this is the "old way" that needs to transform into
[{name:'',value:''}, etc]
- If it gets an array, return the array (input arg). We've already
Off the top of my head I'm not sure why it received a hash of {'<name>': '<value>'}
to begin with.
@@ -112,6 +124,7 @@ angular.module('openshiftConsole') | |||
$scope.loaded = true; | |||
$scope.deployment = deployment; | |||
updateHPAWarnings(); | |||
EnvironmentService.toggleReadonlyForContainerEnvsValueFrom(_.get($scope.deployment, 'spec.template.spec.containers'), envSecretAndConfigMapAreReadonly); |
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 the purpose of all of these calls to toggleReadonly just to wait until secrets/configmaps are loaded before letting you touch the dropdowns? If so I want to discuss a different approach tomorrow. I'm not a fan of adding more gorp to the model data, I already don't like how much extra stuff we are adding that doesn't need to be getting sent to the server.
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.
Good word, gorp
. We have keyValueEditorUtils.cleanEntries()
setup to clean off all the gorp
& went through it pretty thoroughly to ensure we didn't miss anything. Agree its a bit clunky & i'd love to fix it. Thought about kve_
prefixing all the stuff we add so it would be easier to clean off, but there might be a better way.
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.
Other than the gorp, looking @ the toggle again per our discussion to see if we can clean up.
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.
We considered moving the DataService.list("secrets")
and DataService.list("configmaps")
into the directive & eliminating the controller noise... might be a good way to fix this.
@@ -10,6 +10,8 @@ angular.module("openshiftConsole") | |||
hookParams: "=model", | |||
availableVolumes: "=", | |||
availableContainers: "=", | |||
availableSecrets: "=", | |||
availableConfigmaps: "=", |
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.
availableConfigMaps
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.
Good catch. Fixed.
|
||
<div ng-if="(!entry.valueFrom)"> | ||
<input | ||
ng-if="(!entry.valueAlt)" |
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 ng-if still needed?
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.
Good catch. Fixed.
<span ng-switch-when="configMapKeyRef"> | ||
Set to the key {{entry.valueFrom.configMapKeyRef.key}} in config map | ||
<span | ||
ng-if="entry.isReadonlyValue"> |
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.
why is the appearance of the name as a link dependent on whether the value is readonly? shouldn't the appearance of the link depend on whether the user has rights to view secrets / view config maps using a canI check?
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.
We are using canI to check if the user has rights to view config maps or secrets, we're just using a single scope parameter (entry.isReadonlyValue) to track multiple conditions as this was easier than having multiple params. The thought being it was better to keep this logic in the controller and have one less key to clean off entry. Yea/nay?
- If the user can get config maps or secrets and the kve instance is NOT read only, we show the ui-selects for config maps and secrets.
- If the user can get config maps or secrets and the kve instance is read only, we show the faux input with the link.
- If the user can NOT get config maps or secrets and the kve instance is NOT read only, we show the faux input without the link.
- If the user can NOT get config maps or secrets and the kve instance is read only, we show the faux input without the link.
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.
Should we doc this somewhere? Comments @ the top of the directive for future reference?
<div ng-if="(!isReadonlyAny) && (!entry.isReadonlyValue)"> | ||
<div class="ui-select"> | ||
<ui-select ng-model="entry.selectedValueFrom" ng-required="true" on-select="valueFromObjectSelected(entry, $select.selected)"> | ||
<ui-select-match placeholder="Select config map or secret"> |
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.
we made the link configurable to support other options down the road, but then hardcoded this one into the editor. We made the list of objects generic to support other types, would this be better off as just "Select a resource" or something.
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.
Good point. Changed to "Select a resource"
No that is risky, you'll end up re-listing in some cases if the directive
gets re-created for any reason (like an ng-if changing state)
…On Fri, Feb 17, 2017 at 3:21 PM, Ben Petersen ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In app/scripts/controllers/deployment.js
<#1090 (comment)>
:
> @@ -112,6 +124,7 @@ angular.module('openshiftConsole')
$scope.loaded = true;
$scope.deployment = deployment;
updateHPAWarnings();
+ EnvironmentService.toggleReadonlyForContainerEnvsValueFrom(_.get($scope.deployment, 'spec.template.spec.containers'), envSecretAndConfigMapAreReadonly);
We considered moving the DataService.list("secrets") and
DataService.list("configmaps") into the directive & eliminating the
controller noise... might be a good way to fix this.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#1090 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABZk7ZqFWFjBescyMJ1bAJ2DHPaz5G-Xks5rdgFggaJpZM4LeT7a>
.
|
Yeah I definitely disagree with this approach. You are lumping together
multiple things onto an attribute that no longer means what the variable is
called. readonly is readonly, readonly doesn't mean don't let me have a
link to something.
Why is the canI check not right here in the view, you have everything you
need there already, you know exactly which type of resource is being
referenced. The whole point of us pulling in the KVE was to stop doing
hacky things to work around limitations of making stuff generic.
…On Wed, Feb 15, 2017 at 9:14 AM, Robb Hamilton ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In app/views/directives/key-value-editor.html
<#1090>:
> + <div ng-if="entry.valueFrom">
+ <div ng-if="isReadonlyAny || entry.isReadonlyValue" class="faux-input-group">
+ <span
+ class="faux-form-control-addon {{entry.valueIcon}}"
+ aria-hidden="true"
+ data-toggle="tooltip"
+ data-placement="top"
+ data-original-title="{{entry.valueIconTooltip || valueIconTooltip}}"
+ title="{{entry.valueIconTooltip || valueIconTooltip}}"></span>
+ <div
+ class="faux-form-control readonly">
+ <span ng-switch="entry.refType">
+ <span ng-switch-when="configMapKeyRef">
+ Set to the key {{entry.valueFrom.configMapKeyRef.key}} in config map
+ <span
+ ng-if="entry.isReadonlyValue">
We are using canI to check if the user has rights to view config maps or
secrets
<https://github.com/rhamilto/origin-web-console/blob/3940968a6e3e5ab3b881f396788b85236c5f746c/app/scripts/directives/keyValueEditor.js#L197-L198>,
we're just using a single scope parameter (entry.isReadonlyValue) to track
multiple conditions as this was easier than having multiple params. The
thought being it was better to keep this logic in the controller and have
one less key to clean off entry. Yea/nay?
1. If the user can get config maps or secrets and the kve instance is
NOT read only, we show the ui-selects for config maps and secrets.
[image: screen shot 2017-02-15 at 9 03 35 am]
<https://cloud.githubusercontent.com/assets/895728/22977689/b72ac5d8-f35d-11e6-8587-c951c7cd9917.PNG>
1. If the user can get config maps or secrets and the kve instance is
read only, we show the faux input with the link.
[image: screen shot 2017-02-15 at 9 03 46 am]
<https://cloud.githubusercontent.com/assets/895728/22977703/c39d5182-f35d-11e6-8fdc-c522c7b97fc7.PNG>
1. If the user can NOT get config maps or secrets and the kve instance
is NOT read only, we should the faux input without the link.
[image: screen shot 2017-02-15 at 9 11 42 am]
<https://cloud.githubusercontent.com/assets/895728/22977982/cf8ee996-f35e-11e6-81be-dccb91047541.PNG>
1. If the user can NOT get config maps or secrets and the kve instance
is read only, we should the faux input without the link.
[image: screen shot 2017-02-15 at 9 11 36 am]
<https://cloud.githubusercontent.com/assets/895728/22977990/d6fd22f6-f35e-11e6-9c78-151da84646df.PNG>
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#1090>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/ABZk7Qz447q6NPV-MPOrOUTcQ0CW_R_gks5rcwhEgaJpZM4LeT7a>
.
|
|
@jwforres I believe we did it to reduce template logic, we began in the view file but ended up branching/copy paste more than we liked. Doing the check up front simplified the branching. |
@jwforres |
role="button" | ||
aria-label="Add row" | ||
ng-click="onAddRow()">{{ addRowLink }}</a> | ||
<span |
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.
Moar simpler: a single span wrapping both the pipe and the link with ng-if="valueFromSelectorOptions.length"
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.
Moar simpler: a single span wrapping both the pipe and the link with ng-if="valueFromSelectorOptions.length"
Done.
<span ng-switch-when="secretKeyRef"> | ||
Set to the key {{entry.valueFrom.secretKeyRef.key}} in secret | ||
<span | ||
ng-if="entry.isReadonlyValue"> |
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.
canI is much clearer to anyone reading the template. Let's use it instead.
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.
canI is much clearer to anyone reading the template. Let's use it instead.
Done
@jwforres gonna jot down the flow here quick as well, with deployments as an example. It will explain the odd
Hopefully that makes sense... and moves along some discussion about simplifying if we can make it happen! |
data-toggle="tooltip" | ||
data-placement="top" | ||
data-original-title="{{entry.valueIconTooltip || valueIconTooltip}}" | ||
title="{{entry.valueIconTooltip || valueIconTooltip}}"></span> |
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.
while we are fixing things... can you remove the extra title attribute here, it is causing https://bugzilla.redhat.com/show_bug.cgi?id=1395079
[merge] |
1 similar comment
[merge] |
take three [merge] |
…values from config maps or secrets
- add valueFromSelectorOptions checks in kve to detect readonly state - add isValueFromEditable fn to clean up view - remove redundant title= attrs
[merge] |
1 similar comment
[merge] |
Evaluated for origin web console merge up to 7d79245 |
Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/1030/) (Base Commit: abb2505) |
TODOs: