Skip to content

Commit

Permalink
refactor: make timeout nonnullable in KubernetesTypeCommonDeploySpec
Browse files Browse the repository at this point in the history
  • Loading branch information
vvagaytsev committed May 5, 2023
1 parent b4fa61a commit 0f2c3d2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/src/plugins/kubernetes/kubernetes-type/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export interface KubernetesTypeCommonDeploySpec {
manifests: KubernetesResource[]
namespace?: string
portForwards?: PortForwardSpec[]
timeout?: number
timeout: number
}

export interface KubernetesDeployActionSpec extends KubernetesTypeCommonDeploySpec {
Expand Down
7 changes: 4 additions & 3 deletions core/src/plugins/kubernetes/kubernetes-type/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { gardenAnnotationKey } from "../../../util/string"
import { KubeApi } from "../api"
import type { KubernetesPluginContext } from "../config"
import { configureSyncMode, convertKubernetesModuleDevModeSpec } from "../sync"
import { apply, deleteObjectsBySelector, KUBECTL_DEFAULT_TIMEOUT } from "../kubectl"
import { apply, deleteObjectsBySelector } from "../kubectl"
import { streamK8sLogs } from "../logs"
import { getActionNamespace, getActionNamespaceStatus } from "../namespace"
import { getForwardablePorts, killPortForwards } from "../port-forward"
Expand Down Expand Up @@ -65,6 +65,7 @@ export const kubernetesHandlers: Partial<ModuleActionHandlers<KubernetesModule>>
files,
manifests,
sync: convertKubernetesModuleDevModeSpec(module, service, serviceResource),
timeout: service.spec.timeout,
},
}

Expand Down Expand Up @@ -251,7 +252,7 @@ export const kubernetesDeploy: DeployActionHandler<"deploy", KubernetesDeployAct
actionName: action.key(),
resources: namespaceManifests,
log,
timeoutSec: spec.timeout || KUBECTL_DEFAULT_TIMEOUT,
timeoutSec: spec.timeout,
})
}

Expand Down Expand Up @@ -283,7 +284,7 @@ export const kubernetesDeploy: DeployActionHandler<"deploy", KubernetesDeployAct
actionName: action.key(),
resources: preparedManifests,
log,
timeoutSec: spec.timeout || KUBECTL_DEFAULT_TIMEOUT,
timeoutSec: spec.timeout,
})
}

Expand Down
3 changes: 3 additions & 0 deletions core/src/plugins/kubernetes/volumes/configmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { DeployAction, DeployActionConfig, ResolvedDeployAction } from "../../..
import { KubernetesDeployActionConfig } from "../kubernetes-type/config"
import { Resolved } from "../../../actions/types"
import { makeDocsLink } from "../../../docs/common"
import { KUBECTL_DEFAULT_TIMEOUT } from "../kubectl"

// TODO: If we make a third one in addition to this and `persistentvolumeclaim`, we should dedupe some code.

Expand All @@ -41,6 +42,7 @@ const commonSpecKeys = () => ({
export interface ConfigMapSpec extends ConfigmapDeploySpec {
dependencies: string[]
}

type ConfigMapModule = GardenModule<ConfigMapSpec, ConfigMapSpec>

type ConfigmapActionConfig = DeployActionConfig<"configmap", ConfigmapDeploySpec>
Expand Down Expand Up @@ -169,6 +171,7 @@ function getKubernetesAction(action: Resolved<ConfigmapAction>) {
namespace: action.getSpec("namespace"),
files: [],
manifests: [configMapManifest],
timeout: KUBECTL_DEFAULT_TIMEOUT,
},
}

Expand Down
3 changes: 3 additions & 0 deletions core/src/plugins/kubernetes/volumes/persistentvolumeclaim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { KubernetesDeployActionConfig } from "../kubernetes-type/config"
import { DeployActionDefinition } from "../../../plugin/action-types"
import { getKubernetesDeployStatus, kubernetesDeploy } from "../kubernetes-type/handlers"
import { Resolved } from "../../../actions/types"
import { KUBECTL_DEFAULT_TIMEOUT } from "../kubectl"

export interface PersistentVolumeClaimDeploySpec extends BaseVolumeSpec {
namespace?: string
Expand All @@ -47,6 +48,7 @@ const commonSpecKeys = () => ({
interface PersistentVolumeClaimSpec extends PersistentVolumeClaimDeploySpec {
dependencies: string[]
}

type PersistentVolumeClaimModule = GardenModule<PersistentVolumeClaimSpec, PersistentVolumeClaimSpec>

type PersistentVolumeClaimActionConfig = DeployActionConfig<"persistentvolumeclaim", PersistentVolumeClaimDeploySpec>
Expand Down Expand Up @@ -196,6 +198,7 @@ function getKubernetesAction(action: Resolved<PersistentVolumeClaimAction>) {
namespace: action.getSpec("namespace"),
files: [],
manifests: [pvcManifest],
timeout: KUBECTL_DEFAULT_TIMEOUT,
},
}

Expand Down
2 changes: 2 additions & 0 deletions core/test/unit/src/plugins/kubernetes/port-forward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
KubernetesDeployActionSpec,
} from "../../../../../src/plugins/kubernetes/kubernetes-type/config"
import { ResolvedDeployAction } from "../../../../../src/actions/deploy"
import { KUBECTL_DEFAULT_TIMEOUT } from "../../../../../src/plugins/kubernetes/kubectl"

describe("getForwardablePorts", () => {
it("returns all ports for Service resources", () => {
Expand Down Expand Up @@ -59,6 +60,7 @@ describe("getForwardablePorts", () => {
localPort: 9999,
},
],
timeout: KUBECTL_DEFAULT_TIMEOUT,
}
},
}
Expand Down

0 comments on commit 0f2c3d2

Please sign in to comment.