From a80868b56227ec09ead9ed34b4562b352e16efa4 Mon Sep 17 00:00:00 2001 From: Vladimir Vagaytsev <10628074+vvagaytsev@users.noreply.github.com> Date: Wed, 20 Nov 2024 11:06:02 +0100 Subject: [PATCH] fix(k8s): respect pod selector in kubernetes-exec action type --- .../kubernetes/kubernetes-type/kubernetes-exec.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/src/plugins/kubernetes/kubernetes-type/kubernetes-exec.ts b/core/src/plugins/kubernetes/kubernetes-type/kubernetes-exec.ts index f6260c2252..0e2242ad79 100644 --- a/core/src/plugins/kubernetes/kubernetes-type/kubernetes-exec.ts +++ b/core/src/plugins/kubernetes/kubernetes-type/kubernetes-exec.ts @@ -18,13 +18,13 @@ import type { PluginContext } from "../../../plugin-context.js" import type { RunActionDefinition, TestActionDefinition } from "../../../plugin/action-types.js" import type { RunResult } from "../../../plugin/base.js" import { dedent } from "../../../util/string.js" -import { KubeApi, KubernetesError } from "../api.js" +import { KubernetesError } from "../api.js" import type { KubernetesPluginContext, KubernetesTargetResourceSpec } from "../config.js" import { namespaceNameSchema, runPodResourceSchema } from "../config.js" import { getActionNamespaceStatus } from "../namespace.js" import { k8sGetRunResult } from "../run-results.js" import type { SyncableResource } from "../types.js" -import { execInWorkload, readTargetResource } from "../util.js" +import { execInWorkload, getTargetResource } from "../util.js" import type { KubernetesRunOutputs } from "./config.js" import { kubernetesRunOutputsSchema } from "./config.js" @@ -35,6 +35,7 @@ export interface KubernetesExecRunActionSpec { command: string[] namespace?: string } + export type KubernetesExecRunActionConfig = RunActionConfig<"kubernetes-exec", KubernetesExecRunActionSpec> export type KubernetesExecRunAction = RunAction @@ -124,7 +125,6 @@ async function readAndExec({ const { resource, command } = action.getSpec() const k8sCtx = ctx const provider = k8sCtx.provider - const api = await KubeApi.factory(log, k8sCtx, provider) const namespaceStatus = await getActionNamespaceStatus({ ctx: k8sCtx, log, @@ -137,9 +137,11 @@ async function readAndExec({ let target: SyncableResource try { - target = await readTargetResource({ - api, - namespace, + target = await getTargetResource({ + ctx, + log, + provider, + action, query: resource, }) } catch (err) {