Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

GSP-137: Service Output Template #137

Closed
wants to merge 3 commits into from
Closed
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
35 changes: 35 additions & 0 deletions rfcs/137-service-output-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
- Author: Xuanwo <[email protected]>
- Start Date: 2021-07-07
- RFC PR: [beyondstorage/specs#137](https://github.com/beyondstorage/specs/issues/137)
- Tracking Issue: [beyondstorage/go-storage#0](https://github.com/beyondstorage/go-storage/issues/0)

# GSP-137: Service Output Template

## Background

[Increase code coverage](https://github.com/beyondstorage/go-storage/issues/620) plans to move `cmd/definitions/tests` into `tests` and support generating files into `generate_test.go` so we won't export test services.

So `definitions` should have the ability to generate all files into a specified output filename template.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need this feature in definitions? If we just want to change tests, we can simply write some scripts in Makefile?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need this feature in definitions? If we just want to change tests, we can simply write some scripts in Makefile?

You are right. The feature is used in tests services only. I will abort this GSP and use scripts instead.


## Proposal

I propose to add a new field `output_template` in `service.toml`. In `output_template`, we will use format string like `%s_test.go`.

If service provider specify `output_template` to `%s_test.go`, `definitions` will generate files into:

- `generated_test.go`
- `service_test.go`
- `storage_test.go`
Comment on lines +18 to +22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

service.go and storage.go are formatted, not generated?


## Rationale

N/A

## Compatibility

This GSP introduces a compatible change.

## Implementation

- Add `output_template` field in specs.
- Support `output_template` in go-storage.