-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jingwen Peng <pengsrc@yunify.com>
- Loading branch information
Showing
9 changed files
with
141 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hi there, this is an example read me file! |
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,42 @@ | ||
{ | ||
"template": { | ||
"format": "Go" | ||
}, | ||
"output": { | ||
"file_naming": { | ||
"style": "snake_case", | ||
"extension": ".go" | ||
} | ||
}, | ||
"template_files": { | ||
"shared": { | ||
"file_path": "shared.tmpl" | ||
}, | ||
"service": { | ||
"file_path": "service.tmpl", | ||
"output_file_naming": { | ||
"prefix": "qs_", | ||
"suffix": "_service" | ||
} | ||
}, | ||
"sub_service": { | ||
"file_path": "sub_service.tmpl", | ||
"output_file_naming": { | ||
"prefix": "qs_", | ||
"suffix": "_sub_service" | ||
} | ||
}, | ||
"types": { | ||
"file_path": "types.tmpl", | ||
"output_file_naming": { | ||
"prefix": "qs_", | ||
"suffix": "" | ||
} | ||
} | ||
}, | ||
"supporting_files": [ | ||
"utils.go", | ||
"utils_test.go", | ||
"README.md" | ||
] | ||
} |
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,67 @@ | ||
# Manifest file for a bunch of templates. | ||
# The manifest file can be in JSON or YAML format. | ||
|
||
# Template configurations | ||
template: | ||
# Template files format | ||
# Validate formats: Go | ||
# Default: Go | ||
format: Go | ||
|
||
# Output | ||
output: | ||
file_naming: | ||
# Naming style to use in the output file. | ||
# Available styles: snake_case, camel_case | ||
# Default: snake_case | ||
# Example: bucket_acl (snake_case), BucketACL (camel_case) | ||
style: snake_case | ||
extension: .go | ||
|
||
# Template files to read and execute. | ||
# Currently, there's are three of them. | ||
template_files: | ||
# Shared template file. | ||
# This file will be concatenated with each other template to provide shared | ||
# nested template definitions. | ||
shared: | ||
# Relative file path to load the shared template file. | ||
# Default: shared.tmpl | ||
file_path: shared.tmpl | ||
|
||
# Service template file. | ||
# In this case, a file named "qs_qingstor_service.go" will be generated. | ||
service: | ||
# Relative file path to load service template file. | ||
# Default: service.tmpl | ||
file_path: service.tmpl | ||
# Naming options for output file. | ||
output_file_naming: | ||
prefix: qs_ | ||
suffix: _service | ||
|
||
# Service template file. | ||
# In this case, multiple files named like "qs_bucket_sub_service.go" | ||
# will be generated. | ||
sub_service: | ||
# Relative file path to load sub service template file. | ||
# Default: sub_service.tmpl | ||
file_path: sub_service.tmpl | ||
output_file_naming: | ||
prefix: qs_ | ||
suffix: _sub_service | ||
# Types template file. | ||
# In this case, a file named "qs_types.go" will be generated. | ||
types: | ||
# Relative file path to load types template file. | ||
# Default: types.tmpl | ||
file_path: types.tmpl | ||
output_file_naming: | ||
prefix: qs_ | ||
suffix: | ||
|
||
# Supporting files to copy directly. | ||
supporting_files: | ||
- utils.go | ||
- utils_test.go | ||
- README.md |
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,4 @@ | ||
{{$service := .Data.Service}} | ||
|
||
// {{$service.Name | camelCase}} | ||
// API Version {{$service.APIVersion}} |
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 @@ | ||
// Shared Parts |
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,4 @@ | ||
{{$service := .Data.Service}} | ||
{{$subService := index .Data.SubServices .CurrentSubServiceID}} | ||
|
||
// {{$subService.Name | camelCase}} |
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,5 @@ | ||
{{$customizedTypes := .Data.CustomizedTypes}} | ||
|
||
{{range $_, $customizedType := $customizedTypes}} | ||
// {{$customizedType | camelCase}} | ||
{{end}} |
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,5 @@ | ||
package example | ||
|
||
func Utils() string { | ||
return "Hi there, this is an example code file!" | ||
} |
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,12 @@ | ||
package example | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestUtils(t *testing.T) { | ||
assert.True(t, strings.HasPrefix(Utils(), "Hi there")) | ||
} |