Skip to content

Commit b190684

Browse files
Merge pull request #4317 from justinsb/move_discoveryengine_to_new_style
mockgcp: refactor discoveryengine to "registration" style
2 parents 89f48dd + 3633a4a commit b190684

File tree

4 files changed

+44
-9
lines changed

4 files changed

+44
-9
lines changed

mockgcp/mock_http_roundtrip.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ import (
7272
"github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/mockdataplex"
7373
_ "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/mockdataproc"
7474
"github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/mockdatastream"
75-
"github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/mockdiscoveryengine"
75+
_ "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/mockdiscoveryengine"
7676
"github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/mockdocumentai"
7777
"github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/mockedgecontainer"
7878
"github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/mockedgenetwork"
@@ -213,7 +213,6 @@ func NewMockRoundTripper(ctx context.Context, k8sClient client.Client, storage s
213213
services = append(services, mockcontainer.New(env, storage))
214214
services = append(services, mockcertificatemanager.New(env, storage))
215215
services = append(services, mockdataflow.New(env, storage))
216-
services = append(services, mockdiscoveryengine.New(env, storage))
217216
services = append(services, mockedgecontainer.New(env, storage))
218217
services = append(services, mockfirestore.New(env, storage))
219218
services = append(services, mockgkemulticloud.New(env, storage))

mockgcp/mockdiscoveryengine/datastore.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ import (
3535
"github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/common/projects"
3636
)
3737

38-
type dataStoreService struct {
39-
*MockService
40-
pb.UnimplementedDataStoreServiceServer
41-
}
42-
4338
func (s *dataStoreService) CreateDataStore(ctx context.Context, req *pb.CreateDataStoreRequest) (*longrunningpb.Operation, error) {
4439
reqName := fmt.Sprintf("%s/dataStores/%s", req.GetParent(), req.GetDataStoreId())
4540
name, err := s.parseDataStoreName(reqName)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2025 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package mockdiscoveryengine
16+
17+
import (
18+
"github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/mockgcpregistry"
19+
)
20+
21+
var _ mockgcpregistry.SupportsNormalization = &MockService{}
22+
23+
func (s *MockService) ConfigureVisitor(url string, replacements mockgcpregistry.NormalizingVisitor) {
24+
}
25+
26+
func (s *MockService) Previsit(event mockgcpregistry.Event, replacements mockgcpregistry.NormalizingVisitor) {
27+
}

mockgcp/mockdiscoveryengine/service.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022 Google LLC
1+
// Copyright 2025 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -25,9 +25,18 @@ import (
2525
"github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/common/httpmux"
2626
"github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/common/operations"
2727
pbhttp "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/generated/google/cloud/discoveryengine/v1"
28+
"github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/mockgcpregistry"
2829
"github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/pkg/storage"
2930
)
3031

32+
// +tool:mockgcp-service
33+
// http.host: discoveryengine.googleapis.com
34+
// proto.service: google.cloud.discoveryengine.v1.DataStoreService
35+
36+
func init() {
37+
mockgcpregistry.Register(New)
38+
}
39+
3140
// MockService represents a mocked networkservices service.
3241
type MockService struct {
3342
*common.MockEnvironment
@@ -36,8 +45,13 @@ type MockService struct {
3645
operations *operations.Operations
3746
}
3847

48+
type dataStoreService struct {
49+
*MockService
50+
pb.UnimplementedDataStoreServiceServer
51+
}
52+
3953
// New creates a MockService.
40-
func New(env *common.MockEnvironment, storage storage.Storage) *MockService {
54+
func New(env *common.MockEnvironment, storage storage.Storage) mockgcpregistry.MockService {
4155
s := &MockService{
4256
MockEnvironment: env,
4357
storage: storage,

0 commit comments

Comments
 (0)