Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/*
* properties
*/
// ISO 8601 date + time string
creationDate: attr('date'),
// user name
name: attr('string'),
// array of users selections
// must be in same order as options property of poll
selections: fragmentArray('selection'),
// Croodle version user got created with
version: attr('string', {
encrypted: false
})
});
CLEAN: 'clean'
};
export default Model.extend({
created_at: attr(),
event_type: attr(),
result: attr(),
message: attr('string'),
headCommit: attr(),
baseCommit: attr(),
branchName: attr('string'),
pullRequestMergeable: attr('string'),
tagName: attr('string'),
pullRequest: attr('boolean'),
pullRequestTitle: attr('string'),
pullRequestNumber: attr('number'),
config: attr(),
raw_configs: attr(),
uniqRawConfigs: uniqBy('raw_configs', 'source'),
noYaml: empty('raw_configs'),
repo: belongsTo('repo', { async: true }),
commit: belongsTo('commit', { async: true }),
// API models this as hasMany but serializers:request#normalize overrides it
build: belongsTo('build', { async: true }),
isAccepted: computed('result', 'build.id', function () {
// For some reason some of the requests have a null result beside the fact that
// the build was created. We need to look into it, but for now we can just assume
// that if build was created, the request was accepted
let result = this.result;
get ExternalSources() {
const sources = this.items.reduce(function(prev, item) {
return prev.concat(item.ExternalSources || []);
}, []);
// unique, non-empty values, alpha sort
return [...new Set(sources)].filter(Boolean).sort();
}
};
export default class ServiceInstance extends Model {
@attr('string') uid;
@attr('string') Datacenter;
// ProxyInstance is the ember-data model relationship
@belongsTo('Proxy') ProxyInstance;
// Proxy is the actual JSON api response
@attr() Proxy;
@attr() Node;
@attr() Service;
@fragmentArray('health-check') Checks;
@attr('number') SyncTime;
@attr() meta;
@attr({ defaultValue: () => [] }) Resources; // []
// The name is the Name of the Service (the grouping of instances)
@alias('Service.Service') Name;
// If the ID is blank fallback to the Service.Service (the Name)
@or('Service.{ID,Service}') ID;
@or('Service.Address', 'Node.Service') Address;
@attr('string') SocketPath;
@equal('clientStatus', 'running') isRunning;
@attr('boolean') isMigrating;
@computed('clientStatus')
get isScheduled() {
return ['pending', 'running'].includes(this.clientStatus);
}
// An allocation model created from any allocation list response will be lacking
// many properties (some of which can always be null). This is an indicator that
// the allocation needs to be reloaded to get the complete allocation state.
@none('allocationTaskGroup') isPartial;
// When allocations are server-side rescheduled, a paper trail
// is left linking all reschedule attempts.
@belongsTo('allocation', { inverse: 'nextAllocation' }) previousAllocation;
@belongsTo('allocation', { inverse: 'previousAllocation' }) nextAllocation;
@hasMany('allocation', { inverse: 'preemptedByAllocation' }) preemptedAllocations;
@belongsTo('allocation', { inverse: 'preemptedAllocations' }) preemptedByAllocation;
@attr('boolean') wasPreempted;
@belongsTo('evaluation') followUpEvaluation;
@computed('clientStatus')
get statusClass() {
const classMap = {
pending: 'is-pending',
running: 'is-primary',
complete: 'is-complete',
failed: 'is-error',
lost: 'is-light',
event_type: attr(),
result: attr(),
message: attr('string'),
headCommit: attr(),
baseCommit: attr(),
branchName: attr('string'),
pullRequestMergeable: attr('string'),
tagName: attr('string'),
pullRequest: attr('boolean'),
pullRequestTitle: attr('string'),
pullRequestNumber: attr('number'),
config: attr(),
raw_configs: attr(),
uniqRawConfigs: uniqBy('raw_configs', 'source'),
noYaml: empty('raw_configs'),
repo: belongsTo('repo', { async: true }),
commit: belongsTo('commit', { async: true }),
// API models this as hasMany but serializers:request#normalize overrides it
build: belongsTo('build', { async: true }),
isAccepted: computed('result', 'build.id', function () {
// For some reason some of the requests have a null result beside the fact that
// the build was created. We need to look into it, but for now we can just assume
// that if build was created, the request was accepted
let result = this.result;
let buildId = this.get('build.id');
return result === 'approved' || buildId;
}),
features: service(),
logId: attr(),
queue: attr(),
state: attr(),
number: attr(),
allowFailure: attr('boolean'),
tags: attr(),
repositoryPrivate: attr(),
repositorySlug: attr(),
updatedAt: attr('date'),
_config: attr(),
repo: belongsTo('repo'),
build: belongsTo('build', { async: true }),
commit: belongsTo('commit', { async: true }),
stage: belongsTo('stage', { async: true }),
isPullRequest: alias('build.isPullRequest'),
pullRequestNumber: alias('build.pullRequestNumber'),
pullRequestTitle: alias('build.pullRequestTitle'),
branch: alias('build.branch'),
branchName: alias('build.branchName'),
isTag: alias('build.isTag'),
tag: alias('build.tag'),
eventType: alias('build.eventType'),
// TODO: DO NOT SET OTHER PROPERTIES WITHIN A COMPUTED PROPERTY!
log: computed(function () {
this.set('isLogAccessed', true);
return Log.create({
job: this,
api: this.api,
/* global Travis */
import Model, { attr, belongsTo } from '@ember-data/model';
import { observer, computed } from '@ember/object';
import { alias, and, equal, not, reads } from '@ember/object/computed';
import { inject as service } from '@ember/service';
import { isEqual } from '@ember/utils';
import { getOwner } from '@ember/application';
import Log from 'travis/models/log';
import DurationCalculations from 'travis/mixins/duration-calculations';
import DurationAttributes from 'travis/mixins/duration-attributes';
import promiseObject from 'travis/utils/promise-object';
export default Model.extend(DurationCalculations, DurationAttributes, {
api: service(),
jobConfigFetcher: service(),
features: service(),
logId: attr(),
queue: attr(),
state: attr(),
number: attr(),
allowFailure: attr('boolean'),
tags: attr(),
repositoryPrivate: attr(),
repositorySlug: attr(),
updatedAt: attr('date'),
_config: attr(),
repo: belongsTo('repo'),
build: belongsTo('build', { async: true }),
import Model, { attr } from '@ember-data/model';
import { computed } from '@ember/object';
import { apiPath } from 'vault/macros/lazy-capabilities';
import { expandAttributeMeta } from 'vault/utils/field-to-attrs';
import attachCapabilities from 'vault/lib/attach-capabilities';
const ModelExport = Model.extend({
// used for getting appropriate options for backend
idPrefix: 'role/',
// the id prefixed with `role/` so we can use it as the *secret param for the secret show route
idForNav: computed('id', 'idPrefix', function() {
let modelId = this.id || '';
return `${this.idPrefix}${modelId}`;
}),
name: attr('string', {
// TODO: make this required for making a transformation
label: 'Name',
fieldValue: 'id',
readOnly: true,
subText: 'The name for your role. This cannot be edited later.',
}),
transformations: attr('array', {
// eslint-disable-next-line ember/no-observers
import EmberObject, { computed, observer } from '@ember/object';
import Model, { attr, hasMany } from '@ember-data/model';
import { A } from '@ember/array';
import compact from 'lodash-es/compact';
export default Model.extend({
appendQueryString: attr(),
headersString: attr(),
httpBasicAuth: attr(),
requireHttps: attr(),
disableApiKey: attr(),
apiKeyVerificationLevel: attr(),
requiredRoles: attr(),
requiredRolesOverride: attr(),
allowedIps: attr(),
allowedReferers: attr(),
rateLimitMode: attr(),
anonymousRateLimitBehavior: attr(),
authenticatedRateLimitBehavior: attr(),
passApiKeyHeader: attr(),
passApiKeyQueryParam: attr(),
defaultResponseHeadersString: attr(),
@computed('clientStatus')
get isScheduled() {
return ['pending', 'running'].includes(this.clientStatus);
}
// An allocation model created from any allocation list response will be lacking
// many properties (some of which can always be null). This is an indicator that
// the allocation needs to be reloaded to get the complete allocation state.
@none('allocationTaskGroup') isPartial;
// When allocations are server-side rescheduled, a paper trail
// is left linking all reschedule attempts.
@belongsTo('allocation', { inverse: 'nextAllocation' }) previousAllocation;
@belongsTo('allocation', { inverse: 'previousAllocation' }) nextAllocation;
@hasMany('allocation', { inverse: 'preemptedByAllocation' }) preemptedAllocations;
@belongsTo('allocation', { inverse: 'preemptedAllocations' }) preemptedByAllocation;
@attr('boolean') wasPreempted;
@belongsTo('evaluation') followUpEvaluation;
@computed('clientStatus')
get statusClass() {
const classMap = {
pending: 'is-pending',
running: 'is-primary',
complete: 'is-complete',
failed: 'is-error',
lost: 'is-light',
};
return classMap[this.clientStatus] || 'is-dark';