Skip to content

Commit b837256

Browse files
authored
chore: make repometadata struct public (#4056)
Make `LibraryInfo` and its field public. This struct will be used in repo metadata generation in Go clients. For #3617
1 parent c3fe4ef commit b837256

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

internal/repometadata/repometadata.go

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ var (
3333
errNoServiceConfig = errors.New("library has no service config from which to get metadata")
3434
)
3535

36-
type libraryInfo struct {
37-
descriptionOverride string
38-
name string
39-
releaseLevel string
36+
// LibraryInfo contains information about a library that is not available in the service config.
37+
type LibraryInfo struct {
38+
// DescriptionOverride overrides the library description from the service config.
39+
DescriptionOverride string
40+
// Name is the name of the library distribution package.
41+
Name string
42+
// ReleaseLevel is the release level (e.g., "stable", "preview").
43+
ReleaseLevel string
4044
}
4145

4246
// RepoMetadata represents the .repo-metadata.json file structure.
@@ -101,36 +105,36 @@ func FromLibrary(library *config.Library, language, repo, googleapisDir, default
101105
if api.ServiceConfig == "" {
102106
return fmt.Errorf("failed to generate metadata for %s: %w", library.Name, errNoServiceConfig)
103107
}
104-
info := &libraryInfo{
105-
descriptionOverride: library.DescriptionOverride,
106-
name: library.Name,
107-
releaseLevel: library.ReleaseLevel,
108+
info := &LibraryInfo{
109+
DescriptionOverride: library.DescriptionOverride,
110+
Name: library.Name,
111+
ReleaseLevel: library.ReleaseLevel,
108112
}
109113
return FromAPI(api, info, language, repo, defaultVersion, outdir)
110114
}
111115

112116
// FromAPI generates the .repo-metadata.json file from a serviceconfig.API and additional library information.
113-
func FromAPI(api *serviceconfig.API, info *libraryInfo, language, repo, defaultVersion, outputDir string) error {
117+
func FromAPI(api *serviceconfig.API, info *LibraryInfo, language, repo, defaultVersion, outputDir string) error {
114118
clientDocURL := buildClientDocURL(language, extractNameFromAPIID(api.ServiceName))
115119
metadata := &RepoMetadata{
116120
APIID: api.ServiceName,
117121
NamePretty: cleanTitle(api.Title),
118122
DefaultVersion: defaultVersion,
119123
ClientDocumentation: clientDocURL,
120-
ReleaseLevel: info.releaseLevel,
124+
ReleaseLevel: info.ReleaseLevel,
121125
Language: language,
122126
LibraryType: "GAPIC_AUTO",
123127
Repo: repo,
124-
DistributionName: info.name,
128+
DistributionName: info.Name,
125129
}
126130

127131
metadata.ProductDocumentation = extractBaseProductURL(api.DocumentationURI)
128132
metadata.IssueTracker = api.NewIssueURI
129133
metadata.APIShortname = api.ShortName
130134
metadata.Name = api.ShortName
131135
metadata.APIDescription = api.Description
132-
if info.descriptionOverride != "" {
133-
metadata.APIDescription = info.descriptionOverride
136+
if info.DescriptionOverride != "" {
137+
metadata.APIDescription = info.DescriptionOverride
134138
}
135139

136140
data, err := json.MarshalIndent(metadata, "", " ")

0 commit comments

Comments
 (0)