|
33 | 33 | errNoServiceConfig = errors.New("library has no service config from which to get metadata") |
34 | 34 | ) |
35 | 35 |
|
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 |
44 | | -} |
45 | | - |
46 | 36 | // RepoMetadata represents the .repo-metadata.json file structure. |
47 | 37 | type RepoMetadata struct { |
48 | 38 | // APIDescription is the description of the API. |
@@ -105,36 +95,31 @@ func FromLibrary(library *config.Library, language, repo, googleapisDir, default |
105 | 95 | if api.ServiceConfig == "" { |
106 | 96 | return fmt.Errorf("failed to generate metadata for %s: %w", library.Name, errNoServiceConfig) |
107 | 97 | } |
108 | | - info := &LibraryInfo{ |
109 | | - DescriptionOverride: library.DescriptionOverride, |
110 | | - Name: library.Name, |
111 | | - ReleaseLevel: library.ReleaseLevel, |
112 | | - } |
113 | | - return FromAPI(api, info, language, repo, defaultVersion, outdir) |
| 98 | + return FromAPI(api, library, language, repo, defaultVersion, outdir) |
114 | 99 | } |
115 | 100 |
|
116 | | -// FromAPI generates the .repo-metadata.json file from a serviceconfig.API and additional library information. |
117 | | -func FromAPI(api *serviceconfig.API, info *LibraryInfo, language, repo, defaultVersion, outputDir string) error { |
| 101 | +// FromAPI generates the .repo-metadata.json file from a serviceconfig.API and library information. |
| 102 | +func FromAPI(api *serviceconfig.API, library *config.Library, language, repo, defaultVersion, outputDir string) error { |
118 | 103 | clientDocURL := buildClientDocURL(language, extractNameFromAPIID(api.ServiceName)) |
119 | | - metadata := &RepoMetadata{ |
120 | | - APIID: api.ServiceName, |
121 | | - NamePretty: cleanTitle(api.Title), |
122 | | - DefaultVersion: defaultVersion, |
123 | | - ClientDocumentation: clientDocURL, |
124 | | - ReleaseLevel: info.ReleaseLevel, |
125 | | - Language: language, |
126 | | - LibraryType: "GAPIC_AUTO", |
127 | | - Repo: repo, |
128 | | - DistributionName: info.Name, |
| 104 | + apiDescription := api.Description |
| 105 | + if library.DescriptionOverride != "" { |
| 106 | + apiDescription = library.DescriptionOverride |
129 | 107 | } |
130 | | - |
131 | | - metadata.ProductDocumentation = extractBaseProductURL(api.DocumentationURI) |
132 | | - metadata.IssueTracker = api.NewIssueURI |
133 | | - metadata.APIShortname = api.ShortName |
134 | | - metadata.Name = api.ShortName |
135 | | - metadata.APIDescription = api.Description |
136 | | - if info.DescriptionOverride != "" { |
137 | | - metadata.APIDescription = info.DescriptionOverride |
| 108 | + metadata := &RepoMetadata{ |
| 109 | + APIDescription: apiDescription, |
| 110 | + APIID: api.ServiceName, |
| 111 | + APIShortname: api.ShortName, |
| 112 | + ClientDocumentation: clientDocURL, |
| 113 | + DefaultVersion: defaultVersion, |
| 114 | + DistributionName: library.Name, |
| 115 | + IssueTracker: api.NewIssueURI, |
| 116 | + Language: language, |
| 117 | + LibraryType: "GAPIC_AUTO", |
| 118 | + Name: api.ShortName, |
| 119 | + NamePretty: cleanTitle(api.Title), |
| 120 | + ProductDocumentation: extractBaseProductURL(api.DocumentationURI), |
| 121 | + ReleaseLevel: library.ReleaseLevel, |
| 122 | + Repo: repo, |
138 | 123 | } |
139 | 124 |
|
140 | 125 | data, err := json.MarshalIndent(metadata, "", " ") |
|
0 commit comments