Skip to content

spec: use official proto wrappers for primitive fields #131

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

Closed
Closed
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
66 changes: 34 additions & 32 deletions csi.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
////////
syntax = "proto3";
package csi;

import "google/protobuf/wrappers.proto";
////////
////////
service Identity {
Expand Down Expand Up @@ -75,9 +77,9 @@ message GetSupportedVersionsResponse {
// Specifies a version in Semantic Version 2.0 format.
// (http://semver.org/spec/v2.0.0.html)
message Version {
uint32 major = 1; // This field is REQUIRED.
uint32 minor = 2; // This field is REQUIRED.
uint32 patch = 3; // This field is REQUIRED.
.google.protobuf.UInt32Value major = 1; // This field is REQUIRED.
.google.protobuf.UInt32Value minor = 2; // This field is REQUIRED.
.google.protobuf.UInt32Value patch = 3; // This field is REQUIRED.
}
////////
////////
Expand All @@ -89,10 +91,10 @@ message GetPluginInfoRequest {
message GetPluginInfoResponse {
message Result {
// This field is REQUIRED.
string name = 1;
.google.protobuf.StringValue name = 1;

// This field is REQUIRED. Value of this field is opaque to the CO.
string vendor_version = 2;
.google.protobuf.StringValue vendor_version = 2;

// This field is OPTIONAL. Values are opaque to the CO.
map<string, string> manifest = 3;
Expand Down Expand Up @@ -125,7 +127,7 @@ message CreateVolumeRequest {
// an identifier by which to refer to the newly provisioned
// storage. If a storage system supports this, it can optionally
// use this name as the identifier for the new volume.
string name = 2;
.google.protobuf.StringValue name = 2;

// This field is OPTIONAL. This allows the CO to specify the capacity
// requirement of the volume to be provisioned. If not specified, the
Expand Down Expand Up @@ -178,7 +180,7 @@ message VolumeCapability {
// Indicate that the volume will be accessed via the filesystem API.
message MountVolume {
// The filesystem type. This field is OPTIONAL.
string fs_type = 1;
.google.protobuf.StringValue fs_type = 1;

// The mount options that can be used for the volume. This field is
// OPTIONAL. `mount_flags` MAY contain sensitive information.
Expand Down Expand Up @@ -230,18 +232,18 @@ message VolumeCapability {
// least one of the these fields MUST be specified.
message CapacityRange {
// Volume must be at least this big.
uint64 required_bytes = 1;
.google.protobuf.UInt64Value required_bytes = 1;

// Volume must not be bigger than this.
uint64 limit_bytes = 2;
.google.protobuf.UInt64Value limit_bytes = 2;
}

// The information about a provisioned volume.
message VolumeInfo {
// The capacity of the volume in bytes. This field is OPTIONAL. If not
// set, it indicates that the capacity of the volume is unknown (e.g.,
// NFS share). If set, it MUST be non-zero.
uint64 capacity_bytes = 1;
.google.protobuf.UInt64Value capacity_bytes = 1;

// Contains identity information for the created volume. This field is
// REQUIRED. The identity information will be used by the CO in
Expand All @@ -263,7 +265,7 @@ message VolumeHandle {
// Plugin. This field is REQUIRED.
// This information SHALL NOT be considered sensitive such that, for
// example, the CO MAY generate log messages that include this data.
string id = 1;
.google.protobuf.StringValue id = 1;

// Metadata captures additional, possibly sensitive, information about
// a volume in the form of key-value pairs. This field is OPTIONAL.
Expand Down Expand Up @@ -333,7 +335,7 @@ message ControllerPublishVolumeRequest {

// Whether to publish the volume in readonly mode. This field is
// REQUIRED.
bool readonly = 5;
.google.protobuf.BoolValue readonly = 5;

// End user credentials used to authenticate/authorize controller
// publish request.
Expand Down Expand Up @@ -418,11 +420,11 @@ message ValidateVolumeCapabilitiesResponse {
message Result {
// True if the Plugin supports the specified capabilities for the
// given volume. This field is REQUIRED.
bool supported = 1;
.google.protobuf.BoolValue supported = 1;

// Message to the CO if `supported` above is false. This field is
// OPTIONAL.
string message = 2;
.google.protobuf.StringValue message = 2;
}

// One of the following fields MUST be specified.
Expand All @@ -444,12 +446,12 @@ message ListVolumesRequest {
// `ListVolumes` call. This field is OPTIONAL. If not specified, it
// means there is no restriction on the number of entries that can be
// returned.
uint32 max_entries = 2;
.google.protobuf.UInt32Value max_entries = 2;

// A token to specify where to start paginating. Set this field to
// `next_token` returned by a previous `ListVolumes` call to get the
// next page of entries. This field is OPTIONAL.
string starting_token = 3;
.google.protobuf.StringValue starting_token = 3;
}

message ListVolumesResponse {
Expand All @@ -465,7 +467,7 @@ message ListVolumesResponse {
// `max_entries`, use the `next_token` as a value for the
// `starting_token` field in the next `ListVolumes` request. This
// field is OPTIONAL.
string next_token = 2;
.google.protobuf.StringValue next_token = 2;
}

// One of the following fields MUST be specified.
Expand Down Expand Up @@ -501,7 +503,7 @@ message GetCapacityResponse {
// specified in the request, the Plugin SHALL take those into
// consideration when calculating the available capacity of the
// storage. This field is REQUIRED.
uint64 available_capacity = 1;
.google.protobuf.UInt64Value available_capacity = 1;
}

// One of the following fields MUST be specified.
Expand Down Expand Up @@ -570,15 +572,15 @@ message NodePublishVolumeRequest {
// absolute path in the root filesystem of the process serving this
// request. The CO SHALL ensure uniqueness of target_path per volume.
// This is a REQUIRED field.
string target_path = 4;
.google.protobuf.StringValue target_path = 4;

// The capability of the volume the CO expects the volume to have.
// This is a REQUIRED field.
VolumeCapability volume_capability = 5;

// Whether to publish the volume in readonly mode. This field is
// REQUIRED.
bool readonly = 6;
.google.protobuf.BoolValue readonly = 6;

// End user credentials used to authenticate/authorize node publish
// request. This field is OPTIONAL.
Expand Down Expand Up @@ -606,7 +608,7 @@ message NodeUnpublishVolumeRequest {
// The path at which the volume was published. It MUST be an absolute
// path in the root filesystem of the process serving this request.
// This is a REQUIRED field.
string target_path = 3;
.google.protobuf.StringValue target_path = 3;

// End user credentials used to authenticate/authorize node unpublish
// request. This field is OPTIONAL.
Expand Down Expand Up @@ -749,11 +751,11 @@ message Error {
// will cause it to succeed. If this value is false, the caller MAY
// reissue the same call, but SHOULD implement exponential backoff
// on retires.
bool caller_must_not_retry = 2;
.google.protobuf.BoolValue caller_must_not_retry = 2;

// Human readable description of error, possibly with additional
// information. This string MAY be surfaced by CO to end users.
string error_description = 3;
.google.protobuf.StringValue error_description = 3;
}

// `CreateVolume` specific error.
Expand Down Expand Up @@ -838,7 +840,7 @@ message Error {

// Human readable description of error, possibly with additional
// information. This string maybe surfaced by CO to end users.
string error_description = 2;
.google.protobuf.StringValue error_description = 2;
}

// `DeleteVolume` specific error.
Expand Down Expand Up @@ -897,7 +899,7 @@ message Error {

// Human readable description of error, possibly with additional
// information. This string maybe surfaced by CO to end users.
string error_description = 2;
.google.protobuf.StringValue error_description = 2;
}

// `ControllerPublishVolume` specific error.
Expand Down Expand Up @@ -1004,7 +1006,7 @@ message Error {

// Human readable description of error, possibly with additional
// information. This string maybe surfaced by CO to end users.
string error_description = 2;
.google.protobuf.StringValue error_description = 2;

// On `VOLUME_ALREADY_ATTACHED` and `MAX_ATTACHED_NODES` errors,
// this field contains the node(s) that the specified volume is
Expand Down Expand Up @@ -1091,7 +1093,7 @@ message Error {
}

ControllerUnpublishVolumeErrorCode error_code = 1;
string error_description = 2;
.google.protobuf.StringValue error_description = 2;
}

// `ValidateVolumeCapabilities` specific error.
Expand Down Expand Up @@ -1129,7 +1131,7 @@ message Error {
}

ValidateVolumeCapabilitiesErrorCode error_code = 1;
string error_description = 2;
.google.protobuf.StringValue error_description = 2;
}

// `NodePublishVolume` specific error.
Expand Down Expand Up @@ -1183,7 +1185,7 @@ message Error {
}

NodePublishVolumeErrorCode error_code = 1;
string error_description = 2;
.google.protobuf.StringValue error_description = 2;
}

// `NodeUnpublishVolume` specific error.
Expand Down Expand Up @@ -1234,7 +1236,7 @@ message Error {
}

NodeUnpublishVolumeErrorCode error_code = 1;
string error_description = 2;
.google.protobuf.StringValue error_description = 2;
}

// `ProbeNode` specific error.
Expand All @@ -1255,7 +1257,7 @@ message Error {
}

ProbeNodeErrorCode error_code = 1;
string error_description = 2;
.google.protobuf.StringValue error_description = 2;
}

// `GetNodeID` specific error.
Expand All @@ -1275,7 +1277,7 @@ message Error {
}

GetNodeIDErrorCode error_code = 1;
string error_description = 2;
.google.protobuf.StringValue error_description = 2;
}

// One of the following fields MUST be specified.
Expand Down
15 changes: 14 additions & 1 deletion lib/go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,25 @@ export PATH := $(shell pwd):$(PATH)
CSI_GO := csi/csi.pb.go
CSI_A := csi.a
CSI_PROTO := ../../csi.proto
CSI_PROTO_TMP := csi/.build/csi.proto
CSI_GO_TMP := csi/.build/csi.pb.go

# This recipe generates the go language bindings to a temp area.
#
# `sed` is used because the standard protobuf wrapper types actually
# alias the golang package for this, so we need to swap this out before
# attempting to use the golang plugin for protoc.
#
$(CSI_GO_TMP): STDWRAP = google/protobuf/wrappers.proto
$(CSI_GO_TMP): GOWRAP_PKG = github.com/golang/protobuf/ptypes/wrappers
$(CSI_GO_TMP): GOWRAP = $(STDWRAP:%.proto=$(GOWRAP_PKG)/wrappers.proto)
$(CSI_GO_TMP): PROTO_REWRITES = -e 's@"$(STDWRAP)"@"$(GOWRAP)"@g'
$(CSI_GO_TMP): $(CSI_PROTO) | $(PROTOC) $(PROTOC_GEN_GO)
@mkdir -p "$(@D)"
$(PROTOC) -I "$(<D)" --go_out=plugins=grpc:"$(@D)" "$<"
cat "$<" | sed $(PROTO_REWRITES) >"$(CSI_PROTO_TMP)"
$(PROTOC) -I "$(@D)" \
-I$(GOPATH)/src --go_out=plugins=grpc:"$(@D)" \
"$(CSI_PROTO_TMP)"

# The temp language bindings are compared to the ones that are
# versioned. If they are different then it means the language
Expand Down
Loading