Skip to content

Commit 42acfa1

Browse files
Merge pull request #164 from vikram-raj/srvkp-6574
SRVKP-6574: Pass token to Results API
2 parents 91bb6ec + 86c1408 commit 42acfa1

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

src/components/utils/proxy.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { safeLoad } from 'js-yaml';
21
import { consoleFetchJSON } from '@openshift-console/dynamic-plugin-sdk';
2+
import { safeLoad } from 'js-yaml';
33

44
export const API_PROXY_URL = '/api/dev-console/proxy/internet';
55

6-
type ProxyRequest = {
6+
export type ProxyRequest = {
7+
allowAuthHeader?: boolean;
78
allowInsecure?: boolean;
89
method: string;
910
url: string;

src/components/utils/summary-api.ts

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const getResultsSummary = async (
2424
url,
2525
method: 'GET',
2626
allowInsecure: true,
27+
allowAuthHeader: true,
2728
});
2829

2930
return sData;

src/components/utils/tekton-results.ts

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
import {
3+
k8sGet,
34
K8sResourceCommon,
45
MatchExpression,
56
MatchLabels,
67
Selector,
7-
k8sGet,
88
} from '@openshift-console/dynamic-plugin-sdk';
99
import _ from 'lodash';
1010
import { RefObject, useEffect } from 'react';
@@ -16,7 +16,11 @@ import {
1616
import { RouteModel, TektonResultModel } from '../../models';
1717
import { PipelineRunKind, TaskRunKind } from '../../types';
1818
import { K8sResourceKind } from '../../types/openshift';
19-
import { consoleProxyFetch, consoleProxyFetchJSON } from './proxy';
19+
import {
20+
consoleProxyFetch,
21+
consoleProxyFetchJSON,
22+
ProxyRequest,
23+
} from './proxy';
2024

2125
// REST API spec
2226
// https://github.com/tektoncd/results/blob/main/docs/api/rest-api-spec.md
@@ -64,15 +68,6 @@ export type TektonResultsOptions = {
6468
groupBy?: string;
6569
};
6670

67-
type ProxyRequest = {
68-
allowInsecure?: boolean;
69-
method: string;
70-
url: string;
71-
headers?: Record<string, string[]>;
72-
queryparams?: Record<string, string[]>;
73-
body?: string;
74-
};
75-
7671
const throw404 = () => {
7772
// eslint-disable-next-line no-throw-literal
7873
throw { code: 404 };
@@ -335,6 +330,7 @@ export const getFilteredRecord = async <R extends K8sResourceCommon>(
335330
url,
336331
method: 'GET',
337332
allowInsecure: true,
333+
allowAuthHeader: true,
338334
});
339335
if (options?.limit >= 0) {
340336
list = {
@@ -490,7 +486,12 @@ export const getTaskRunLog = async (taskRunPath: string): Promise<string> => {
490486
'/records/',
491487
'/logs/',
492488
)}`;
493-
return consoleProxyFetchLog({ url, method: 'GET', allowInsecure: true });
489+
return consoleProxyFetchLog({
490+
url,
491+
method: 'GET',
492+
allowInsecure: true,
493+
allowAuthHeader: true,
494+
});
494495
};
495496

496497
export const useLoadMoreOnScroll = (

0 commit comments

Comments
 (0)