Skip to content

Commit 28e6078

Browse files
authored
Merge pull request #12 from wk8/wk8/generator
Adding the API generator
2 parents 15613db + 9beec53 commit 28e6078

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2722
-230
lines changed

client/api/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,19 +204,19 @@ service Dummy {
204204
...
205205
}
206206
```
207-
then regenerate the protobuf code, and run `csi-proxy-gen`: it will also mark the version's server (``) and client (``) packages as deprecated.
207+
then regenerate the protobuf code, and run `csi-proxy-api-gen`: it will also mark the version's server (``) and client (``) packages as deprecated.
208208

209-
For removal, remove the whole `client/api/<api_group_name>/<version>` directory, and run `csi-proxy-gen`, it will remove all references to the removed version.
209+
For removal, remove the whole `client/api/<api_group_name>/<version>` directory, and run `csi-proxy-api-gen`, it will remove all references to the removed version.
210210

211211
#### An API group
212212

213-
Deprecate and remove all its versions as explained in the previous version; then remove the entire `client/api/<api_group_name>` directory, and run `csi-proxy-gen`, it will remove all references to the removed API group.
213+
Deprecate and remove all its versions as explained in the previous version; then remove the entire `client/api/<api_group_name>` directory, and run `csi-proxy-api-gen`, it will remove all references to the removed API group.
214214

215215
## Detailed breakdown of generated files
216216

217-
This section details how `csi-proxy-gen` works, and what files it generates; `csi-proxy-gen` is built on top of [gengo](https://github.com/kubernetes/gengo), and re-uses part of [k8s' code-generator](https://github.com/kubernetes/code-generator), notably to generate conversion functions.
217+
This section details how `csi-proxy-api-gen` works, and what files it generates; `csi-proxy-api-gen` is built on top of [gengo](https://github.com/kubernetes/gengo), and re-uses part of [k8s' code-generator](https://github.com/kubernetes/code-generator), notably to generate conversion functions.
218218

219-
First, it looks for all API group definitions, which are either subdirectories of `client/api/`, or any go package that contains a `doc.go` file containing a `// +csi-proxy-gen` comment.
219+
First, it looks for all API group definitions, which are either subdirectories of `client/api/`, or any go package whose `doc.go` file contains a `// +csi-proxy-api-gen` comment.
220220

221221
Then for each API group it finds:
222222
1. it iterates through each version subpackage, and in each looks for the `<ApiGroupName>Server` interface, and compiles the list of callbacks that the group's `Server` needs to implement as well as the list of top-level `struct`s (`*Request`s and `*Response`s)
@@ -230,9 +230,9 @@ Then for each API group it finds:
230230
2. it generates missing conversion functions to `internal/server/<api_group_name>/internal/<version>/conversion_generated.go`
231231
3. it generates `internal/server/<api_group_name>/internal/<version>/server_generated.go`
232232
6. it generates `internal/server/<api_group_name>/internal/api_group_generated.go` to list all the versioned servers it's just created
233-
7. and finally, it generates `client/groups/<api_group_name>/<version>/client_generated.go`
233+
7. and finally, it generates `client/groups/<api_group_name>/<version>/client_generated.go` for each version
234234

235-
When `csi-proxy-gen` has successfully run to completion, [our example API group's go package from earlier](#serverPkgTree) will look something like:
235+
When `csi-proxy-api-gen` has successfully run to completion, [our example API group's go package from earlier](#serverPkgTree) will look something like:
236236
```
237237
internal/server/<api_group_name>
238238
├── api_group_generated.go

client/api/filesystem/v1alpha1/api.pb.go

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/api/filesystem/v1alpha1/api.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ service FileSystem {
1414
}
1515

1616
message PathExistsRequest {
17-
// The path to check in the host filesystem.
17+
// The path to check in the host file system.
1818
string path = 1;
1919
}
2020

client/apiversion/version.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ func NewVersionOrPanic(name string) Version {
8080
return version
8181
}
8282

83+
// IsValidVersion returns true iff the input is a valid version name.
84+
func IsValidVersion(name string) bool {
85+
return nameRegex.MatchString(name)
86+
}
87+
8388
func toUint(s, name string) (uint, error) {
8489
i, err := strconv.ParseUint(s, 10, 0)
8590
if err != nil {

client/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ require (
66
github.com/Microsoft/go-winio v0.4.14
77
github.com/golang/protobuf v1.3.2
88
github.com/pkg/errors v0.8.1
9-
google.golang.org/grpc v1.23.1
9+
google.golang.org/grpc v1.24.0
1010
)

client/go.sum

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk
66
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
77
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
88
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
9-
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
109
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
1110
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
1211
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
@@ -34,6 +33,6 @@ golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBn
3433
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
3534
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc=
3635
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
37-
google.golang.org/grpc v1.23.1 h1:q4XQuHFC6I28BKZpo6IYyb3mNO+l7lSOxRuYTCiDfXk=
38-
google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
36+
google.golang.org/grpc v1.24.0 h1:vb/1TCsVn3DcJlQ0Gs1yB1pKI6Do2/QNwxdKqmc/b0s=
37+
google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA=
3938
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

client/groups/filesystem/v1alpha1/client_generated.go

Lines changed: 16 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)