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

chore(examples): update code-synchronization example to use actions #3822

Merged
merged 8 commits into from
Mar 8, 2023
28 changes: 23 additions & 5 deletions core/src/plugins/kubernetes/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,17 +248,35 @@ export function convertContainerSyncSpec(
action: Resolved<ContainerDeployAction>
): KubernetesDeploySyncSpec | undefined {
const spec = action.getSpec()
const kind: SyncableKind = spec.daemon ? "DaemonSet" : "Deployment"
const target = { kind, name: action.name }
const sourcePath = action.basePath()
const syncSpec = spec.sync

if (!spec.sync) {
if (!syncSpec || !target) {
return
}

const kind: SyncableKind = spec.daemon ? "DaemonSet" : "Deployment"
const target = { kind, name: action.name }
const sync: KubernetesDeploySyncSpec = {
paths: convertSyncPaths(sourcePath, syncSpec.paths, target),
}

return {
paths: convertSyncPaths(action.basePath(), spec.sync.paths, target),
if (syncSpec.command || syncSpec.args) {
if (target.kind && target.name) {
sync.overrides = [
{
target: {
kind: target.kind,
name: target.name,
},
command: syncSpec.command,
args: syncSpec.args,
},
]
}
}

return sync
}

function convertSyncPaths(
Expand Down
49 changes: 27 additions & 22 deletions examples/code-synchronization/node-service/garden.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
kind: Module
kind: Build
name: node-service
type: container

---
kind: Deploy
description: Node greeting service
name: node-service
type: container
services:
- name: node-service
args: [npm, start]
sync:
command: [npm, run, dev] # Overrides the container's default when the service is deployed in sync mode
paths:
- source: src
target: /app/src
# Make sure to specify any paths that should not be synced!
exclude: [node_modules]
mode: one-way
ports:
- name: http
containerPort: 8080
ingresses:
- path: /hello
port: http
healthCheck:
httpGet:
path: /_ah/health
port: http
build: node-service
spec:
args: [npm, start]
sync:
command: [npm, run, dev] # Overrides the container's default when the service is deployed in dev mode
paths:
- source: src
target: /app/src
# Make sure to specify any paths that should not be synced!
exclude: [node_modules]
mode: one-way
ports:
- name: http
containerPort: 8080
ingresses:
- path: /hello
port: http
healthCheck:
httpGet:
path: /_ah/health
port: http
2 changes: 1 addition & 1 deletion examples/code-synchronization/node-service/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const express = require("express")
const app = express()

app.get("/hello", (req, res) => {
res.json({message: "Hello from Node!"})
res.json({ message: "Hello from Node!" })
})

// This is the path GAE uses for health checks
Expand Down