Tweak resource finding logic
This commit is contained in:
parent
02620c4ea7
commit
892c7dfe3c
@ -155,16 +155,15 @@ func findApplicationS(ctx context.Context, s store.Storer, gf genericFilter) (ap
|
||||
// findApplicationR looks for the app in the resource set
|
||||
func findApplicationR(rr resource.InterfaceSet, ii resource.Identifiers) (ap *types.Application) {
|
||||
var apRes *resource.Application
|
||||
var ok bool
|
||||
|
||||
rr.Walk(func(r resource.Interface) error {
|
||||
apRes, ok = r.(*resource.Application)
|
||||
ar, ok := r.(*resource.Application)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
if !apRes.Identifiers().HasAny(r.Identifiers()) {
|
||||
apRes = nil
|
||||
if ar.Identifiers().HasAny(ii) {
|
||||
apRes = ar
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@ -202,16 +202,15 @@ func findComposeChartS(ctx context.Context, s store.Storer, nsID uint64, gf gene
|
||||
// findComposeChartR looks for the chart in the resources
|
||||
func findComposeChartR(rr resource.InterfaceSet, ii resource.Identifiers) (ch *types.Chart) {
|
||||
var chRes *resource.ComposeChart
|
||||
var ok bool
|
||||
|
||||
rr.Walk(func(r resource.Interface) error {
|
||||
chRes, ok = r.(*resource.ComposeChart)
|
||||
cr, ok := r.(*resource.ComposeChart)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
if !chRes.Identifiers().HasAny(r.Identifiers()) {
|
||||
chRes = nil
|
||||
if chRes.Identifiers().HasAny(ii) {
|
||||
chRes = cr
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
@ -286,16 +286,15 @@ func findComposeModuleS(ctx context.Context, s store.Storer, nsID uint64, gf gen
|
||||
// findComposeModuleR looks for the module in the store
|
||||
func findComposeModuleR(rr resource.InterfaceSet, ii resource.Identifiers) (ns *types.Module) {
|
||||
var modRes *resource.ComposeModule
|
||||
var ok bool
|
||||
|
||||
rr.Walk(func(r resource.Interface) error {
|
||||
modRes, ok = r.(*resource.ComposeModule)
|
||||
mr, ok := r.(*resource.ComposeModule)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
if !modRes.Identifiers().HasAny(r.Identifiers()) {
|
||||
modRes = nil
|
||||
if modRes.Identifiers().HasAny(ii) {
|
||||
modRes = mr
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
@ -149,16 +149,15 @@ func findComposeNamespaceS(ctx context.Context, s store.Storer, gf genericFilter
|
||||
// findComposeNamespaceR looks for the namespace in the resources
|
||||
func findComposeNamespaceR(rr resource.InterfaceSet, ii resource.Identifiers) (ns *types.Namespace) {
|
||||
var nsRes *resource.ComposeNamespace
|
||||
var ok bool
|
||||
|
||||
rr.Walk(func(r resource.Interface) error {
|
||||
nsRes, ok = r.(*resource.ComposeNamespace)
|
||||
nr, ok := r.(*resource.ComposeNamespace)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
if !nsRes.Identifiers().HasAny(r.Identifiers()) {
|
||||
nsRes = nil
|
||||
if nr.Identifiers().HasAny(ii) {
|
||||
nsRes = nr
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
@ -207,16 +207,15 @@ func findComposePageS(ctx context.Context, s store.Storer, nsID uint64, gf gener
|
||||
// findComposePageR looks for the page in the resources
|
||||
func findComposePageR(ctx context.Context, rr resource.InterfaceSet, ii resource.Identifiers) (pg *types.Page) {
|
||||
var pgRes *resource.ComposePage
|
||||
var ok bool
|
||||
|
||||
rr.Walk(func(r resource.Interface) error {
|
||||
pgRes, ok = r.(*resource.ComposePage)
|
||||
pr, ok := r.(*resource.ComposePage)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
if !pgRes.Identifiers().HasAny(r.Identifiers()) {
|
||||
pgRes = nil
|
||||
if pr.Identifiers().HasAny(ii) {
|
||||
pgRes = pr
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
@ -143,16 +143,15 @@ func findRoleS(ctx context.Context, s store.Storer, gf genericFilter) (rl *types
|
||||
// findRoleR looks for the role in the resources
|
||||
func findRoleR(rr resource.InterfaceSet, ii resource.Identifiers) (rl *types.Role) {
|
||||
var rlRes *resource.Role
|
||||
var ok bool
|
||||
|
||||
rr.Walk(func(r resource.Interface) error {
|
||||
rlRes, ok = r.(*resource.Role)
|
||||
rr, ok := r.(*resource.Role)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
if rlRes.Identifiers().HasAny(r.Identifiers()) {
|
||||
rlRes = nil
|
||||
if rr.Identifiers().HasAny(ii) {
|
||||
rlRes = rr
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
@ -156,18 +156,16 @@ func findUserS(ctx context.Context, s store.Storer, gf genericFilter) (u *types.
|
||||
|
||||
// findUserR looks for the user in the resources
|
||||
func findUserR(ctx context.Context, rr resource.InterfaceSet, ii resource.Identifiers) (u *types.User) {
|
||||
// Try to find it in the parent resources
|
||||
var uRes *resource.User
|
||||
var ok bool
|
||||
|
||||
rr.Walk(func(r resource.Interface) error {
|
||||
uRes, ok = r.(*resource.User)
|
||||
ur, ok := r.(*resource.User)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
if !uRes.Identifiers().HasAny(r.Identifiers()) {
|
||||
uRes = nil
|
||||
if uRes.Identifiers().HasAny(ii) {
|
||||
uRes = ur
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user