Skip to content

Commit 4cde632

Browse files
Merge pull request #4320 from justinsb/refactor_mockdataflow_to_use_registry
mockgcp: refactor mockdataflow to use registry pattern
2 parents 3d082a1 + fb9cedc commit 4cde632

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

mockgcp/mock_http_roundtrip.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ import (
6767
"github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/mockcontainer"
6868
"github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/mockcontaineranalysis"
6969
"github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/mockdatacatalog"
70-
"github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/mockdataflow"
70+
_ "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/mockdataflow"
7171
"github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/mockdataform"
7272
"github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/mockdataplex"
7373
_ "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/mockdataproc"
@@ -213,7 +213,6 @@ func NewMockRoundTripper(ctx context.Context, k8sClient client.Client, storage s
213213
services = append(services, mockcloudidentity.New(env, storage))
214214
services = append(services, mockcontainer.New(env, storage))
215215
services = append(services, mockcertificatemanager.New(env, storage))
216-
services = append(services, mockdataflow.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/mockdataflow/normalize.go

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2022 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 mockdataflow
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+
// No-op for now
25+
}
26+
27+
func (s *MockService) Previsit(event mockgcpregistry.Event, replacements mockgcpregistry.NormalizingVisitor) {
28+
// No-op for now
29+
}

mockgcp/mockdataflow/service.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@ import (
2424
"github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/common/httpmux"
2525
"github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/common/operations"
2626
pb "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/generated/mockgcp/dataflow/v1beta3"
27+
"github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/mockgcpregistry"
2728
"github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/pkg/storage"
2829
)
2930

31+
func init() {
32+
mockgcpregistry.Register(New)
33+
}
34+
3035
// MockService represents a mocked dataflow service.
3136
type MockService struct {
3237
*common.MockEnvironment
@@ -35,7 +40,7 @@ type MockService struct {
3540
}
3641

3742
// New creates a MockService.
38-
func New(env *common.MockEnvironment, storage storage.Storage) *MockService {
43+
func New(env *common.MockEnvironment, storage storage.Storage) mockgcpregistry.MockService {
3944
s := &MockService{
4045
MockEnvironment: env,
4146
storage: storage,

0 commit comments

Comments
 (0)