-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #26046: Migrate compliance status from lift-json to zio-json #6086
Fixes #26046: Migrate compliance status from lift-json to zio-json #6086
Conversation
485f1d2
to
94f34fa
Compare
94f34fa
to
f097743
Compare
PR updated with a new commit |
1 similar comment
PR updated with a new commit |
9949e4e
to
e922c62
Compare
PR updated with a new commit |
1 similar comment
PR updated with a new commit |
noReport: Option[Double], | ||
reportsDisabled: Option[Double], | ||
badPolicyMode: Option[Double] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved in the end of the file, with other serialization things
PR updated with a new commit |
1 similar comment
PR updated with a new commit |
5271ae6
to
8124190
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just some suggestions/questions
.withFieldComputed(_.run, _._1.transformInto[ApiRunInfo]) | ||
.withFieldComputed(_.status, _._2.transformInto[ApiStatusInfo]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So now with the last chimney version, it could be :
.withFieldComputed(_.run, _._1.transformInto[ApiRunInfo]) | |
.withFieldComputed(_.status, _._2.transformInto[ApiStatusInfo]) | |
.withFieldRenamed(_._1, _.run) | |
.withFieldRenamed(_._1, _.status) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep,it works now (with a 2
in second line)
// here, I'm not sure that we want compliance or | ||
// compliance percents. Having a normalized value | ||
// seems far better for queries in the future. | ||
// but in that case, we should also keep the total | ||
// number of events to be able to rebuild raw data | ||
|
||
// always map compliance field from ComplianceLevel to ComplianceSerializable automatically | ||
implicit private lazy val transformComplianceLevel: Transformer[ComplianceLevel, ComplianceSerializable] = { | ||
case c: ComplianceLevel => c.computePercent().transformInto[ComplianceSerializable] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that seems like a transformation that should be reusable, is there a reason why it is here instead of in the ComplianceLevel
companion object ?
In fact there already is a transformComplianceSerializable: Transformer[ComplianceLevel, ComplianceLevelSerialisation]
, I am not sure about the difference between ComplianceSerialization
and ComplianceLevelSerialisation
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the existing one is for thing of the same type: ComplianceLevel
is the number of things in each kind, and ComplianceLevelSerialisation
the corresponding json.
This one is changing the type from level to percent. It's a local tool because almost all reports have the percent, so just removing boilerplate in the other transformers.
/* | ||
* This is the serialization for API. | ||
* We are again redefining roughly the same objects. | ||
*/ | ||
// not sure why it doesn't see that they are used | ||
@nowarn("msg=private val .* in object NodeStatusReportSerialization is never used") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the solution of declaring everything in a private object InternalDatastructures
, this avoids the issue of private implicits being reported as unused by the compiler.
Plus, in all the code below, there are really many things that end up being private, the structure and the dependencies are becoming hard to follow...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -49,6 +49,7 @@ import com.normation.rudder.domain.RudderDit | |||
import com.normation.rudder.domain.RudderLDAPConstants.* | |||
import com.normation.rudder.domain.policies.Tag | |||
import com.normation.rudder.domain.policies.TagName | |||
import com.normation.rudder.domain.policies.Tags as TAGS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why ? 😇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BECAUSE
(there is a name clash, and this one is used only one time)
.../rudder/rudder-core/src/main/scala/com/normation/rudder/domain/reports/ComplianceLevel.scala
Outdated
Show resolved
Hide resolved
8124190
to
8b1aab6
Compare
OK, merging this PR |
6cb85f1
into
Normation:master
https://issues.rudder.io/issues/26046
Main change:
...withFieldComputed(_.a, _.aa.transformInto[AA])
and just use.withFieldRenamed(_.a, _.aa)
given a transformerA
toAA
in scopeTags
needed to be migrated. Only encode is needed at that point, which was created with an intermediateJsonTag
that is not exposed so that we can keepTags
in Json objects in place ofJValue
.zio.json.ast
objectsOptPosNum
type for compliance and compliance percent serialization. It's anOption[Numeric]
(so that it works with int and float, but some quirks because js/java/scala) and so can be eliminated in the json when not present.ComplianceSerializable
andComplianceLevelSerialisation
have their fields with the correct naming and order. There's a lot of chimney to map to/from the corresponding business objects.AggregatedStatusReport
(it already existed in a more compact fashion for database, now with full name - and IIRC, there's some other little differences)RuleLine
, because it's an horror mixing json and full js. And perhaps we can just delete it at some point.I think other things are rather automatics.
Not a lot of
net.liftweb.json
removed, but still some more, especially inrudder-core
.