istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pkg/test/framework/resource/resource.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 resource 16 17 import "fmt" 18 19 // Resource of a resource. 20 type Resource interface { 21 // ID used for debugging the resource instance. 22 ID() ID 23 } 24 25 // ID for the resource instance. This is allocated by the framework and passed here. 26 type ID interface { 27 fmt.Stringer 28 } 29 30 var _ ID = FakeID("") 31 32 // FakeID used for testing. 33 type FakeID string 34 35 func (id FakeID) String() string { 36 return string(id) 37 } 38 39 var _ Resource = &FakeResource{} 40 41 // FakeResource used for testing. 42 type FakeResource struct { 43 IDValue string 44 OtherValue string 45 } 46 47 func (f *FakeResource) ID() ID { 48 return FakeID(f.IDValue) 49 } 50 51 // GetOtherValue is an additional method used to distinguish this resource API from others. 52 func (f *FakeResource) GetOtherValue() string { 53 return f.OtherValue 54 }