Fix improper ns import resource re-id due to resources being ignored
This commit is contained in:
@@ -324,7 +324,7 @@ func (svc namespace) Clone(ctx context.Context, namespaceID uint64, dup *types.N
|
||||
|
||||
// Correct internal references
|
||||
// - namespace identifiers
|
||||
nn.SearchForIdentifiers(oldNsRef.Identifiers).Walk(func(r resource.Interface) error {
|
||||
nn.SearchForIdentifiers(oldNsRef.ResourceType, oldNsRef.Identifiers).Walk(func(r resource.Interface) error {
|
||||
r.ReID(newNsRef.Identifiers)
|
||||
return nil
|
||||
})
|
||||
@@ -490,7 +490,7 @@ func (svc namespace) ImportRun(ctx context.Context, sessionID uint64, dup *types
|
||||
|
||||
// Correct internal references
|
||||
// - namespace identifiers
|
||||
session.Resources.SearchForIdentifiers(oldNsRef.Identifiers).Walk(func(r resource.Interface) error {
|
||||
session.Resources.SearchForIdentifiers(oldNsRef.ResourceType, oldNsRef.Identifiers).Walk(func(r resource.Interface) error {
|
||||
r.ReID(newNsRef.Identifiers)
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -155,10 +155,14 @@ func (rr InterfaceSet) Walk(f func(r Interface) error) (err error) {
|
||||
// SearchForIdentifiers returns the resources where the provided identifiers exist
|
||||
//
|
||||
// The Resource is matching if at least one identifier matches.
|
||||
func (rr InterfaceSet) SearchForIdentifiers(ii Identifiers) (out InterfaceSet) {
|
||||
func (rr InterfaceSet) SearchForIdentifiers(resource string, ii Identifiers) (out InterfaceSet) {
|
||||
out = make(InterfaceSet, 0, len(rr)/2)
|
||||
|
||||
for _, r := range rr {
|
||||
if r.ResourceType() != resource {
|
||||
continue
|
||||
}
|
||||
|
||||
if r.Identifiers().HasAny(ii) {
|
||||
out = append(out, r)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user