istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pilot/pkg/serviceregistry/mock/discovery_mock.go (about) 1 // Copyright Istio Authors 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 mock 16 17 import ( 18 "istio.io/istio/pilot/pkg/model" 19 "istio.io/istio/pkg/config/host" 20 ) 21 22 var ( 23 // HelloService is a mock service with `hello.default.svc.cluster.local` as 24 // a hostname and `10.1.0.0` for ip 25 HelloService = MakeService(ServiceArgs{ 26 Hostname: "hello.default.svc.cluster.local", 27 Address: "10.1.0.0", 28 ServiceAccounts: []string{}, 29 ClusterID: "cluster-1", 30 }) 31 32 // ReplicatedFooServiceName is a service replicated in all clusters. 33 ReplicatedFooServiceName = host.Name("foo.default.svc.cluster.local") 34 ReplicatedFooServiceV1 = MakeService(ServiceArgs{ 35 Hostname: ReplicatedFooServiceName, 36 Address: "10.3.0.0", 37 ServiceAccounts: []string{ 38 "spiffe://cluster.local/ns/default/sa/foo1", 39 "spiffe://cluster.local/ns/default/sa/foo-share", 40 }, 41 ClusterID: "", 42 }) 43 ReplicatedFooServiceV2 = MakeService(ServiceArgs{ 44 Hostname: ReplicatedFooServiceName, 45 Address: "10.3.0.1", 46 ServiceAccounts: []string{ 47 "spiffe://cluster.local/ns/default/sa/foo2", 48 "spiffe://cluster.local/ns/default/sa/foo-share", 49 }, 50 ClusterID: "", 51 }) 52 53 // WorldService is a mock service with `world.default.svc.cluster.local` as 54 // a hostname and `10.2.0.0` for ip 55 WorldService = MakeService(ServiceArgs{ 56 Hostname: "world.default.svc.cluster.local", 57 Address: "10.2.0.0", 58 ServiceAccounts: []string{ 59 "spiffe://cluster.local/ns/default/sa/world1", 60 "spiffe://cluster.local/ns/default/sa/world2", 61 }, 62 ClusterID: "cluster-2", 63 }) 64 65 // ExtHTTPService is a mock external HTTP service 66 ExtHTTPService = MakeExternalHTTPService("httpbin.default.svc.cluster.local", 67 true, "") 68 69 // ExtHTTPSService is a mock external HTTPS service 70 ExtHTTPSService = MakeExternalHTTPSService("httpsbin.default.svc.cluster.local", 71 true, "") 72 73 // HelloInstanceV0 is a mock IP address for v0 of HelloService 74 HelloInstanceV0 = MakeIP(HelloService, 0) 75 76 // HelloProxyV0 is a mock proxy v0 of HelloService 77 HelloProxyV0 = model.Proxy{ 78 Type: model.SidecarProxy, 79 IPAddresses: []string{HelloInstanceV0}, 80 ID: "v0.default", 81 DNSDomain: "default.svc.cluster.local", 82 IstioVersion: model.MaxIstioVersion, 83 Metadata: &model.NodeMetadata{}, 84 } 85 )