-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(openshift): container Build action (#4726)
* chore(openshift): rename container.ts -> deploy.ts * feat(openshift): container Build action, buildmode local-docker * chore: fix lint on openshift/build.ts * feat(openshift): in-cluster container Build using kaniko * chore(openshift): add openshift logo to example web page * chore(openshift): update demo-project readme
- Loading branch information
Showing
15 changed files
with
333 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (C) 2018-2023 Garden Technologies, Inc. <info@garden.io> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
import { DeepPrimitiveMap } from "@garden-io/platform-api-types" | ||
import { BuildActionExtension } from "../../plugin/action-types" | ||
import { ContainerBuildAction } from "../container/config" | ||
import { ContainerBuildMode, KubernetesProvider } from "../kubernetes/config" | ||
import { k8sGetContainerBuildActionOutputs } from "../kubernetes/container/handlers" | ||
import { k8sPublishContainerBuild } from "../kubernetes/container/publish" | ||
import { BuildHandler, BuildStatusHandler } from "../kubernetes/container/build/common" | ||
import { getLocalBuildStatus, localBuild } from "../kubernetes/container/build/local" | ||
import { getKanikoBuildStatus, kanikoBuild } from "../kubernetes/container/build/kaniko" | ||
|
||
export const openshiftContainerBuildExtension = (): BuildActionExtension<ContainerBuildAction> => ({ | ||
name: "container", | ||
handlers: { | ||
async getOutputs({ ctx, action }) { | ||
const provider = ctx.provider as KubernetesProvider | ||
return { | ||
outputs: k8sGetContainerBuildActionOutputs({ action, provider }) as unknown as DeepPrimitiveMap, | ||
} | ||
}, | ||
|
||
build: async (params) => { | ||
const { ctx } = params | ||
|
||
const provider = <KubernetesProvider>ctx.provider | ||
const buildMode = provider.config.buildMode || "local-docker" | ||
const handler = buildHandlers[buildMode] | ||
|
||
return handler(params) | ||
}, | ||
|
||
getStatus: async (params) => { | ||
const { ctx } = params | ||
const provider = <KubernetesProvider>ctx.provider | ||
|
||
const buildMode = provider.config.buildMode || "local-docker" | ||
const handler = buildStatusHandlers[buildMode] | ||
return handler(params) | ||
}, | ||
|
||
publish: k8sPublishContainerBuild, | ||
}, | ||
}) | ||
|
||
const unimplemented = () => { | ||
throw new Error("Unimplemented handler called in OpenShift Build") | ||
} | ||
|
||
const buildStatusHandlers: { [mode in ContainerBuildMode]: BuildStatusHandler } = { | ||
"local-docker": getLocalBuildStatus, | ||
"cluster-buildkit": unimplemented, | ||
"kaniko": getKanikoBuildStatus, | ||
} | ||
|
||
const buildHandlers: { [mode in ContainerBuildMode]: BuildHandler } = { | ||
"local-docker": localBuild, | ||
"cluster-buildkit": unimplemented, | ||
"kaniko": kanikoBuild, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.