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

correct field name accord for struct definition and update README #1

Merged
merged 1 commit into from
Jun 16, 2022
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
71 changes: 69 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,78 @@ This repo contains the templates for `kusion init`, which make it easy to quickl

2. Add template files in the new directory.

3. Write a default configuration set file, aka, `kusion.yaml`.

## Text replacement

Kusion templates use [go template](https://pkg.go.dev/text/template) rules to generate output, which is described in `kusion.yaml`.

`kusion.yaml` contains all configurations, including project level and stack level.

- `common` represents project level configurations, which can be covered by stack ones.
- `stacks` represents stacks level configurations, which is specific to each stack.
- `projectFields` represents project level configurations, which can be covered by stack ones.
- `stacks` represents stacks level configurations, which is specific to each stack.

Every field type should be one of these two kinds -- one is primitive, anthor is composite. For example:
- Primitive
- string
- int
- float
- bool
- Composite
- array
- map
- struct
- any

All variables defined in template shall have an explaination, for example:

Go template:
```go
name: {{ .Name }}
age: {{ .Age }}
gender: {{- if .Sex }} Male {{- else}} Female {{ end }}
Hobbies: {{ range .Hobbies }}{{"\n"}}- {{.}}{{ end }}
Additional: {{ range $k, $v := .Additional }}{{"\n"}} {{ $k }}: {{ $v }}{{ end }}
```

Field explainations:
```yaml
- name: Name
type: string
default: Tom
- name: Age
type: int
default: 8
- name: Sex
type: bool
default: true
- name: Hobbies
type: array
elem:
type: string
default:
- singing
- dancing
- name: Additional
type: map
key:
type: string
value:
type: string
default:
Country: China
Language: Simple Chinese
```

Output is similar to:
```yaml
name: Tom
age: 8
gender: Male
Hobbies:
- dancing
- singing
Additional:
Country: China
Language: Simple Chinese
```
2 changes: 1 addition & 1 deletion deployment-multi-stack/kusion.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
projectName: my-app
description: A minimal kusion project of single stack
quickstart: kusion compile main.k -Y ci-test/settings.yaml
common:
projectFields:
# base/base.k
- name: ServiceName
description: service name
Expand Down
2 changes: 1 addition & 1 deletion deployment-single-stack/kusion.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
projectName: my-app
description: A minimal kusion project of single stack
quickstart: kusion compile main.k -Y ci-test/settings.yaml
common:
projectFields:
# base/base.k
- name: ServiceName
description: service name
Expand Down