25
"k8s.io/apimachinery/pkg/runtime/schema"
27
"istio.io/api/meta/v1alpha1"
28
"istio.io/istio/pkg/config"
29
"istio.io/istio/pkg/config/resource"
30
"istio.io/istio/pkg/config/schema/collections"
31
"istio.io/istio/pkg/config/schema/gvk"
32
"istio.io/istio/pkg/log"
35
var scope = log.RegisterScope("status",
36
"status controller for istio")
38
func ResourceFromString(s string) *Resource {
39
pieces := strings.Split(s, "/")
41
scope.Errorf("cannot unmarshal %s into resource identifier", s)
45
GroupVersionResource: schema.GroupVersionResource{
52
Generation: pieces[5],
58
schema.GroupVersionResource
64
func (r Resource) String() string {
65
return strings.Join([]string{r.Group, r.Version, r.GroupVersionResource.Resource, r.Namespace, r.Name, r.Generation}, "/")
68
func (r *Resource) ToModelKey() string {
70
found, _ := collections.All.FindByGroupVersionResource(r.GroupVersionResource)
72
found.Group(), found.Version(), found.Kind(),
76
func ResourceFromMetadata(i resource.Metadata) Resource {
78
GroupVersionResource: i.Schema.GroupVersionResource(),
79
Namespace: i.FullName.Namespace.String(),
80
Name: i.FullName.Name.String(),
81
Generation: strconv.FormatInt(i.Generation, 10),
85
func ResourceFromModelConfig(c config.Config) Resource {
86
gvr, ok := gvk.ToGVR(c.GroupVersionKind)
91
GroupVersionResource: gvr,
92
Namespace: c.Namespace,
94
Generation: strconv.FormatInt(c.Generation, 10),
98
func GetTypedStatus(in any) (out *v1alpha1.IstioStatus, err error) {
99
if ret, ok := in.(*v1alpha1.IstioStatus); ok {
102
return nil, fmt.Errorf("cannot cast %T: %v to IstioStatus", in, in)
105
func GetOGProvider(in any) (out GenerationProvider, err error) {
106
if ret, ok := in.(*v1alpha1.IstioStatus); ok && ret != nil {
107
return &IstioGenerationProvider{ret}, nil
109
return nil, fmt.Errorf("cannot cast %T: %v to GenerationProvider", in, in)
112
func NewIstioContext(stop <-chan struct{}) context.Context {
113
ctx, cancel := context.WithCancel(context.Background())