mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-16 03:27:01 +02:00
* Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License. Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUS-1.1 * Fix test that expected exact offset on hcl file --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Co-authored-by: Sarah Thompson <sthompson@hashicorp.com> Co-authored-by: Brian Kassouf <bkassouf@hashicorp.com>
54 lines
1.8 KiB
JavaScript
54 lines
1.8 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';
|
|
import ApplicationSerializer from './application';
|
|
|
|
export default ApplicationSerializer.extend(EmbeddedRecordsMixin, {
|
|
attrs: {
|
|
versions: { embedded: 'always' },
|
|
},
|
|
secretDataPath: 'data',
|
|
normalizeItems(payload, requestType) {
|
|
if (payload.data.keys && Array.isArray(payload.data.keys)) {
|
|
// if we have data.keys, it's a list of ids, so we map over that
|
|
// and create objects with id's
|
|
return payload.data.keys.map((secret) => {
|
|
// secrets don't have an id in the response, so we need to concat the full
|
|
// path of the secret here - the id in the payload is added
|
|
// in the adapter after making the request
|
|
let fullSecretPath = payload.id ? payload.id + secret : secret;
|
|
|
|
// if there is no path, it's a "top level" secret, so add
|
|
// a unicode space for the id
|
|
// https://github.com/hashicorp/vault/issues/3348
|
|
if (!fullSecretPath) {
|
|
fullSecretPath = '\u0020';
|
|
}
|
|
return {
|
|
id: fullSecretPath,
|
|
engine_id: payload.backend,
|
|
};
|
|
});
|
|
}
|
|
// transform versions to an array with composite IDs
|
|
if (payload.data.versions) {
|
|
payload.data.versions = Object.keys(payload.data.versions).map((version) => {
|
|
const body = payload.data.versions[version];
|
|
body.version = version;
|
|
body.path = payload.id;
|
|
body.id = JSON.stringify([payload.backend, payload.id, version]);
|
|
return body;
|
|
});
|
|
}
|
|
payload.data.engine_id = payload.backend;
|
|
payload.data.id = payload.id;
|
|
return requestType === 'queryRecord' ? payload.data : [payload.data];
|
|
},
|
|
serializeHasMany() {
|
|
return;
|
|
},
|
|
});
|