istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pkg/config/analysis/local/helpers_test.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 package local 15 16 // Test helpers common to this package 17 18 import ( 19 "reflect" 20 "testing" 21 22 "google.golang.org/protobuf/types/known/emptypb" 23 "google.golang.org/protobuf/types/known/structpb" 24 25 "istio.io/istio/pkg/config/analysis/legacy/source/kube" 26 "istio.io/istio/pkg/config/resource" 27 r2 "istio.io/istio/pkg/config/schema/resource" 28 "istio.io/istio/pkg/config/validation" 29 ) 30 31 // K8SCollection1 describes the collection k8s/collection1 32 var K8SCollection1 = r2.Builder{ 33 Group: "testdata.istio.io", 34 Kind: "Kind1", 35 Plural: "Kind1s", 36 Version: "v1alpha1", 37 Proto: "google.protobuf.Struct", 38 ReflectType: reflect.TypeOf(&structpb.Struct{}).Elem(), 39 ProtoPackage: "github.com/gogo/protobuf/types", 40 ClusterScoped: false, 41 ValidateProto: validation.EmptyValidate, 42 }.MustBuild() 43 44 func createTestResource(t *testing.T, ns, name, version string) *resource.Instance { 45 t.Helper() 46 rname := resource.NewFullName(resource.Namespace(ns), resource.LocalName(name)) 47 return &resource.Instance{ 48 Metadata: resource.Metadata{ 49 FullName: rname, 50 Version: resource.Version(version), 51 }, 52 Message: &emptypb.Empty{}, 53 Origin: &kube.Origin{ 54 FullName: rname, 55 }, 56 } 57 }