Skip to content
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 blog/2023-05-30-vs-helm/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,13 @@ spec = {
template.metadata.labels = metadata.labels
template.spec.containers = [
{
name = name
name = n
image = container.image.name
command = container.command
command = container.args
env = container.env
resources = container.resources
} for name, container in option("containers") or {}
} for n, container in option("containers") or {}
]
}
EOF
Expand Down
2 changes: 2 additions & 0 deletions examples/gitops/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test:
make -C config
3 changes: 3 additions & 0 deletions examples/gitops/config/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test:
kcl run
kcl test
4 changes: 2 additions & 2 deletions examples/gitops/config/kubernetes_render.k
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ kubernetesRender = lambda a: app.App {
template.metadata.labels = a.labels
template.spec.containers = [
{
name = name
name = n
image = c.image
command = c.command
args = c.args
env = c.env
volumeMounts = c.volumes
resources: c.resources
ports = c.ports
} for name, c in a.containers
} for n, c in a.containers
]
}
}
Expand Down
19 changes: 19 additions & 0 deletions examples/gitops/config/kubernetes_render_test.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import manifests

import app

# Convert the `App` model into Kubernetes Deployment and Service Manifests
test_kubernetesRender = lambda {
a = app.App {
name = "app"
containers.ngnix = {
image = "ngnix"
ports = [{containerPort = 80}]
}
service.ports = [{ port = 80 }]
}
resources = kubernetesRender(a)
assert resources[0].kind == "Deployment"
assert resources[1].kind == "Service"
assert resources[0].spec.template.spec.containers[0]["name"] == "ngnix", "expected {}, got {}".format("", resources[0].spec.template.spec.containers[0]["name"])
}
2 changes: 1 addition & 1 deletion examples/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pwd=$(
pwd
)

for path in "configuration" "validation" "abstraction" "definition" "mutation" "data-integration" "automation" "package-management" "kubernetes" "codelab"; do
for path in "configuration" "validation" "abstraction" "definition" "gitops" "mutation" "data-integration" "automation" "package-management" "kubernetes" "codelab"; do
echo "\033[1mTesting $path ...\033[0m"
if (cd $pwd/$path && make test); then
echo "\033[32mTest SUCCESSED - $path\033[0m\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,13 @@ spec = {
template.metadata.labels = metadata.labels
template.spec.containers = [
{
name = name
name = n
image = container.image.name
command = container.command
command = container.args
env = container.env
resources = container.resources
} for name, container in option("containers") or {}
} for n, container in option("containers") or {}
]
}
EOF
Expand Down