Skip to content
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

Updates/removes dependencies throwing errors in Ember 4.4 #17396

Merged
merged 16 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175,346 changes: 175,346 additions & 0 deletions ui/.yarn/releases/yarn-1.22.19.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions ui/.yarnrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# yarn lockfile v1


lastUpdateCheck 1572032507422
yarn-path ".yarn/releases/yarn-1.19.1.js"
lastUpdateCheck 1664829239911
yarn-path ".yarn/releases/yarn-1.22.19.js"
Comment on lines +5 to +6
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After updating ember-data to 4.5 an error was thrown stating that the yarn version was too old and the build failed. I ran yarn policies set-version 1.22.19 as per the readme to update the embedded yarn version to the latest.

6 changes: 5 additions & 1 deletion ui/app/adapters/auth-method.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default ApplicationAdapter.extend({
return path ? url + '/' + encodePath(path) : url;
},

// used in updateRecord on the model#tune action
// used in updateRecord
pathForType() {
return 'mounts/auth';
},
Expand Down Expand Up @@ -61,4 +61,8 @@ export default ApplicationAdapter.extend({
exchangeOIDC(path, state, code) {
return this.ajax(`/v1/auth/${encodePath(path)}/oidc/callback`, 'GET', { data: { state, code } });
},

tune(path, data) {
return this.ajax(`${this.url(path)}tune`, 'POST', { data });
},
zofskeez marked this conversation as resolved.
Show resolved Hide resolved
});
1 change: 1 addition & 0 deletions ui/app/adapters/secret-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default ApplicationAdapter.extend({
let data = serializer.serialize(snapshot);
const path = snapshot.attr('path');
// for kv2 we make two network requests
data.config.id = path; // config relationship needs an id so use path for now
if (data.type === 'kv' && data.options.version === 2) {
// data has both data for sys mount and the config, we need to separate them
let splitObjects = splitObject(data, ['max_versions', 'delete_version_after', 'cas_required']);
Expand Down
1 change: 1 addition & 0 deletions ui/app/components/mount-backend-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default class MountBackendForm extends Component {
const type = this.args.mountType || 'auth';
const modelType = type === 'secret' ? 'secret-engine' : 'auth-method';
const model = this.store.createRecord(modelType);
model.set('config', this.store.createRecord('mount-config'));
this.mountModel = model;
}

Expand Down
4 changes: 1 addition & 3 deletions ui/app/controllers/vault/cluster/access/mfa/methods.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import Controller from '@ember/controller';

export default class MfaMethodsListController extends Controller {
queryParams = {
page: 'page',
};
zofskeez marked this conversation as resolved.
Show resolved Hide resolved
queryParams = ['page'];

page = 1;
}
23 changes: 14 additions & 9 deletions ui/app/models/auth-method.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import Model, { hasMany, attr } from '@ember-data/model';
import Model, { belongsTo, hasMany, attr } from '@ember-data/model';
import { alias } from '@ember/object/computed'; // eslint-disable-line
import { computed } from '@ember/object'; // eslint-disable-line
import { fragment } from 'ember-data-model-fragments/attributes';
import { inject as service } from '@ember/service';
import fieldToAttrs, { expandAttributeMeta } from 'vault/utils/field-to-attrs';
import { memberAction } from 'ember-api-actions';
import apiPath from 'vault/utils/api-path';
import attachCapabilities from 'vault/lib/attach-capabilities';
import { withModelValidations } from 'vault/decorators/model-validations';
Expand All @@ -17,6 +16,9 @@ const validations = {
@withModelValidations(validations)
class AuthMethodModel extends Model {}
const ModelExport = AuthMethodModel.extend({
store: service(),

config: belongsTo('mount-config', { async: false, inverse: null }), // one-to-none that replaces former fragment
authConfigs: hasMany('auth-config', { polymorphic: true, inverse: 'backend', async: false }),
path: attr('string'),
accessor: attr('string'),
Expand All @@ -30,7 +32,6 @@ const ModelExport = AuthMethodModel.extend({
description: attr('string', {
editType: 'textarea',
}),
config: fragment('mount-config', { defaultValue: {} }),
local: attr('boolean', {
helpText:
'When Replication is enabled, a local mount will not be replicated across clusters. This can only be specified at mount time.',
Expand Down Expand Up @@ -68,11 +69,11 @@ const ModelExport = AuthMethodModel.extend({
}),

// sys/mounts/auth/[auth-path]/tune.
tune: memberAction({
path: 'tune',
type: 'post',
urlType: 'updateRecord',
}),
// tune: memberAction({
// path: 'tune',
// type: 'post',
// urlType: 'updateRecord',
// }),

formFields: computed(function () {
return [
Expand Down Expand Up @@ -110,6 +111,10 @@ const ModelExport = AuthMethodModel.extend({
}),
canDisable: alias('deletePath.canDelete'),
canEdit: alias('configPath.canUpdate'),

tune(data) {
return this.store.adapterFor('auth-method').tune(this.path, data);
},
zofskeez marked this conversation as resolved.
Show resolved Hide resolved
});

export default attachCapabilities(ModelExport, {
Expand Down
9 changes: 4 additions & 5 deletions ui/app/models/cluster.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import Model, { attr, hasMany } from '@ember-data/model';
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';
import { inject as service } from '@ember/service';
import { alias, and, equal, gte, not, or } from '@ember/object/computed';
import { get, computed } from '@ember/object';
import { fragment } from 'ember-data-model-fragments/attributes';

export default Model.extend({
version: service(),
Expand Down Expand Up @@ -53,10 +52,10 @@ export default Model.extend({
allReplicationDisabled: and('{dr,performance}.replicationDisabled'),
anyReplicationEnabled: or('{dr,performance}.replicationEnabled'),

dr: fragment('replication-attributes'),
performance: fragment('replication-attributes'),
dr: belongsTo('replication-attributes', { async: false, inverse: null }),
performance: belongsTo('replication-attributes', { async: false, inverse: null }),
// this service exposes what mode the UI is currently viewing
// replicationAttrs will then return the relevant `replication-attributes` fragment
// replicationAttrs will then return the relevant `replication-attributes` model
rm: service('replication-mode'),
drMode: alias('dr.mode'),
replicationMode: alias('rm.mode'),
Expand Down
48 changes: 30 additions & 18 deletions ui/app/models/mount-config.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,53 @@
import { attr } from '@ember-data/model';
import Fragment from 'ember-data-model-fragments/fragment';
import Model, { attr } from '@ember-data/model';

export default Fragment.extend({
defaultLeaseTtl: attr({
export default class MountConfigModel extends Model {
@attr({
label: 'Default Lease TTL',
editType: 'ttl',
}),
maxLeaseTtl: attr({
})
defaultLeaseTtl;

@attr({
label: 'Max Lease TTL',
editType: 'ttl',
}),
auditNonHmacRequestKeys: attr({
})
maxLeaseTtl;

@attr({
label: 'Request keys excluded from HMACing in audit',
editType: 'stringArray',
helpText: "Keys that will not be HMAC'd by audit devices in the request data object.",
}),
auditNonHmacResponseKeys: attr({
})
auditNonHmacRequestKeys;

@attr({
label: 'Response keys excluded from HMACing in audit',
editType: 'stringArray',
helpText: "Keys that will not be HMAC'd by audit devices in the response data object.",
}),
listingVisibility: attr('string', {
})
auditNonHmacResponseKeys;

@attr('string', {
editType: 'boolean',
label: 'List method when unauthenticated',
trueValue: 'unauth',
falseValue: 'hidden',
}),
passthroughRequestHeaders: attr({
})
listingVisibility;

@attr({
label: 'Allowed passthrough request headers',
helpText: 'Headers to whitelist and pass from the request to the backend',
editType: 'stringArray',
}),
tokenType: attr('string', {
})
passthroughRequestHeaders;

@attr('string', {
label: 'Token Type',
helpText:
"The type of token that should be generated via this role. Can be `service`, `batch`, or `default` to use the mount's default (which unless changed will be `service` tokens).",
possibleValues: ['default', 'batch', 'service'],
defaultFormValue: 'default',
}),
});
})
tokenType;
}
13 changes: 0 additions & 13 deletions ui/app/models/mount-options.js

This file was deleted.

5 changes: 2 additions & 3 deletions ui/app/models/replication-attributes.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import Model, { attr } from '@ember-data/model';
import { match, not } from '@ember/object/computed';
import { computed } from '@ember/object';
import { attr } from '@ember-data/model';
import Fragment from 'ember-data-model-fragments/fragment';

export default Fragment.extend({
export default Model.extend({
clusterId: attr('string'),
clusterIdDisplay: computed('clusterId', 'mode', function () {
const clusterId = this.clusterId;
Expand Down
29 changes: 17 additions & 12 deletions ui/app/models/secret-engine.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Model, { attr } from '@ember-data/model';
import Model, { attr, belongsTo } from '@ember-data/model';
import { computed } from '@ember/object'; // eslint-disable-line
import { equal } from '@ember/object/computed'; // eslint-disable-line
import { fragment } from 'ember-data-model-fragments/attributes';
import fieldToAttrs, { expandAttributeMeta } from 'vault/utils/field-to-attrs';
import { withModelValidations } from 'vault/decorators/model-validations';

Expand Down Expand Up @@ -29,8 +28,16 @@ export default SecretEngineModel.extend({
description: attr('string', {
editType: 'textarea',
}),
config: fragment('mount-config', { defaultValue: {} }),
options: fragment('mount-options', { defaultValue: {} }),
// will only have value for kv type
version: attr('number', {
label: 'Version',
helpText:
'The KV Secrets Engine can operate in different modes. Version 1 is the original generic Secrets Engine the allows for storing of static key/value pairs. Version 2 added more features including data versioning, TTLs, and check and set.',
possibleValues: [2, 1],
// This shouldn't be defaultValue because if no version comes back from API we should assume it's v1
defaultFormValue: 2, // Set the form to 2 by default
}),
zofskeez marked this conversation as resolved.
Show resolved Hide resolved
config: belongsTo('mount-config', { async: false, inverse: null }),
local: attr('boolean', {
helpText:
'When Replication is enabled, a local mount will not be replicated across clusters. This can only be specified at mount time.',
Expand Down Expand Up @@ -60,30 +67,28 @@ export default SecretEngineModel.extend({
helperTextEnabled: 'Delete all new versions of this secret after',
}),

modelTypeForKV: computed('engineType', 'options.version', function () {
modelTypeForKV: computed('engineType', 'version', function () {
let type = this.engineType;
let version = this.options?.version;
let modelType = 'secret';
if ((type === 'kv' || type === 'generic') && version === 2) {
if ((type === 'kv' || type === 'generic') && this.version === 2) {
modelType = 'secret-v2';
}
return modelType;
}),

isV2KV: equal('modelTypeForKV', 'secret-v2'),

formFields: computed('engineType', 'options.version', function () {
formFields: computed('engineType', 'version', function () {
let type = this.engineType;
let version = this.options?.version;
let fields = ['type', 'path', 'description', 'accessor', 'local', 'sealWrap'];
// no ttl options for keymgmt
const ttl = type !== 'keymgmt' ? 'defaultLeaseTtl,maxLeaseTtl,' : '';
fields.push(`config.{${ttl}auditNonHmacRequestKeys,auditNonHmacResponseKeys,passthroughRequestHeaders}`);
zofskeez marked this conversation as resolved.
Show resolved Hide resolved
if (type === 'kv' || type === 'generic') {
fields.push('options.{version}');
fields.push('version');
}
// version comes in as number not string
if (type === 'kv' && version === 2) {
if (type === 'kv' && this.version === 2) {
fields.push('casRequired', 'deleteVersionAfter', 'maxVersions');
}
return fields;
Expand All @@ -108,7 +113,7 @@ export default SecretEngineModel.extend({
);

if (type === 'kv' || type === 'generic') {
optionsGroup['Method Options'].unshift('options.{version}');
optionsGroup['Method Options'].unshift('version');
}
if (type === 'database') {
// For the Database Secret Engine we want to highlight the defaultLeaseTtl and maxLeaseTtl, removing them from the options object
Expand Down
4 changes: 2 additions & 2 deletions ui/app/models/test-form-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
//

import AuthMethodModel from './auth-method';
import { fragment } from 'ember-data-model-fragments/attributes';
import { belongsTo } from '@ember-data/model';

export default AuthMethodModel.extend({
otherConfig: fragment('mount-config', { defaultValue: {} }),
otherConfig: belongsTo('mount-config', { async: false, inverse: null }),
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import UnloadModelRoute from 'vault/mixins/unload-model-route';
export default Route.extend(UnloadModelRoute, {
modelPath: 'model.model',
pathHelp: service('path-help'),
store: service(),

modelType(backendType, section) {
// TODO: Update endpoints from PR#10997
Expand Down
2 changes: 2 additions & 0 deletions ui/app/routes/vault/cluster/settings/mount-secret-backend.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import Route from '@ember/routing/route';
import UnloadModelRoute from 'vault/mixins/unload-model-route';
import UnsavedModelRoute from 'vault/mixins/unsaved-model-route';
import { inject as service } from '@ember/service';

export default Route.extend(UnloadModelRoute, UnsavedModelRoute, {
store: service(),
// intentionally blank - we don't want a model until one is
// created via the form in the controller
model() {
Expand Down
14 changes: 13 additions & 1 deletion ui/app/serializers/auth-method.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
import ApplicationSerializer from './application';
import { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';

export default ApplicationSerializer.extend({
export default ApplicationSerializer.extend(EmbeddedRecordsMixin, {
attrs: {
config: { embedded: 'always' },
},
normalize(modelClass, data) {
// embedded records need a unique value to be stored
// use the uuid from the auth-method as the unique id for mount-config
if (data.config) {
data.config.id = data.uuid;
}
return this._super(modelClass, data);
},
normalizeBackend(path, backend) {
let struct = { ...backend };
// strip the trailing slash off of the path so we
Expand Down
19 changes: 19 additions & 0 deletions ui/app/serializers/cluster.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';
import { assign } from '@ember/polyfills';
import { decamelize } from '@ember/string';
import IdentityManager from '../utils/identity-manager';

const uuids = new IdentityManager();
Comment on lines +4 to +6
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was running into an issue where cluster_id was not defined and the replication attributes need a unique id or the store will throw an error so I adapted the mirage identity manager into a utility and use it here.


export default RESTSerializer.extend(EmbeddedRecordsMixin, {
keyForAttribute: function (attr) {
Expand All @@ -9,6 +12,22 @@ export default RESTSerializer.extend(EmbeddedRecordsMixin, {

attrs: {
nodes: { embedded: 'always' },
dr: { embedded: 'always' },
performance: { embedded: 'always' },
},

setReplicationId(data) {
if (data) {
data.id = data.cluster_id || uuids.fetch();
}
},

normalize(modelClass, data) {
// embedded records need a unique value to be stored
// set id for dr and performance to cluster_id or random unique id
this.setReplicationId(data.dr);
this.setReplicationId(data.performance);
return this._super(modelClass, data);
},

pushPayload(store, payload) {
Expand Down
Loading