Skip to content

Commit 0e4f96f

Browse files
authored
feat(internal/serviceconfig): add API overrides data (#3524)
Additional API overrides data is added based on the google-cloud-rust librarian.yaml. This data will be used by `librarian generate` in a follow up PR and removed from the google-cloud-rust librarian.yaml.
1 parent dccc40c commit 0e4f96f

File tree

3 files changed

+65
-14
lines changed

3 files changed

+65
-14
lines changed

internal/serviceconfig/override.go

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,66 @@
1414

1515
package serviceconfig
1616

17-
// channelToServiceConfigOverrides defines API channels whose service configuration does not live
18-
// alongside the API definition directory.
19-
//
20-
// For these entries, the service config must be resolved explicitly rather
21-
// than discovered via directory traversal. All paths are relative to the
22-
// googleapis root.
23-
var channelToServiceConfigOverrides = map[string]string{
24-
"google/cloud/aiplatform/schema/predict/instance": "google/cloud/aiplatform/v1/schema/aiplatform_v1.yaml",
25-
"google/cloud/aiplatform/schema/predict/params": "google/cloud/aiplatform/v1/schema/aiplatform_v1.yaml",
26-
"google/cloud/aiplatform/schema/predict/prediction": "google/cloud/aiplatform/v1/schema/aiplatform_v1.yaml",
27-
"google/cloud/aiplatform/schema/trainingjob/definition": "google/cloud/aiplatform/v1/schema/aiplatform_v1.yaml",
17+
const (
18+
titleAppsScriptTypes = "Google Apps Script Types"
19+
titleGKEHubTypes = "GKE Hub Types"
20+
serviceConfigAIPlatformSchema = "google/cloud/aiplatform/v1/schema/aiplatform_v1.yaml"
21+
)
22+
23+
// Override represents a single API entry with its overrides.
24+
type Override struct {
25+
ServiceConfig string
26+
Title string
27+
}
28+
29+
// Overrides defines the set of API definitions and their overrides.
30+
var Overrides = map[string]Override{
31+
"google/apps/script/type": {
32+
Title: titleAppsScriptTypes,
33+
},
34+
"google/apps/script/type/calendar": {
35+
Title: titleAppsScriptTypes,
36+
},
37+
"google/apps/script/type/docs": {
38+
Title: titleAppsScriptTypes,
39+
},
40+
"google/apps/script/type/drive": {
41+
Title: titleAppsScriptTypes,
42+
},
43+
"google/apps/script/type/gmail": {
44+
Title: titleAppsScriptTypes,
45+
},
46+
"google/apps/script/type/sheets": {
47+
Title: titleAppsScriptTypes,
48+
},
49+
"google/apps/script/type/slides": {
50+
Title: titleAppsScriptTypes,
51+
},
52+
"google/cloud/aiplatform/v1/schema/predict/instance": {
53+
ServiceConfig: serviceConfigAIPlatformSchema,
54+
},
55+
"google/cloud/aiplatform/v1/schema/predict/params": {
56+
ServiceConfig: serviceConfigAIPlatformSchema,
57+
},
58+
"google/cloud/aiplatform/v1/schema/predict/prediction": {
59+
ServiceConfig: serviceConfigAIPlatformSchema,
60+
},
61+
"google/cloud/aiplatform/v1/schema/trainingjob/definition": {
62+
ServiceConfig: serviceConfigAIPlatformSchema,
63+
},
64+
"google/cloud/gkehub/v1/configmanagement": {
65+
Title: titleGKEHubTypes,
66+
},
67+
"google/cloud/gkehub/v1/multiclusteringress": {
68+
Title: titleGKEHubTypes,
69+
},
70+
"google/cloud/orgpolicy/v1": {
71+
Title: "Organization Policy Types",
72+
},
73+
"google/cloud/oslogin/common": {
74+
Title: "Cloud OS Login Common Types",
75+
},
76+
"google/identity/accesscontextmanager/type": {
77+
Title: "Access Context Manager Types",
78+
},
2879
}

internal/serviceconfig/serviceconfig.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ func Read(serviceConfigPath string) (*Service, error) {
7979
// "google/cloud/secretmanager/v1"). Returns the service config path relative
8080
// to googleapisDir, or empty string if not found.
8181
func Find(googleapisDir, channel string) (string, error) {
82-
if config, ok := channelToServiceConfigOverrides[channel]; ok {
83-
return config, nil
82+
if override, ok := Overrides[channel]; ok && override.ServiceConfig != "" {
83+
return override.ServiceConfig, nil
8484
}
8585

8686
dir := filepath.Join(googleapisDir, channel)

internal/serviceconfig/serviceconfig_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func TestFind(t *testing.T) {
104104
},
105105
{
106106
name: "override",
107-
channel: "google/cloud/aiplatform/schema/predict/instance",
107+
channel: "google/cloud/aiplatform/v1/schema/predict/instance",
108108
want: "google/cloud/aiplatform/v1/schema/aiplatform_v1.yaml",
109109
},
110110
} {

0 commit comments

Comments
 (0)