Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} catch (e) {
this.setState({ triggering: false });
notify(`YAML Error: ${e.message}`, 'danger');
return;
}
const valid = validate(input);
if (!valid) {
this.setState({ triggering: false });
notify(ajv.errorsText(validate.errors), 'danger');
return;
}
}
TaskclusterModel.submit({
action,
actionTaskId: slugid(),
decisionTaskId,
taskId: originalTaskId,
task: originalTask,
input,
staticActionVariables,
currentRepo,
}).then(
taskId => {
this.setState({ triggering: false });
let message = 'Custom action request sent successfully:';
let url = tcLibUrls.ui(currentRepo.tc_root_url, `/tasks/${taskId}`);
// For the time being, we are redirecting specific actions to
// specific urls that are different than usual. At this time, we are
// only directing loaner tasks to the loaner UI in the tools site.
// It is possible that we may make this a part of the spec later.
return tcactions.load(decisionTaskId, $scope.job).then((results) => {
const actionTaskId = slugid();
if (results) {
const backfilltask = _.find(results.actions, { name: 'backfill' });
// We'll fall back to actions.yaml if this isn't true
if (backfilltask) {
return tcactions.submit({
action: backfilltask,
actionTaskId,
decisionTaskId,
taskId: results.originalTaskId,
task: results.originalTask,
input: {},
staticActionVariables: results.staticActionVariables,
}).then(function () {
$scope.$apply(thNotify.send(`Request sent to backfill job via actions.json (${actionTaskId})`, 'success'));
}, function (e) {
// The full message is too large to fit in a Treeherder
} catch (e) {
$scope.triggering = false;
thNotify.send(`YAML Error: ${e.message}`, 'danger');
return;
}
const valid = validate(input);
if (!valid) {
$scope.triggering = false;
thNotify.send(ajv.errorsText(validate.errors), 'danger');
return;
}
}
tcactions.submit({
action: $scope.input.selectedAction,
actionTaskId: slugid(),
decisionTaskId,
taskId: originalTaskId,
task: originalTask,
input,
staticActionVariables: $scope.staticActionVariables,
}).then(function (taskId) {
$scope.triggering = false;
let message = 'Custom action request sent successfully:';
let url = `https://tools.taskcluster.net/tasks/${taskId}`;
// For the time being, we are redirecting specific actions to
// specific urls that are different than usual. At this time, we are
// only directing loaner tasks to the loaner UI in the tools site.
// It is possible that we may make this a part of the spec later.
const loaners = ['docker-worker-linux-loaner', 'generic-worker-windows-loaner'];
if (loaners.indexOf($scope.input.selectedAction.name) !== -1) {
return taskclusterModel.load(decisionTaskId).then((results) => {
const actionTaskId = slugid();
// In this case we have actions.json tasks
if (results) {
const addjobstask = results.actions.find(action =>
action.name === 'add-new-jobs');
// We'll fall back to actions.yaml if this isn't true
if (addjobstask) {
return taskclusterModel.submit({
action: addjobstask,
actionTaskId,
decisionTaskId,
taskId: null,
task: null,
input: { tasks: tclabels },
staticActionVariables: results.staticActionVariables,
}).then(() => `Request sent to trigger new jobs via actions.json (${actionTaskId})`);
}
return taskclusterModel.load(decisionTaskId).then((results) => {
const actionTaskId = slugid();
// In this case we have actions.json tasks
if (results) {
const missingtask = results.actions.find(action =>
action.name === 'run-missing-tests');
// We'll fall back to actions.yaml if this isn't true
if (missingtask) {
return taskclusterModel.submit({
action: missingtask,
actionTaskId,
decisionTaskId,
taskId: null,
task: null,
input: {},
staticActionVariables: results.staticActionVariables,
}).then(() => `Request sent to trigger missing jobs via actions.json (${actionTaskId})`);
omit(
[
'taskGroupId',
'routes',
'dependencies',
'requires',
'scopes',
'payload'
],
cloneDeep(task)
),
{
retries: 0,
deadline: fromNowJSON('12 hours'),
created: fromNowJSON(),
expires: fromNowJSON('7 days'),
scopes: task.scopes.filter(scope => !/^docker-worker:cache:/.test(scope)), // Delete cache scopes
payload: merge(omit(['artifacts', 'cache'], task.payload || {}), {
maxRunTime: Math.max(
task.payload && task.payload.maxRunTime,
3 * 60 * 60
),
features: {
interactive: true
},
env: {
TASKCLUSTER_INTERACTIVE: 'true'
}
})
}
);
merge(
omit(
[
'taskGroupId',
'routes',
'dependencies',
'requires',
'scopes',
'payload'
],
cloneDeep(task)
),
{
retries: 0,
deadline: fromNowJSON('12 hours'),
created: fromNowJSON(),
expires: fromNowJSON('7 days'),
scopes: task.scopes.filter(scope => !/^docker-worker:cache:/.test(scope)), // Delete cache scopes
payload: merge(omit(['artifacts', 'cache'], task.payload || {}), {
maxRunTime: Math.max(
task.payload && task.payload.maxRunTime,
3 * 60 * 60
),
features: {
interactive: true
},
env: {
TASKCLUSTER_INTERACTIVE: 'true'
}
})
}
);
export const parameterizeTask = task =>
merge(
omit(
[
'taskGroupId',
'routes',
'dependencies',
'requires',
'scopes',
'payload'
],
cloneDeep(task)
),
{
retries: 0,
deadline: fromNowJSON('12 hours'),
created: fromNowJSON(),
expires: fromNowJSON('7 days'),
scopes: task.scopes.filter(scope => !/^docker-worker:cache:/.test(scope)), // Delete cache scopes
payload: merge(omit(['artifacts', 'cache'], task.payload || {}), {
maxRunTime: Math.max(
task.payload && task.payload.maxRunTime,
3 * 60 * 60
),
features: {
interactive: true
},
env: {
TASKCLUSTER_INTERACTIVE: 'true'
}
})
}
export function userSessionFromAuthResult(authResult) {
return UserSession.fromOIDC({
oidcProvider: process.env.OIDC_PROVIDER,
accessToken: authResult.accessToken,
fullName: authResult.idTokenPayload.nickname,
picture: authResult.idTokenPayload.picture,
oidcSubject: authResult.idTokenPayload.sub,
// per https://wiki.mozilla.org/Security/Guidelines/OpenID_connect#Session_handling
renewAfter: fromNow('15 minutes')
});
}
async loadSecret(props) {
// If there is a secretId, we load it. Otherwise we create a new secret
if (!props.secretId) {
const defaultSecret = { foo: 'bar' };
return this.setState({
secret: defaultSecret,
secretValue: safeDump(defaultSecret, safeDumpOpts),
expires: fromNow('1000 years'),
editing: true,
loading: false,
error: null
});
}
// indicate loading while the async secret fetch occurs
this.setState({
loading: true,
error: null
});
try {
const { secret, expires } = await props.secrets.get(props.secretId);
this.setState({