Skip to content

Commit

Permalink
fix: jump to namespaceless owner reference (#2718)
Browse files Browse the repository at this point in the history
  • Loading branch information
gitolicious authored May 26, 2024
1 parent 0afea24 commit 9594065
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions internal/dao/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,17 @@ func (m *Meta) AllGVRs() client.GVRs {
}

// GVK2GVR convert gvk to gvr
func (m *Meta) GVK2GVR(gv schema.GroupVersion, kind string) (client.GVR, bool) {
func (m *Meta) GVK2GVR(gv schema.GroupVersion, kind string) (client.GVR, bool, bool) {
m.mx.RLock()
defer m.mx.RUnlock()

for gvr, meta := range m.resMetas {
if gv.Group == meta.Group && gv.Version == meta.Version && kind == meta.Kind {
return gvr, true
return gvr, meta.Namespaced, true
}
}

return client.NoGVR, false
return client.NoGVR, false, false
}

// IsCRD checks if resource represents a CRD
Expand Down
11 changes: 9 additions & 2 deletions internal/view/owner_extender.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,19 @@ func (v *OwnerExtender) jumpOwner(ns string, owner metav1.OwnerReference) error
return err
}

gvr, found := dao.MetaAccess.GVK2GVR(gv, owner.Kind)
gvr, namespaced, found := dao.MetaAccess.GVK2GVR(gv, owner.Kind)
if !found {
return errors.Errorf("unsupported GVK: %s/%s", owner.APIVersion, owner.Kind)
}

v.App().gotoResource(gvr.String(), client.FQN(ns, owner.Name), false)
var ownerFQN string
if namespaced {
ownerFQN = client.FQN(ns, owner.Name)
} else {
ownerFQN = owner.Name
}

v.App().gotoResource(gvr.String(), ownerFQN, false)
return nil
}

Expand Down

0 comments on commit 9594065

Please sign in to comment.