Skip to content

Commit

Permalink
fix definition test cases
Browse files Browse the repository at this point in the history
Signed-off-by: Jian.Li <lj176172@alibaba-inc.com>
  • Loading branch information
leejanee committed Dec 16, 2021
1 parent 4bdc34e commit a792aa0
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 38 deletions.
Expand Up @@ -706,11 +706,9 @@ spec:
schematic:
cue:
template: |
import (
ev1 "example.com/v1"
)
output: ev1.#Foo
output: {
kind: "Foo"
apiVersion: "example.com/v1"
spec: key: parameter.key1
status: key: parameter.key2
}
Expand Down
Expand Up @@ -269,8 +269,8 @@ spec:
cue:
template: |
output: {
metadata: kind: "Foo"
metadata: apiVersion: "example.com/v1"
kind: "Foo"
apiVersion: "example.com/v1"
spec: key: parameter.key1
status: key: parameter.key2
}
Expand Down
8 changes: 4 additions & 4 deletions references/appfile/dryrun/testdata/cd-myworker.yaml
Expand Up @@ -10,10 +10,10 @@ spec:
schematic:
cue:
template: |
import (
apps "kube/apps/v1"
)
output: apps.#Deployment
output: {
apiVersion: "apps/v1"
kind: "Deployment"
}
output: {
spec: {
selector: matchLabels: {
Expand Down
40 changes: 19 additions & 21 deletions references/appfile/dryrun/testdata/diff-apprevision.yaml
Expand Up @@ -117,15 +117,14 @@ spec:
spec:
schematic:
cue:
template: "import (\n apps \"kube/apps/v1\"\n)\noutput: apps.#Deployment\noutput:
{\n\tspec: {\n\t\tselector: matchLabels: {\n\t\t\t\"app.oam.dev/component\":
context.name\n\t\t}\n\n\t\ttemplate: {\n\t\t\tmetadata: labels: {\n\t\t\t\t\"app.oam.dev/component\":
context.name\n\t\t\t}\n\n\t\t\tspec: {\n\t\t\t\tcontainers: [{\n\t\t\t\t\tname:
\ context.name\n\t\t\t\t\timage: parameter.image\n\n\t\t\t\t\tif parameter[\"cmd\"]
!= _|_ {\n\t\t\t\t\t\tcommand: parameter.cmd\n\t\t\t\t\t}\n\t\t\t\t}]\n\t\t\t}\n\t\t}\n\t}\n}\n\nparameter:
{\n\t// +usage=Which image would you like to use for your service\n\t//
+short=i\n\timage: string\n\t// +usage=Commands to run in the container\n\tcmd?:
[...string]\n}\n"
template: "output: {\n apiVersion: \"apps/v1\"\n kind: \"Deployment\"\n}\noutput:
{\n\tspec: {\n\t\tselector: matchLabels: {\n\t\t\t\"app.oam.dev/component\":
context.name\n\t\t}\n\n\t\ttemplate: {\n\t\t\tmetadata: labels: {\n\t\t\t\t\"app.oam.dev/component\":
context.name\n\t\t\t}\n\n\t\t\tspec: {\n\t\t\t\tcontainers: [{\n\t\t\t\t\tname:
\ context.name\n\t\t\t\t\timage: parameter.image\n\n\t\t\t\t\tif parameter[\"cmd\"]
!= _|_ {\n\t\t\t\t\t\tcommand: parameter.cmd\n\t\t\t\t\t}\n\t\t\t\t}]\n\t\t\t}\n\t\t}\n\t}\n}\n\nparameter:
{\n\t// +usage=Which image would you like to use for your service\n\t// +short=i\n\timage:
string\n\t// +usage=Commands to run in the container\n\tcmd?: [...string]\n}\n"
workload:
definition:
apiVersion: apps/v1
Expand Down Expand Up @@ -219,18 +218,17 @@ spec:
name: ""
schematic:
cue:
template: "import (\n\tkubev1 \"kube/v1\"\n\tnetwork \"kube/networking.k8s.io/v1beta1\"\n)\n\nparameter:
{\n\tdomain: string\n\thttp: [string]: int\n}\n\noutputs: {\nservice:
kubev1.#Service\ningress: network.#Ingress\n}\n\n// trait template can
have multiple outputs in one trait\noutputs: service: {\n\tmetadata:\n\t\tname:
context.name\n\tspec: {\n\t\tselector:\n\t\t\t\"app.oam.dev/component\":
context.name\n\t\tports: [\n\t\t\tfor k, v in parameter.http {\n\t\t\t\tport:
\ v\n\t\t\t\ttargetPort: v\n\t\t\t},\n\t\t]\n\t}\n}\n\noutputs:
ingress: {\n\tmetadata:\n\t\tname: context.name\n\tspec: {\n\t\trules:
[{\n\t\t\thost: parameter.domain\n\t\t\thttp: {\n\t\t\t\tpaths: [\n\t\t\t\t\tfor
k, v in parameter.http {\n\t\t\t\t\t\tpath: k\n\t\t\t\t\t\tbackend:
{\n\t\t\t\t\t\t\tserviceName: context.name\n\t\t\t\t\t\t\tservicePort:
v\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t}\n\t\t}]\n\t}\n}\n"
template: "parameter: {\n\tdomain: string\n\thttp: [string]: int\n}\n\noutputs:
{\n service: {\n apiVersion: \"v1\"\n kind: \"Service\"\n }\n ingress:
{\n apiVersion: \"networking.k8s.io/v1beta1\"\n kind: \"Ingress\"\n
\ }\n}\n\n// trait template can have multiple outputs in one trait\noutputs:
service: {\n\tmetadata:\n\t\tname: context.name\n\tspec: {\n\t\tselector:\n\t\t\t\"app.oam.dev/component\":
context.name\n\t\tports: [\n\t\t\tfor k, v in parameter.http {\n\t\t\t\tport:
\ v\n\t\t\t\ttargetPort: v\n\t\t\t},\n\t\t]\n\t}\n}\n\noutputs: ingress:
{\n\tmetadata:\n\t\tname: context.name\n\tspec: {\n\t\trules: [{\n\t\t\thost:
parameter.domain\n\t\t\thttp: {\n\t\t\t\tpaths: [\n\t\t\t\t\tfor k, v in parameter.http
{\n\t\t\t\t\t\tpath: k\n\t\t\t\t\t\tbackend: {\n\t\t\t\t\t\t\tserviceName:
context.name\n\t\t\t\t\t\t\tservicePort: v\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t}\n\t\t}]\n\t}\n}\n"
status: {}
myscaler:
apiVersion: core.oam.dev/v1beta1
Expand Down
15 changes: 8 additions & 7 deletions references/appfile/dryrun/testdata/td-myingress.yaml
Expand Up @@ -9,19 +9,20 @@ spec:
schematic:
cue:
template: |
import (
kubev1 "kube/v1"
network "kube/networking.k8s.io/v1beta1"
)
parameter: {
domain: string
http: [string]: int
}
outputs: {
service: kubev1.#Service
ingress: network.#Ingress
service: {
apiVersion: "v1"
kind: "Service"
}
ingress: {
apiVersion: "networking.k8s.io/v1beta1"
kind: "Ingress"
}
}
// trait template can have multiple outputs in one trait
Expand Down

0 comments on commit a792aa0

Please sign in to comment.