Skip to content

Commit

Permalink
Merge pull request openshift-pipelines#74 from vikram-raj/switch-to-s…
Browse files Browse the repository at this point in the history
…ervice

OCPBUGS-29816: Switch to service from external result route endpoint
  • Loading branch information
openshift-merge-bot[bot] authored Feb 22, 2024
2 parents d1c1a0b + d08e4e0 commit 3295fe3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/components/utils/summary-api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { consoleProxyFetchJSON } from './proxy';
import { SummaryProps } from '../pipelines-overview/utils';
import { consoleProxyFetchJSON } from './proxy';
import {
TektonResultsOptions,
createTektonResultsSummaryUrl,
Expand Down
39 changes: 22 additions & 17 deletions src/components/utils/tekton-results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Selector,
k8sGet,
} from '@openshift-console/dynamic-plugin-sdk';
import { RouteModel, TektonResultModel } from '../../models';
import { TektonResultModel } from '../../models';
import { PipelineRunKind, TaskRunKind } from '../../types';
import { K8sResourceKind } from '../../types/openshift';
import { consoleProxyFetchJSON } from './proxy';
Expand Down Expand Up @@ -212,13 +212,17 @@ export const createTektonResultsUrl = async (
name: 'result',
});
const targetNamespace = tektonResult?.spec?.targetNamespace;
const route: K8sResourceKind = await k8sGet({
model: RouteModel,
name: 'tekton-results-api-service',
ns: targetNamespace,
});
const tektonResultUrl = route?.spec.host;
const URL = `https://${tektonResultUrl}/apis/results.tekton.dev/v1alpha2/parents/${namespace}/results/-/records?${new URLSearchParams(
const serverPort = tektonResult?.spec?.server_port ?? '8080';
const tlsHostname = tektonResult?.spec?.tls_hostname_override;
let tektonResultsAPI;
if (tlsHostname) {
tektonResultsAPI = `${tlsHostname}:${serverPort}`;
} else if (targetNamespace && serverPort) {
tektonResultsAPI = `tekton-results-api-service.${targetNamespace}.svc.cluster.local:${serverPort}`;
} else {
tektonResultsAPI = `tekton-results-api-service.openshift-pipelines.svc.cluster.local:${serverPort}`;
}
const URL = `https://${tektonResultsAPI}/apis/results.tekton.dev/v1alpha2/parents/${namespace}/results/-/records?${new URLSearchParams(
{
// default sort should always be by `create_time desc`
// order_by: 'create_time desc', not supported yet
Expand Down Expand Up @@ -371,16 +375,17 @@ export const createTektonResultsSummaryUrl = async (
name: 'result',
});
const targetNamespace = tektonResult?.spec?.targetNamespace;
const route: K8sResourceKind = await k8sGet({
model: RouteModel,
name: 'tekton-results-api-service',
ns: targetNamespace,
});
const tektonResultUrl = route?.spec.host;
if (!tektonResultUrl) {
throw new Error('route.spec.host is undefined');
const serverPort = tektonResult?.spec?.server_port ?? '8080';
const tlsHostname = tektonResult?.spec?.tls_hostname_override;
let tektonResultsAPI;
if (tlsHostname) {
tektonResultsAPI = `${tlsHostname}:${serverPort}`;
} else if (targetNamespace && serverPort) {
tektonResultsAPI = `tekton-results-api-service.${targetNamespace}.svc.cluster.local:${serverPort}`;
} else {
tektonResultsAPI = `tekton-results-api-service.openshift-pipelines.svc.cluster.local:${serverPort}`;
}
const URL = `https://${tektonResultUrl}/apis/results.tekton.dev/v1alpha2/parents/${namespace}/results/-/records/summary?${new URLSearchParams(
const URL = `https://${tektonResultsAPI}/apis/results.tekton.dev/v1alpha2/parents/${namespace}/results/-/records/summary?${new URLSearchParams(
{
summary: `${options?.summary}`,
...(options?.groupBy ? { group_by: `${options.groupBy}` } : {}),
Expand Down

0 comments on commit 3295fe3

Please sign in to comment.