Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: respect deploymentRegistry in the garden publish command #4740

Merged
merged 1 commit into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/src/plugins/container/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ export const publishContainerBuild: BuildActionHandler<"publish", ContainerBuild
const localId = action.getOutput("localImageId")
const remoteId = containerHelpers.getPublicImageId(action, tag)

log.info({ msg: `Publishing image ${remoteId}...` })

if (localId !== remoteId) {
log.info({ msg: `Tagging image with ${localId} and ${remoteId}` })
await containerHelpers.dockerCli({
cwd: action.getBuildPath(),
args: ["tag", localId, remoteId],
Expand All @@ -30,6 +29,7 @@ export const publishContainerBuild: BuildActionHandler<"publish", ContainerBuild
})
}

log.info({ msg: `Publishing image ${remoteId}...` })
// TODO: stream output to log if at debug log level
await containerHelpers.dockerCli({ cwd: action.getBuildPath(), args: ["push", remoteId], log, ctx })

Expand Down
20 changes: 16 additions & 4 deletions core/src/plugins/kubernetes/container/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@

import { ContainerBuildAction } from "../../container/moduleConfig"
import { KubernetesPluginContext } from "../config"
import { publishContainerBuild } from "../../container/publish"
import { pullBuild } from "../commands/pull-image"
import { BuildActionHandler } from "../../../plugin/action-types"
import { containerHelpers } from "../../container/helpers"

export const k8sPublishContainerBuild: BuildActionHandler<"publish", ContainerBuildAction> = async (params) => {
const { ctx, action, log } = params
const k8sCtx = ctx as KubernetesPluginContext
const provider = k8sCtx.provider

const localId = action.getOutput("localImageId")
// NOTE: this may contain a custom deploymentRegistry, from the kubernetes provider config
// We cannot combine this publish method with the container plugin's publish method, because it won't have the context
const remoteId = action.getOutput("deploymentImageId")

if (provider.config.buildMode !== "local-docker") {
// First pull from the remote registry, then resume standard publish flow.
// This does mean we require a local docker as a go-between, but the upside is that we can rely on the user's
Expand All @@ -25,10 +30,17 @@ export const k8sPublishContainerBuild: BuildActionHandler<"publish", ContainerBu
// We also generally prefer this because the remote cluster very likely doesn't (and shouldn't) have
// privileges to push to production registries.
log.info(`Pulling from remote registry...`)
const localId = action.getOutput("localImageId")
const remoteId = action.getOutput("deploymentImageId")
await pullBuild({ ctx: k8sCtx, action, log, localId, remoteId })
}

return publishContainerBuild({ ...params, ctx: { ...ctx, provider: provider.dependencies.container } })
log.info({ msg: `Publishing image ${remoteId}...` })
// TODO: stream output to log if at debug log level
await containerHelpers.dockerCli({ cwd: action.getBuildPath(), args: ["push", remoteId], log, ctx })

return {
state: "ready",
detail: { published: true, message: `Published ${remoteId}` },
// TODO-0.13.1
outputs: {},
}
vvagaytsev marked this conversation as resolved.
Show resolved Hide resolved
}