Skip to content

Commit

Permalink
Merge pull request #479 from kcl-lang/inherit-oam-app-example
Browse files Browse the repository at this point in the history
docs: add inherit oam app example
  • Loading branch information
Peefy authored Nov 5, 2024
2 parents e78c264 + 8754340 commit c819b5b
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 0 deletions.
7 changes: 7 additions & 0 deletions examples/kubevela/inherit-oam-app/kcl.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "inherit-oam-app"
edition = "v0.10.0"
version = "0.0.1"

[dependencies]
oam = "0.2.1"
10 changes: 10 additions & 0 deletions examples/kubevela/inherit-oam-app/kcl.mod.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[dependencies]
[dependencies.k8s]
name = "k8s"
full_name = "k8s_1.31.2"
version = "1.31.2"
[dependencies.oam]
name = "oam"
full_name = "oam_0.2.1"
version = "0.2.1"
sum = "bz5HT/ggMm6heYVUOaZd5mOLIv/q2jicXupv0ChDlsE="
22 changes: 22 additions & 0 deletions examples/kubevela/inherit-oam-app/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import oam

schema MyApplication(oam.Application):
metadata.annotations = {
"some-key" = "some-value"
} # Extend default values

check:
"some-key" in metadata.annotations if metadata.annotations # Extend validation rules

MyApplication {
metadata.name = "kcl-play-svc"
spec.components = [{
name = metadata.name
type = "webservice"
properties = {
image = "kcllang/kcl"
ports = [{port = 80, expose = True}]
cmd = ["kcl", "play"]
}
}]
}
7 changes: 7 additions & 0 deletions examples/kubevela/template-oam-app/kcl.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "inherit-oam-app"
edition = "v0.10.0"
version = "0.0.1"

[dependencies]
oam = "0.2.1"
10 changes: 10 additions & 0 deletions examples/kubevela/template-oam-app/kcl.mod.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[dependencies]
[dependencies.k8s]
name = "k8s"
full_name = "k8s_1.31.2"
version = "1.31.2"
[dependencies.oam]
name = "oam"
full_name = "oam_0.2.1"
version = "0.2.1"
sum = "bz5HT/ggMm6heYVUOaZd5mOLIv/q2jicXupv0ChDlsE="
27 changes: 27 additions & 0 deletions examples/kubevela/template-oam-app/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import oam

schema MyTemplate:
name: str
image: str
cmd?: [str]
port: int = 80

schema MyApplication[template: MyTemplate](oam.Application):
metadata = {name = "kcl-play-svc"}
spec = {
components = [{
name = metadata.name
type = "webservice"
properties = {
image = "kcllang/kcl"
ports = [{port = 80, expose = True}]
cmd = ["kcl", "play"]
}
}]
}

MyApplication({
name = "kcl-play-svc"
image = "kcllang/kcl"
cmd: ["kcl", "play"]
}) {}

0 comments on commit c819b5b

Please sign in to comment.