-
Notifications
You must be signed in to change notification settings - Fork 86
Fixes #28040: Migrate CheckRudderGlobalParam to zio-json in rudder-webapp #6824
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
base: branches/rudder/9.1
Are you sure you want to change the base?
Conversation
|
PR updated with a new commit |
|
PR rebased |
257ee9c to
10dd842
Compare
|
PR updated with a new commit |
|
PR rebased |
2660d2c to
cb5cc0f
Compare
| /** | ||
| * Parse a JSON JValue to ConfigValue. It always succeeds. | ||
| */ | ||
| @Deprecated(since = "8.0", forRemoval = true) |
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.
Not sure actually if the migration to zio-json started on version 8.0...
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 migration started a long time ago (7.0.0 IIRC)
Why wouldn't it be 9.1 ?
This would be removed when we migrate the whole Properties.scala, that I hope is before the 9.1 release...
|
|
||
| // lift json need that to be topevel | ||
| // TODO: handle the following TODO | ||
| // TODO: add Option[String] revision in API |
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.
@fanf I would like to create a redmine ticket to handle to delete the TODO
// TODO: add Option[String] revision in API
Just need a bit of context
clarktsiory
left a comment
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 only have a few suggestions, I'm open to discuss these few aspects !
| case Right(Json.Arr(list)) => | ||
| ZIO.foreach(list)(v => { | ||
| v.as[GlobalPropertiesJson] match { | ||
| case Left(error) => | ||
| Unexpected( | ||
| s"An unexpected error occurred while decoding json global properties $v as $GlobalPropertiesJson: $error" | ||
| ).fail | ||
| case Right(value) => IOResult.attempt(value.toGlobalParam) | ||
| } | ||
|
|
||
| }) | ||
| case _ => | ||
| Inconsistency( | ||
| s"Resources `$resource` must contain an array of json object with keys name, description, value." | ||
| ).fail |
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.
With our error-handling utils (in the ZioCommons file, e.g. EitherToIoResult#toIO), we have multiple ways to have a fluent syntax, instead of pattern matching (which at some point could hurt readability).
Here it could be something like :
value.map(_.asArray)
.toIO
.notOptional(s"Resources `$resource` must contain an array of json object with keys name, description, value.")
.flatMap(arr =>
ZIO.foreach(...)(/* can also be fluent */)
)| } | ||
| object GlobalPropertiesJson { | ||
| implicit val decoder: JsonDecoder[GlobalPropertiesJson] = DeriveJsonDecoder.gen[GlobalPropertiesJson] | ||
| } |
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.
now this is more verbose than derives JsonDecoder, I would happier with the derives syntax since the case class is already a JSON one 😄
| /** | ||
| * Parse a JSON JValue to ConfigValue. It always succeeds. | ||
| */ | ||
| @Deprecated(since = "8.0", forRemoval = true) |
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 migration started a long time ago (7.0.0 IIRC)
Why wouldn't it be 9.1 ?
This would be removed when we migrate the whole Properties.scala, that I hope is before the 9.1 release...
https://issues.rudder.io/issues/28040
fromJsonValuewith a nowarn the remaining calls