Skip to content
Merged
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
10 changes: 5 additions & 5 deletions internal/librariangen/generate/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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)
Expand All @@ -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)

Expand Down Expand Up @@ -264,4 +264,4 @@ func unzip(src, dest string) error {
}
}
return nil
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,30 @@
// 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"
"fmt"
"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 {
Expand Down Expand Up @@ -75,4 +91,4 @@ func ParseLibrary(path string) (*Library, error) {
}

return &req, nil
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package request
package message

import (
"os"
Expand Down Expand Up @@ -95,4 +95,4 @@ func TestParseLibrary_FileNotFound(t *testing.T) {
if err == nil {
t.Error("Parse() expected error for non-existent file, got nil")
}
}
}
Loading