diff --git a/internal/registry/vendor.go b/internal/registry/vendor.go index bc129e7..5c0a5f9 100644 --- a/internal/registry/vendor.go +++ b/internal/registry/vendor.go @@ -35,13 +35,16 @@ func VendorRegistryModule(module *model.Module, client v1.RegistryClient) error outputPath := module.OutputFolder if module.Path != "" { - modulePath := filepath.Dir(module.Path) + modulePath := module.Path if strings.HasSuffix(module.Path, ".proto") { // skip if the file is not in the module path if originalFilename != module.Path { continue } + + // get directory + modulePath = filepath.Dir(module.Path) } else { // skip if the file is not in the module path if !strings.HasPrefix(originalFilename, modulePath) { @@ -50,7 +53,7 @@ func VendorRegistryModule(module *model.Module, client v1.RegistryClient) error } if outputPath != "" { - originalFilename = strings.Replace(originalFilename, filepath.Dir(module.Path), outputPath, 1) + originalFilename = strings.Replace(originalFilename, modulePath, outputPath, 1) } } else { if outputPath != "" { diff --git a/pbuf.yaml b/pbuf.yaml index c4bfeb6..0afc1a3 100644 --- a/pbuf.yaml +++ b/pbuf.yaml @@ -7,7 +7,7 @@ modules: - name: pbufio/pbuf-registry tag: v0.2.0 path: api/pbuf-registry - out: third_party + out: third_party/pbuf-registry - name: googleapis repository: https://github.com/googleapis/googleapis path: google/api diff --git a/third_party/api/v1/registry.proto b/third_party/api/v1/registry.proto deleted file mode 100644 index c84ca1d..0000000 --- a/third_party/api/v1/registry.proto +++ /dev/null @@ -1,180 +0,0 @@ -syntax = "proto3"; - -package pbufregistry.v1; - -import "google/api/annotations.proto"; - -option go_package = "pbufregistry/api/v1;v1"; - -// Registry service definition -service Registry { - // List all registered modules - rpc ListModules(ListModulesRequest) returns (ListModulesResponse) { - option (google.api.http) = { - get: "/v1/modules" - }; - } - - // Get a module by name - rpc GetModule(GetModuleRequest) returns (Module) { - option (google.api.http) = { - get: "/v1/modules/{name}" - }; - } - - // Register a module - rpc RegisterModule(RegisterModuleRequest) returns (Module) { - option (google.api.http) = { - post: "/v1/modules" - body: "*" - }; - } - - // Pull a module tag - rpc PullModule(PullModuleRequest) returns (PullModuleResponse) { - option (google.api.http) = { - get: "/v1/modules/{name}/tags/{tag}" - }; - } - - // Push a module - rpc PushModule(PushModuleRequest) returns (Module) { - option (google.api.http) = { - post: "/v1/modules/push" - body: "*" - }; - } - - // Delete a module by name - rpc DeleteModule(DeleteModuleRequest) returns (DeleteModuleResponse) { - option (google.api.http) = { - delete: "/v1/modules/{name}" - }; - } - - // Delete a specific module tag - rpc DeleteModuleTag(DeleteModuleTagRequest) returns (DeleteModuleTagResponse) { - option (google.api.http) = { - delete: "/v1/modules/{name}/tags/{tag}" - }; - } -} - -// ListModulesRequest is the request message for ListModules. -message ListModulesRequest { - // The maximum number of modules to return. - // The service may return fewer than this value. - // If unspecified, at most 50 modules will be returned. - // The maximum value is 1000; values above 1000 will be coerced to 1000. - int32 page_size = 1 [json_name = "page_size"]; - - // A page token, received from a previous `ListModules` call. - // Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to `ListModules` must match - // the call that provided the page token. - string page_token = 2 [json_name = "page_token"]; -} - -// ListModulesResponse is the response message for ListModules. -message ListModulesResponse { - // The modules requested. - repeated Module modules = 1; - - // A token, which can be sent as `page_token` to retrieve the next page. - // If this field is omitted, there are no subsequent pages. - string next_page_token = 2 [json_name = "next_page_token"]; -} - -// GetModuleRequest is the request message for GetModule. -message GetModuleRequest { - // The name of the module to retrieve. - string name = 1; -} - -// PullModuleRequest is the request message for PullModule. -message PullModuleRequest { - // The name of the module to retrieve. - string name = 1; - - // The tag of the module to retrieve. - string tag = 2; -} - -// PullModuleResponse is the response message for PullModule. -message PullModuleResponse { - // The module requested. - Module module = 1; - - // The protofiles of the module. - repeated ProtoFile protofiles = 2; -} - -// RegisterModuleRequest is the request message for RegisterModule. -message RegisterModuleRequest { - // Module name - string name = 1; -} - -// PushModuleRequest is the request message for PushModule. -message PushModuleRequest { - // The module to register. - string module_name = 1 [json_name = "module_name"]; - - // The tag of the module to register. - string tag = 2; - - // Protofiles - repeated ProtoFile protofiles = 3; -} - -// DeleteModuleRequest is the request message for DeleteModule. -message DeleteModuleRequest { - // The name of the module to delete. - string name = 1; -} - -// DeleteModuleResponse is the response message for DeleteModule. -message DeleteModuleResponse { - // The name of the deleted module. - string name = 1; -} - -// DeleteModuleTagRequest is the request message for DeleteModuleTag. -message DeleteModuleTagRequest { - // The name of the module to delete. - string name = 1; - - // The tag of the module to delete. - string tag = 2; -} - -// DeleteModuleTagResponse is the response message for DeleteModuleTag. -message DeleteModuleTagResponse { - // The name of the deleted module. - string name = 1; - - // The tag of the deleted module. - string tag = 2; -} - -// Module is a module registered in the registry. -message Module { - // id is the unique identifier of the module. - string id = 1; - - // The name of the module. - string name = 2; - - // The tags of the module. - repeated string tags = 3; -} - -// ProtoFile is a proto file registered in the registry. -message ProtoFile { - // The filename of the proto file. - string filename = 1; - - // The content of the proto file. - string content = 2; -} \ No newline at end of file