Skip to content

Commit bedd158

Browse files
authored
chore(internal/librarian): add snippet directories to legacy state (#5137)
The `createLegacyLibrary` function is updated to include the generated snippets directory in both the `SourceRoots` and `ReleaseExcludePaths` fields for the legacy configuration. Snippet directory needs to be present in `SourceRoots` so that the updated snippet metadata can be copied from docker response to language repository. Snippet directory needs to be present in `ReleaseExcludePaths` so that changes in this directory will cause a release. See go/sdk-librarian-interim-state for more details. Fixes #5034
1 parent 4777507 commit bedd158

2 files changed

Lines changed: 35 additions & 26 deletions

File tree

internal/librarian/add.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,16 @@ func createLegacyLibrary(lib *config.Library) *legacyconfig.LibraryState {
252252
libAPIs = append(libAPIs, &legacyconfig.API{Path: api.Path})
253253
}
254254
return &legacyconfig.LibraryState{
255-
ID: lib.Name,
256-
Version: lib.Version,
257-
APIs: libAPIs,
258-
SourceRoots: []string{lib.Name},
259-
TagFormat: "{id}/v{version}",
255+
ID: lib.Name,
256+
Version: lib.Version,
257+
APIs: libAPIs,
258+
SourceRoots: []string{
259+
lib.Name,
260+
fmt.Sprintf("internal/generated/snippets/%s", lib.Name),
261+
},
262+
ReleaseExcludePaths: []string{
263+
fmt.Sprintf("internal/generated/snippets/%s/", lib.Name),
264+
},
265+
TagFormat: "{id}/v{version}",
260266
}
261267
}

internal/librarian/add_test.go

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -609,13 +609,14 @@ func TestSyncToStateYAML(t *testing.T) {
609609
SourceRoots: []string{"existing"},
610610
},
611611
{
612-
ID: "new",
613-
Version: "0.1.0",
614-
PreserveRegex: []string{},
615-
RemoveRegex: []string{},
616-
APIs: []*legacyconfig.API{{Path: "google/cloud/new/v1"}},
617-
SourceRoots: []string{"new"},
618-
TagFormat: "{id}/v{version}",
612+
ID: "new",
613+
Version: "0.1.0",
614+
PreserveRegex: []string{},
615+
RemoveRegex: []string{},
616+
APIs: []*legacyconfig.API{{Path: "google/cloud/new/v1"}},
617+
SourceRoots: []string{"new", "internal/generated/snippets/new"},
618+
ReleaseExcludePaths: []string{"internal/generated/snippets/new/"},
619+
TagFormat: "{id}/v{version}",
619620
},
620621
},
621622
},
@@ -636,22 +637,24 @@ func TestSyncToStateYAML(t *testing.T) {
636637
Image: "gcr.io/my-image:latest",
637638
Libraries: []*legacyconfig.LibraryState{
638639
{
639-
ID: "lib-a",
640-
Version: "2.0.0",
641-
PreserveRegex: []string{},
642-
RemoveRegex: []string{},
643-
APIs: []*legacyconfig.API{{Path: "google/cloud/lib-a/v1"}},
644-
SourceRoots: []string{"lib-a"},
645-
TagFormat: "{id}/v{version}",
640+
ID: "lib-a",
641+
Version: "2.0.0",
642+
PreserveRegex: []string{},
643+
RemoveRegex: []string{},
644+
APIs: []*legacyconfig.API{{Path: "google/cloud/lib-a/v1"}},
645+
SourceRoots: []string{"lib-a", "internal/generated/snippets/lib-a"},
646+
ReleaseExcludePaths: []string{"internal/generated/snippets/lib-a/"},
647+
TagFormat: "{id}/v{version}",
646648
},
647649
{
648-
ID: "lib-b",
649-
Version: "1.0.0",
650-
PreserveRegex: []string{},
651-
RemoveRegex: []string{},
652-
APIs: []*legacyconfig.API{{Path: "google/cloud/lib-b/v1"}},
653-
SourceRoots: []string{"lib-b"},
654-
TagFormat: "{id}/v{version}",
650+
ID: "lib-b",
651+
Version: "1.0.0",
652+
PreserveRegex: []string{},
653+
RemoveRegex: []string{},
654+
APIs: []*legacyconfig.API{{Path: "google/cloud/lib-b/v1"}},
655+
SourceRoots: []string{"lib-b", "internal/generated/snippets/lib-b"},
656+
ReleaseExcludePaths: []string{"internal/generated/snippets/lib-b/"},
657+
TagFormat: "{id}/v{version}",
655658
},
656659
},
657660
},

0 commit comments

Comments
 (0)