vault/ui/app/models/aws/lease-config.js
Angel Garbarino a73a6983c4
Prep work for creating one WIF configuration component (#29345)
* initial things without helper changes

* adjust test for clean up of secret-engine-helper

* remove added line thats better in next pr

* remove extra check

* 🧹

* replace return with continue within loops
2025-01-10 14:06:42 -08:00

47 lines
1.3 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import Model, { attr } from '@ember-data/model';
import { expandAttributeMeta } from 'vault/utils/field-to-attrs';
import { withModelValidations } from 'vault/decorators/model-validations';
const validations = {
lease: [
{
validator(model) {
const { lease, leaseMax } = model;
return (lease && leaseMax) || (!lease && !leaseMax) ? true : false;
},
message: 'Lease TTL and Max Lease TTL are both required if one of them is set.',
},
],
};
@withModelValidations(validations)
export default class AwsLeaseConfig extends Model {
@attr('string') backend; // dynamic path of secret -- set on response from value passed to queryRecord
@attr({
label: 'Max Lease TTL',
editType: 'ttl',
})
leaseMax;
@attr({
label: 'Default Lease TTL',
editType: 'ttl',
})
lease;
configurableParams = ['lease', 'leaseMax'];
get displayAttrs() {
// while identical to formFields, keeping the same pattern as other configurable secret engines for consistency
// and to easily filter out displayAttributes in the future if needed
return this.formFields;
}
get formFields() {
return expandAttributeMeta(this, this.configurableParams);
}
}