-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
UI add custom metadata to KV2 #12169
Conversation
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.
Preliminary comments because this review is gonna take a while 😅
ui/app/adapters/secret-engine.js
Outdated
}))(data); | ||
// remove extra params from data | ||
/*eslint no-unused-vars: ["error", { "ignoreRestSiblings": true }]*/ | ||
let { max_versions, delete_version_after, cas_required, ...newData } = data; |
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.
If any of these are undefined this will blow up, so we just need to make sure the serializer always returns those values even if they're falsey
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.
Maybe you could help me on this one. In my testing by trying to set all values to falsey I couldn't get it to blow up, but maybe I'm missing 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.
If there's no way for those to be undefined, we should be good! Just wanted to call that out as a thing to test with default values for example
ui/app/adapters/secret-engine.js
Outdated
// for kv2 we make two network requests | ||
if (data.type === 'kv' && data.options.version !== 1) { | ||
// data has both data for sys mount and the config, we need to separate them | ||
let configData = (({ max_versions, delete_version_after, cas_required }) => ({ |
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 wonder if we can pull out the splitting logic to a helper method so that we can reuse it in other areas (like update
) and it will be easier to catch errors and unit test there
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 idea. Let me work on that today.
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.
Okay, created a new helper called split-object
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.
Great work on this beast so far! 👏
}; | ||
// for validation, return array of path names already assigned | ||
if (Ember.testing) { | ||
this.secretPaths = ['beep', 'bop', 'boop']; |
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.
very curious why we need to hardcode this for testing 🤔
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.
In validation, we test for secret paths that already exist, and throw a validation if they do. This ensures the paths already exist. It also prevents us from hitting the adapter and getting an error in testing for making an adapter call that returns a 404.
if (isV2) { | ||
secret.set('id', key); | ||
} | ||
if (isV2 && Object.keys(secret.changedAttributes()).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.
I've run into unexpected behavior before by treating .length
as a boolean. Granted, usually it had to do with JSX but it may be safer to check > 0
if that's what you're aiming for
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 idea.
try { | ||
await model.save(); | ||
} catch (err) { | ||
// error |
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 don't want to do anything for error?
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 call, I added handling of the error.
@action | ||
onSaveChanges(event) { | ||
event.preventDefault(); | ||
this.save(); |
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 we're not awaiting this async method, it's possible that the method returns before save
finishes. Also, since save
ends with a transition I wonder if we even need the return after this line. Maybe return this.save()
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.
Good call. Amended.
</InfoTooltip> | ||
{{/if}} | ||
</label> | ||
{{#if true}} |
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.
do we need the if true
?
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. Amended.
<div class="box is-sideless is-fullwidth is-marginless is-paddingless"> | ||
<MessageError @model={{@modelForData}} @errorMessage={{this.error}} /> | ||
<NamespaceReminder @mode="edit" @noun="secret" /> | ||
{{#if (and (not @model.failedServerRead) (not @model.selectedVersion.failedServerRead) (not-eq @model.selectedVersion.version @model.currentVersion))}} |
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... so much template logic 🤯 Maybe we could pull that logic into the component js file?
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 idea. This was a carry-over of previous templating, but it looks a lot better inside the js file. Amended.
@@ -45,7 +45,7 @@ | |||
</button> | |||
</li> | |||
{{else}} | |||
{{#if @item.canRead}} | |||
{{#if (or @item.canReadSecretData @item.canRead)}} |
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.
Oh, so to confirm canReadSecretData
is for kvv2, canRead
is for kvv1
? (and so on with edit and delete)
await click('[data-test-secret-edit="true"]'); | ||
await editPage.save(); | ||
await settled(); | ||
await editPage.metadataTab(); | ||
await settled(); | ||
// convert to number for IE11 browserstack test |
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.
Honestly we should drop that test, we're not supporting IE11 anymore. But that's out of scope for 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.
Good call. I'll make a note in my test ticket.
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 PR adds custom metadata to the KV2 secret engine. It also adds the config endpoint when you're mounting the KV2 secret engine.
Here is a movie walk-through of the changes. API changes have been made on main (see PR here).
kv.mp4
TODOs that will happen in later PRs