diff --git a/internal/librariangen/generate/generator.go b/internal/librariangen/generate/generator.go index 2ecf3c05a5..8a1b00e521 100644 --- a/internal/librariangen/generate/generator.go +++ b/internal/librariangen/generate/generator.go @@ -27,15 +27,15 @@ import ( "cloud.google.com/java/internal/librariangen/bazel" "cloud.google.com/java/internal/librariangen/execv" + "cloud.google.com/java/internal/librariangen/message" "cloud.google.com/java/internal/librariangen/protoc" - "cloud.google.com/java/internal/librariangen/request" ) // Test substitution vars. var ( bazelParse = bazel.Parse execvRun = execv.Run - requestParse = request.ParseLibrary + requestParse = message.ParseLibrary protocBuild = protoc.Build ) @@ -113,7 +113,7 @@ func Generate(ctx context.Context, cfg *Config) error { // invokeProtoc handles the protoc GAPIC generation logic for the 'generate' CLI command. // It reads a request file, and for each API specified, it invokes protoc // to generate the client library. It returns the module path and the path to the service YAML. -func invokeProtoc(ctx context.Context, cfg *Config, generateReq *request.Library) error { +func invokeProtoc(ctx context.Context, cfg *Config, generateReq *message.Library) error { for _, api := range generateReq.APIs { apiServiceDir := filepath.Join(cfg.SourceDir, api.Path) slog.Info("processing api", "service_dir", apiServiceDir) @@ -135,7 +135,7 @@ func invokeProtoc(ctx context.Context, cfg *Config, generateReq *request.Library // readGenerateReq reads generate-request.json from the librarian-tool input directory. // The request file tells librariangen which library and APIs to generate. // It is prepared by the Librarian tool and mounted at /librarian. -func readGenerateReq(librarianDir string) (*request.Library, error) { +func readGenerateReq(librarianDir string) (*message.Library, error) { reqPath := filepath.Join(librarianDir, "generate-request.json") slog.Debug("librariangen: reading generate request", "path", reqPath) @@ -264,4 +264,4 @@ func unzip(src, dest string) error { } } return nil -} \ No newline at end of file +} diff --git a/internal/librariangen/request/request.go b/internal/librariangen/message/message.go similarity index 82% rename from internal/librariangen/request/request.go rename to internal/librariangen/message/message.go index 72734e1edc..fc032bd540 100644 --- a/internal/librariangen/request/request.go +++ b/internal/librariangen/message/message.go @@ -12,7 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -package request +// Package message defines data types which the Librarian CLI and language +// containers exchange. +// There shouldn't be CLI-specific data type or language container-specific +// data types in this package. +// TODO(b/447404382): Move this package to the https://github.com/googleapis/librarian +// GitHub repository once the interface is finalized. +package message import ( "encoding/json" @@ -20,6 +26,16 @@ import ( "os" ) +// ReleaseInitRequest is the structure of the release-init-request.json file. +type ReleaseInitRequest struct { + Libraries []*Library `json:"libraries"` +} + +// ReleaseInitResponse is the structure of the release-init-response.json file. +type ReleaseInitResponse struct { + Error string `json:"error,omitempty"` +} + // Library is the combination of all the fields used by CLI requests and responses. // Each CLI command has its own request/response type, but they all use Library. type Library struct { @@ -75,4 +91,4 @@ func ParseLibrary(path string) (*Library, error) { } return &req, nil -} \ No newline at end of file +} diff --git a/internal/librariangen/request/request_test.go b/internal/librariangen/message/message_test.go similarity index 99% rename from internal/librariangen/request/request_test.go rename to internal/librariangen/message/message_test.go index 03f05b2b23..2599570313 100644 --- a/internal/librariangen/request/request_test.go +++ b/internal/librariangen/message/message_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package request +package message import ( "os" @@ -95,4 +95,4 @@ func TestParseLibrary_FileNotFound(t *testing.T) { if err == nil { t.Error("Parse() expected error for non-existent file, got nil") } -} \ No newline at end of file +}