Skip to content

Commit

Permalink
conditionally filter pre-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Feroze Mohideen committed Sep 19, 2023
1 parent ac4f7fc commit 2a69af1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const LogsTab: React.FC = () => {
appName={appName}
serviceNames={serviceNames}
deploymentTargetId={deploymentTargetId}
filterPredeploy={true}
/>
);
};
Expand Down
21 changes: 11 additions & 10 deletions dashboard/src/main/home/app-dashboard/validate-apply/logs/Logs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ import Container from "components/porter/Container";
import Button from "components/porter/Button";
import LogFilterContainer from "../../expanded-app/logs/LogFilterContainer";
import StyledLogs from "../../expanded-app/logs/StyledLogs";
import { AppRevision } from "lib/revisions/types";
import { useLatestRevisionNumber, useRevisionIdToNumber } from "lib/hooks/useRevisionList";
import { useLocation } from "react-router";
import { valueExists } from "shared/util";

type Props = {
projectId: number;
Expand All @@ -38,6 +36,7 @@ type Props = {
deploymentTargetId: string;
appRevisionId?: string;
logFilterNames?: LogFilterName[];
filterPredeploy?: boolean;
};

const Logs: React.FC<Props> = ({
Expand All @@ -48,6 +47,7 @@ const Logs: React.FC<Props> = ({
deploymentTargetId,
appRevisionId,
logFilterNames = ["service_name", "revision", "output_stream"],
filterPredeploy = false,
}) => {
const { search } = useLocation();
const queryParams = new URLSearchParams(search);
Expand Down Expand Up @@ -173,20 +173,21 @@ const Logs: React.FC<Props> = ({
}, 5000);
};

const { logs, refresh, moveCursor, paginationInfo } = useLogs(
projectId,
clusterId,
const { logs, refresh, moveCursor, paginationInfo } = useLogs({
projectID: projectId,
clusterID: clusterId,
selectedFilterValues,
appName,
selectedFilterValues.service_name,
serviceName: selectedFilterValues.service_name,
deploymentTargetId,
enteredSearchText,
searchParam: enteredSearchText,
notify,
setIsLoading,
setLoading: setIsLoading,
revisionIdToNumber,
selectedDate,
setDate: selectedDate,
appRevisionId,
);
filterPredeploy,
});

useEffect(() => {
setFilters([
Expand Down
23 changes: 20 additions & 3 deletions dashboard/src/main/home/app-dashboard/validate-apply/logs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,22 @@ export const parseLogs = (logs: any[] = []): PorterLog[] => {
});
};

export const useLogs = (
export const useLogs = ({
projectID,
clusterID,
selectedFilterValues,
appName,
serviceName,
deploymentTargetId,
searchParam,
notify,
setLoading,
revisionIdToNumber,
setDate,
appRevisionId = "",
timeRange,
filterPredeploy,
}: {
projectID: number,
clusterID: number,
selectedFilterValues: Record<LogFilterName, string>,
Expand All @@ -54,11 +69,13 @@ export const useLogs = (
revisionIdToNumber: Record<string, number>,
// if setDate is set, results are not live
setDate?: Date,
appRevisionId: string = "",
appRevisionId?: string,
timeRange?: {
startTime?: Dayjs,
endTime?: Dayjs,
},
filterPredeploy: boolean,
}
) => {
const isLive = !setDate;
const logsBufferRef = useRef<PorterLog[]>([]);
Expand Down Expand Up @@ -218,7 +235,7 @@ export const useLogs = (
return false;
}

if ((log.metadata.raw_labels?.porter_run_service_name ?? "").endsWith("predeploy")) {
if (filterPredeploy && (log.metadata.raw_labels?.porter_run_service_name ?? "").endsWith("predeploy")) {
return false;
}

Expand Down

0 comments on commit 2a69af1

Please sign in to comment.