Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ installCmd = installCmd.toCommand();
promoteCmd = promoteCmd.toCommand();

jest.mock('../../../helpers/helm');
jest.mock('../../../helpers/workflow');
jest.mock('../../../helpers/logs');
jest.spyOn(process, 'exit').mockImplementation();

const request = require('requestretry');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Command = require('../../../Command');
const { followLogs } = require('../../../helpers/workflow');
const { followLogs } = require('../../../helpers/logs');
const { sdk } = require('../../../../../logic');
const { normalizeValues, normalizeSetValues } = require('../../../helpers/helm');
const Output = require('../../../../../output/Output');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Command = require('../../../Command');
const { followLogs } = require('../../../helpers/workflow');
const { followLogs } = require('../../../helpers/logs');
const { sdk } = require('../../../../../logic');
const { normalizeValues, normalizeSetValues } = require('../../../helpers/helm');
const Output = require('../../../../../output/Output');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const Command = require('../../../Command');
const { sdk } = require('../../../../../logic');
const { followLogs } = require('../../../helpers/workflow');
const { followLogs } = require('../../../helpers/logs');
const Output = require('../../../../../output/Output');

const install = new Command({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ deleteCmd = deleteCmd.toCommand();
testCmd = testCmd.toCommand();

jest.mock('../../../helpers/helm');
jest.mock('../../../helpers/workflow');
jest.mock('../../../helpers/logs');
jest.spyOn(process, 'exit').mockImplementation();

const request = require('requestretry');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Command = require('../../../Command');
const { followLogs } = require('../../../helpers/workflow');
const { followLogs } = require('../../../helpers/logs');
const { sdk } = require('../../../../../logic');
const Output = require('../../../../../output/Output');

Expand Down
2 changes: 1 addition & 1 deletion lib/interface/cli/commands/pipeline/run.cf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const RunBaseCommand = require('./run.base');
const { sdk } = require('../../../../logic');
const { followLogs } = require('../../helpers/workflow');
const { followLogs } = require('../../helpers/logs');

function _buildBody(data) {
const body = {
Expand Down
2 changes: 1 addition & 1 deletion lib/interface/cli/commands/pipeline/run.local.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const path = require('path');
const DEFAULTS = require('../../defaults');
const _ = require('lodash');
const { sdk } = require('../../../../logic');
const { followLogs } = require('../../helpers/workflow');
const { followLogs } = require('../../helpers/logs');
const chalk = require('chalk');

const regex = /##[0-9a-f]{24}##/i;
Expand Down
2 changes: 1 addition & 1 deletion lib/interface/cli/commands/workflow/restart.cmd.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Command = require('../../Command');
const { followLogs } = require('../../helpers/workflow');
const { followLogs } = require('../../helpers/logs');
const { sdk } = require('../../../../logic');

const restart = new Command({
Expand Down
2 changes: 1 addition & 1 deletion lib/interface/cli/commands/workflow/workflow.sdk.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jest.mock('../../../../logic/entities/Workflow', () => {
fromResponse: res => res,
};
});
jest.mock('../../helpers/workflow');
jest.mock('../../helpers/logs');

const request = require('requestretry');

Expand Down
4 changes: 2 additions & 2 deletions lib/interface/cli/helpers/helpers.sdk.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { Config } = require('codefresh-sdk');

const { normalizeValues } = require('./helm');
const { validatePipelineSpec, validatePipelineYaml } = require('./validation');
const { followLogs } = require('./workflow');
const { followLogs } = require('./logs');
const { printTableForAuthContexts } = require('./auth');
const { sdk } = require('../../../logic');

Expand Down Expand Up @@ -56,7 +56,7 @@ describe('helpers using sdk', () => {
});
});

describe('workflow', () => {
describe('logs', () => {
it('should handle showing logs', async () => {
const workflowId = 'id';
jest.spyOn(process, 'exit').mockImplementation();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const Promise = require('bluebird');
const _ = require('lodash');
const request = require('requestretry');
const CFError = require('cf-errors');

const { sdk } = require('../../../logic');
const Workflow = require('../../../logic/entities/Workflow');
const Output = require('../../../output/Output');

const END_STATUSES = ['error', 'success', 'terminated'];

Expand All @@ -15,7 +17,10 @@ async function _fallbackLogs(workflowId, interval, retriesLeft) {
await sdk.logs.showWorkflowLogs(workflowId, true);
return;
} catch (e) {
console.log(`Could not retrieve logs due to error: ${e.message}`);
Output.printError(new CFError({
message: `Could not retrieve logs for workflow: ${workflowId}`,
cause: e,
}));
}

let failedToGetStatus = false;
Expand Down Expand Up @@ -51,10 +56,15 @@ const followLogs = async (workflowId) => {
try {
await sdk.logs.showWorkflowLogs(workflowId, true);
} catch (e) {
const error = new CFError({
message: `Could not retrieve logs for workflow: ${workflowId}`,
cause: e,
});
if (!process.env.CF_CLI_RUN_WAIT_FALLBACK) {
throw e;
throw error;
} else {
Output.printError(error);
}
console.log(`Could not retrieve logs due to error: ${e.message}`);
await _fallbackLogs(workflowId, config.logs.fallback.interval, config.logs.fallback.maxAttempts);
}
const json = await sdk.workflows.get({ id: workflowId });
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codefresh",
"version": "0.17.10",
"version": "0.17.11",
"description": "Codefresh command line utility",
"main": "index.js",
"preferGlobal": true,
Expand Down