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

Add missing API root for external logs requests #3614

Merged
merged 1 commit into from
Sep 16, 2024
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
2 changes: 1 addition & 1 deletion src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export function getExternalLogURL({
if (queryString) {
queryString = `?${queryString}`;
}
return `${externalLogsURL}/${namespace}/${podName}/${container}${queryString}`;
return `${getAPIRoot({ isDashboardAPI: true })}${externalLogsURL}/${namespace}/${podName}/${container}${queryString}`;
}

export function getPodLogURL({ container, name, namespace, follow }) {
Expand Down
14 changes: 8 additions & 6 deletions src/api/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ it('useEvents', async () => {

it('getExternalLogURL', () => {
const container = 'fake_container';
const externalLogsURL = 'fake_externalLogsURL';
const externalLogsURL = '/fake_externalLogsURL';
const namespace = 'fake_namespace';
const podName = 'fake_podName';
const startTime = '2000-01-02T03:04:05Z';
Expand All @@ -171,7 +171,7 @@ it('getExternalLogURL', () => {
startTime
})
).toEqual(
`${externalLogsURL}/${namespace}/${podName}/${container}?startTime=${startTime.replaceAll(
`http://localhost:3000${externalLogsURL}/${namespace}/${podName}/${container}?startTime=${startTime.replaceAll(
':',
'%3A'
)}&completionTime=${completionTime.replaceAll(':', '%3A')}`
Expand All @@ -180,7 +180,7 @@ it('getExternalLogURL', () => {

it('getExternalLogURL with empty completionTime', () => {
const container = 'fake_container';
const externalLogsURL = 'fake_externalLogsURL';
const externalLogsURL = '/fake_externalLogsURL';
const namespace = 'fake_namespace';
const podName = 'fake_podName';
const startTime = '2000-01-02T03:04:05Z';
Expand All @@ -193,7 +193,7 @@ it('getExternalLogURL with empty completionTime', () => {
startTime
})
).toEqual(
`${externalLogsURL}/${namespace}/${podName}/${container}?startTime=${startTime.replaceAll(
`http://localhost:3000${externalLogsURL}/${namespace}/${podName}/${container}?startTime=${startTime.replaceAll(
':',
'%3A'
)}`
Expand All @@ -202,12 +202,14 @@ it('getExternalLogURL with empty completionTime', () => {

it('getExternalLogURL with empty startTime and completionTime', () => {
const container = 'fake_container';
const externalLogsURL = 'fake_externalLogsURL';
const externalLogsURL = '/fake_externalLogsURL';
const namespace = 'fake_namespace';
const podName = 'fake_podName';
expect(
API.getExternalLogURL({ container, externalLogsURL, namespace, podName })
).toEqual(`${externalLogsURL}/${namespace}/${podName}/${container}`);
).toEqual(
`http://localhost:3000${externalLogsURL}/${namespace}/${podName}/${container}`
);
});

it('getPodLog', () => {
Expand Down
8 changes: 4 additions & 4 deletions src/utils/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe('fetchLogsFallback', () => {

it('should return a function to retrieve logs from the external provider', () => {
const container = 'fake_container';
const externalLogsURL = 'fake_url';
const externalLogsURL = '/fake_url';
const namespace = 'fake_namespace';
const podName = 'fake_podName';
const stepName = 'fake_stepName';
Expand All @@ -149,7 +149,7 @@ describe('fetchLogsFallback', () => {
const fallback = fetchLogsFallback(externalLogsURL);
fallback(stepName, stepStatus, taskRun);
expect(comms.get).toHaveBeenCalledWith(
`${externalLogsURL}/${namespace}/${podName}/${container}?startTime=${startTime.replaceAll(
`http://localhost:3000${externalLogsURL}/${namespace}/${podName}/${container}?startTime=${startTime.replaceAll(
':',
'%3A'
)}&completionTime=${completionTime.replaceAll(':', '%3A')}`,
Expand All @@ -159,7 +159,7 @@ describe('fetchLogsFallback', () => {

it('should handle a missing startTime and completionTime', () => {
const container = 'fake_container';
const externalLogsURL = 'fake_url';
const externalLogsURL = '/fake_url';
const namespace = 'fake_namespace';
const podName = 'fake_podName';
const stepName = 'fake_stepName';
Expand All @@ -170,7 +170,7 @@ describe('fetchLogsFallback', () => {
const fallback = fetchLogsFallback(externalLogsURL);
fallback(stepName, stepStatus, taskRun);
expect(comms.get).toHaveBeenCalledWith(
`${externalLogsURL}/${namespace}/${podName}/${container}`,
`http://localhost:3000${externalLogsURL}/${namespace}/${podName}/${container}`,
{ Accept: 'text/plain' }
);
});
Expand Down
Loading