Skip to content

Commit cc5cf26

Browse files
authored
feat(repometadata): handle APIs with no service config (#4230)
Removes a check to see whether there's a service config. We never access the service config directly within repometadata.FromAPI, so it's fine for it to be absent. We may well have very little information to put in the RepoMetadata returned by functions, but that's okay.
1 parent dacc1d1 commit cc5cf26

2 files changed

Lines changed: 15 additions & 14 deletions

File tree

internal/repometadata/repometadata.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ const (
3636
)
3737

3838
var (
39-
errNoAPIs = errors.New("library has no APIs from which to get metadata")
40-
errNoServiceConfig = errors.New("library has no service config from which to get metadata")
39+
errNoAPIs = errors.New("library has no APIs from which to get metadata")
4140
)
4241

4342
// RepoMetadata represents the .repo-metadata.json file structure.
@@ -122,9 +121,6 @@ func FromLibrary(config *config.Config, library *config.Library, googleapisDir s
122121
if err != nil {
123122
return nil, fmt.Errorf("failed to find API for path %s: %w", firstAPIPath, err)
124123
}
125-
if api.ServiceConfig == "" {
126-
return nil, fmt.Errorf("failed to generate metadata for %s: %w", library.Name, errNoServiceConfig)
127-
}
128124
return fromAPI(config, api, library), nil
129125
}
130126

internal/repometadata/repometadata_test.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ func TestFromLibrary(t *testing.T) {
7474
APIDescription: "Stores, manages, and secures access to application secrets.",
7575
},
7676
},
77+
{
78+
name: "no service config",
79+
library: &config.Library{
80+
Name: "google-longrunning",
81+
ReleaseLevel: "stable",
82+
APIs: []*config.API{{Path: "google/longrunning"}},
83+
},
84+
want: &RepoMetadata{
85+
ReleaseLevel: "stable",
86+
Language: "python",
87+
Repo: "googleapis/google-cloud-python",
88+
DistributionName: "google-longrunning",
89+
},
90+
},
7791
} {
7892
t.Run(test.name, func(t *testing.T) {
7993
tmpDir := t.TempDir()
@@ -122,15 +136,6 @@ func TestFromLibrary_Error(t *testing.T) {
122136
},
123137
// Error returned by serviceconfig.Find isn't easily distinguished
124138
},
125-
{
126-
name: "no service config",
127-
library: &config.Library{
128-
Name: "google-longrunning",
129-
ReleaseLevel: "stable",
130-
APIs: []*config.API{{Path: "google/longrunning"}},
131-
},
132-
wantErr: errNoServiceConfig,
133-
},
134139
} {
135140
t.Run(test.name, func(t *testing.T) {
136141
cfg := &config.Config{Language: serviceconfig.LangPython}

0 commit comments

Comments
 (0)