Skip to content

Commit

Permalink
Merge pull request #44 from kubenav/fix-logs-modal
Browse files Browse the repository at this point in the history
Fix logs modal for valid json
  • Loading branch information
ricoberger committed Mar 5, 2020
2 parents 77f3b23 + f55b78d commit ee35016
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
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

0 comments on commit ee35016

Please sign in to comment.