Skip to content

Commit c142bed

Browse files
authored
fix(devtools/cmd/migrate-sidekick): add hardcoded exclusion list for veneer detection (#3317)
Adds a hardcoded list to excluded when identifying veneer libraries. The migrate tool treats any library with a Cargo.toml file outside the src/generated directory as a veneer library. This heuristic approach is a bit too broad and included libraries that are not generated: - [echo-server](https://github.com/googleapis/google-cloud-rust/blob/main/src/gax-internal/echo-server/src/lib.rs): test util that is handwritten - [gcp-sdk](https://github.com/googleapis/google-cloud-rust/blob/main/src/root/Cargo.toml): workspace Crate For #3313
1 parent 59cd235 commit c142bed

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

devtools/cmd/migrate-sidekick/main.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ var (
5151
errUnableToCalculateOutputPath = errors.New("unable to calculate output path")
5252
)
5353

54+
var excludedVeneerLibraries = map[string]struct{}{
55+
"echo-server": {},
56+
"gcp-sdk": {},
57+
}
58+
5459
// SidekickConfig represents the structure of a .sidekick.toml file.
5560
type SidekickConfig struct {
5661
General struct {
@@ -505,6 +510,12 @@ func buildVeneer(files []string) (map[string]*config.Library, error) {
505510
if err != nil {
506511
return nil, err
507512
}
513+
514+
if _, ok := excludedVeneerLibraries[cargo.Package.Name]; ok {
515+
slog.Info("Excluding hardcoded veneer library", "name", cargo.Package.Name)
516+
continue
517+
}
518+
508519
dir := filepath.Dir(file)
509520
rustModules, err := buildModules(dir)
510521
if err != nil {

devtools/cmd/migrate-sidekick/main_test.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,58 @@ func TestBuildVeneer(t *testing.T) {
507507
},
508508
},
509509
},
510+
{
511+
name: "excluded_library",
512+
files: []string{
513+
"testdata/build-veneer/success/lib-1/Cargo.toml",
514+
"testdata/build-veneer/success/echo-server/Cargo.toml",
515+
},
516+
want: map[string]*config.Library{
517+
"google-cloud-storage": {
518+
Name: "google-cloud-storage",
519+
Veneer: true,
520+
Output: "testdata/build-veneer/success/lib-1",
521+
Version: "1.5.0",
522+
CopyrightYear: "2025",
523+
Rust: &config.RustCrate{
524+
Modules: []*config.RustModule{
525+
{
526+
DisabledRustdocWarnings: []string{},
527+
GenerateSetterSamples: true,
528+
ModuleRoots: nil,
529+
HasVeneer: true,
530+
IncludedIds: []string{
531+
".google.storage.v2.Storage.DeleteBucket",
532+
".google.storage.v2.Storage.GetBucket",
533+
".google.storage.v2.Storage.CreateBucket",
534+
".google.storage.v2.Storage.ListBuckets",
535+
},
536+
IncludeGrpcOnlyMethods: true,
537+
NameOverrides: ".google.storage.v2.Storage=StorageControl",
538+
Output: "testdata/build-veneer/success/lib-1/dir-1",
539+
RoutingRequired: true,
540+
ServiceConfig: "google/storage/v2/storage_v2.yaml",
541+
SkippedIds: []string{".google.iam.v1.ResourcePolicyMember"},
542+
Source: "google/storage/v2",
543+
Template: "grpc-client",
544+
TitleOverride: "Cloud Firestore API",
545+
},
546+
{
547+
GenerateSetterSamples: false,
548+
ModulePath: "crate::generated::gapic_control::model",
549+
ModuleRoots: map[string]string{
550+
"project-root": ".",
551+
},
552+
NameOverrides: ".google.storage.control.v2.IntelligenceConfig.Filter.cloud_storage_buckets=CloudStorageBucketsOneOf",
553+
Output: "testdata/build-veneer/success/lib-1/dir-2/dirdir-2",
554+
Source: "google/storage/control/v2",
555+
Template: "convert-prost",
556+
},
557+
},
558+
},
559+
},
560+
},
561+
},
510562
} {
511563
t.Run(test.name, func(t *testing.T) {
512564
got, err := buildVeneer(test.files)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[package]
2+
name = "echo-server"
3+
version = "0.1.0"

0 commit comments

Comments
 (0)