Skip to content

Commit e7bf98e

Browse files
authored
feat: do not derive path for veneer (#3237)
Do not derive googleapis path and service config for veneer library because these two parameters live in modules, not in channels For #3193
1 parent 76dbb68 commit e7bf98e

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

internal/librarian/generate.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,17 @@ func prepareLibrary(language string, lib *config.Library, defaults *config.Defau
244244
// If no channels are specified, create an empty channel first
245245
lib.Channels = append(lib.Channels, &config.Channel{})
246246
}
247-
for _, ch := range lib.Channels {
248-
if ch.Path == "" {
249-
ch.Path = deriveChannelPath(language, lib)
250-
}
251-
if ch.ServiceConfig == "" {
252-
ch.ServiceConfig = deriveServiceConfig(ch.Path)
247+
248+
// The googleapis path of a veneer library lives in language-specific configurations,
249+
// so we only need to derive the path and service config for non-veneer libraries.
250+
if !lib.Veneer {
251+
for _, ch := range lib.Channels {
252+
if ch.Path == "" {
253+
ch.Path = deriveChannelPath(language, lib)
254+
}
255+
if ch.ServiceConfig == "" {
256+
ch.ServiceConfig = deriveServiceConfig(ch.Path)
257+
}
253258
}
254259
}
255260

internal/librarian/generate_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,20 @@ func TestPrepareLibrary(t *testing.T) {
254254
name: "rust with no channels creates default and derives path",
255255
language: "rust",
256256
channels: nil,
257-
wantErr: false,
258257
wantOutput: "src/generated/cloud/test/v1",
259258
wantChannelPath: "google/cloud/test/v1",
260259
wantServiceConfig: "google/cloud/test/v1/test_v1.yaml",
261260
},
261+
{
262+
name: "veneer rust with no channels does not derive path and service config",
263+
language: "rust",
264+
output: "src/storage/test/v1",
265+
veneer: true,
266+
channels: nil,
267+
wantOutput: "src/storage/test/v1",
268+
wantChannelPath: "",
269+
wantServiceConfig: "",
270+
},
262271
{
263272
name: "veneer without output returns error",
264273
veneer: true,

0 commit comments

Comments
 (0)