-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: update README, add kubernetes examples and refine kcl run c…
…odes. (#91)
- Loading branch information
Showing
4 changed files
with
110 additions
and
68 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2022 The KCL Authors. All rights reserved. | ||
|
||
// Run CGO Mode: | ||
// KCLVM_SERVICE_CLIENT_HANDLER=native KCLVM_PLUGIN_DEBUG=1 go run -tags=kclvm_service_capi . | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"kusionstack.io/kclvm-go" | ||
_ "kusionstack.io/kclvm-go/pkg/kcl_plugin/hello_plugin" | ||
) | ||
|
||
func main() { | ||
yaml := kclvm.MustRun("kubernetes.k", kclvm.WithCode(k_code)).GetRawYamlResult() | ||
fmt.Println(yaml) | ||
} | ||
|
||
const k_code = ` | ||
apiVersion = "apps/v1" | ||
kind = "Deployment" | ||
metadata = { | ||
name = "nginx" | ||
labels.app = "nginx" | ||
} | ||
spec = { | ||
replicas = 3 | ||
selector.matchLabels = metadata.labels | ||
template.metadata.labels = metadata.labels | ||
template.spec.containers = [ | ||
{ | ||
name = metadata.name | ||
image = "${metadata.name}:1.14.2" | ||
ports = [{ containerPort = 80 }] | ||
} | ||
] | ||
} | ||
` |
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