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

Fix logs modal for valid json #44

Merged
merged 1 commit into from
Mar 5, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { formatResourceValue } from '../../../../../utils/helpers';
import Editor from '../../../../misc/Editor';
import IonCardEqualHeight from '../../../../misc/IonCardEqualHeight';
import Row from '../../template/Row';
import Logs from '../Logs';
import Logs from './Logs';

// getState returns the current state of the given container. This is used for the list view for init containers and
// containers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import {
import { close, ellipsisHorizontal, ellipsisVertical, list } from 'ionicons/icons';
import React, { useContext, useEffect, useState } from 'react';

import { IContext, TActivator } from '../../../../declarations';
import { AppContext } from '../../../../utils/context';
import Editor from '../../../misc/Editor';
import { IContext, TActivator } from '../../../../../declarations';
import { AppContext } from '../../../../../utils/context';
import Editor from '../../../../misc/Editor';

const TAIL_LINES = 1000;

Expand Down Expand Up @@ -66,8 +66,10 @@ const Logs: React.FunctionComponent<ILogsProps> = ({ activator, name, namespace,
parameters = `${parameters}&tailLines=${tailLines}`;
}

// It is possible that the returned log only contains one line with valid json. This gets parsed by the requests
// function and so an object instead of a string is returned. In this case we have to revert the parsing.
const data: any = await context.request('GET', `/api/v1/namespaces/${namespace}/pods/${name}/log?${parameters}`, '');
setLogs(data);
setLogs(typeof data === 'string' ? data : JSON.stringify(data));
} catch (err) {
setError(err);
}
Expand Down