Skip to content

Commit

Permalink
Fixed duplicate path issue for kv engine (hashicorp#11423)
Browse files Browse the repository at this point in the history
- Ids used to collide in ember data while creating a secret with any existing
path name from a different kv engine
  • Loading branch information
arnav28 authored Apr 20, 2021
1 parent 7a6f777 commit 4905b8b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions ui/app/components/secret-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ export default Component.extend(FocusOnInsertMixin, WithNavToNearestAncestor, {
secretData.set(secretData.pathAttr, key);
}

if (this.mode === 'create') {
key = JSON.stringify({
backend: secret.backend,
id: key,
});
}

return secretData
.save()
.then(() => {
Expand Down Expand Up @@ -323,8 +330,14 @@ export default Component.extend(FocusOnInsertMixin, WithNavToNearestAncestor, {
return;
}

this.persistKey(() => {
this.transitionToRoute(SHOW_ROUTE, this.model.path || this.model.id);
this.persistKey(key => {
let secretKey;
try {
secretKey = JSON.parse(key).id;
} catch (error) {
secretKey = key;
}
this.transitionToRoute(SHOW_ROUTE, secretKey);
});
},

Expand Down

0 comments on commit 4905b8b

Please sign in to comment.