fix: fail to reset policy org_node_id to empty (#19425)

Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
Jian Qiu
2024-02-03 23:19:42 +08:00
committed by GitHub
co-authored by Qiu Jian
parent 69eaad8afe
commit 2e4e2d3bef
22 changed files with 497 additions and 66 deletions
+7 -4
View File
@@ -266,7 +266,10 @@ func listItemQueryFiltersRaw(manager IModelManager,
return nil, httperrors.NewGeneralError(err)
}
query.(*jsonutils.JSONDict).Update(policyTagFilters.Json())
if !policyTagFilters.IsEmpty() {
query.(*jsonutils.JSONDict).Update(policyTagFilters.Json())
log.Debugf("policyTagFilers: %s", query)
}
if !useRawQuery {
// Specifically for joint resource, these filters will exclude
@@ -1745,11 +1748,11 @@ func reflectDispatcherInternal(
} else {
if model != nil {
if _, ok := model.(IStandaloneModel); ok {
Metadata.rawSetValues(ctx, model.Keyword(), model.GetId(), tagutils.Tagset2MapString(result.ObjectTags.Flattern()), false, "")
Metadata.rawSetValues(ctx, model.Keyword(), model.GetId(), tagutils.TagsetMap2MapString(result.ObjectTags.Flattern()), false, "")
if model.Keyword() == "project" {
Metadata.rawSetValues(ctx, model.Keyword(), model.GetId(), tagutils.Tagset2MapString(result.ProjectTags.Flattern()), false, "")
Metadata.rawSetValues(ctx, model.Keyword(), model.GetId(), tagutils.TagsetMap2MapString(result.ProjectTags.Flattern()), false, "")
} else if model.Keyword() == "domain" {
Metadata.rawSetValues(ctx, model.Keyword(), model.GetId(), tagutils.Tagset2MapString(result.DomainTags.Flattern()), false, "")
Metadata.rawSetValues(ctx, model.Keyword(), model.GetId(), tagutils.TagsetMap2MapString(result.DomainTags.Flattern()), false, "")
}
}
}
+3 -3
View File
@@ -722,12 +722,12 @@ func (model *SStandaloneAnonResourceBase) applyPolicyTags(ctx context.Context, u
data.Unmarshal(&tags)
log.Debugf("applyPolicyTags: %s", jsonutils.Marshal(tags))
if len(tags.PolicyObjectTags) > 0 {
model.PerformMetadata(ctx, userCred, nil, tagutils.Tagset2MapString(tags.PolicyObjectTags.Flattern()))
model.PerformMetadata(ctx, userCred, nil, tagutils.TagsetMap2MapString(tags.PolicyObjectTags.Flattern()))
}
if model.Keyword() == "project" && len(tags.PolicyProjectTags) > 0 {
model.PerformMetadata(ctx, userCred, nil, tagutils.Tagset2MapString(tags.PolicyProjectTags.Flattern()))
model.PerformMetadata(ctx, userCred, nil, tagutils.TagsetMap2MapString(tags.PolicyProjectTags.Flattern()))
} else if model.Keyword() == "domain" && len(tags.PolicyDomainTags) > 0 {
model.PerformMetadata(ctx, userCred, nil, tagutils.Tagset2MapString(tags.PolicyDomainTags.Flattern()))
model.PerformMetadata(ctx, userCred, nil, tagutils.TagsetMap2MapString(tags.PolicyDomainTags.Flattern()))
}
}