3
0

Fix improper ns import resource re-id due to resources being ignored

This commit is contained in:
Tomaž Jerman
2022-03-23 12:01:37 +01:00
parent 46eb0f1749
commit a1a462c5fb
2 changed files with 7 additions and 3 deletions
+2 -2
View File
@@ -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
})
+5 -1
View File
@@ -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)
}