Skip to content

Conversation

@skaerg
Copy link
Contributor

@skaerg skaerg commented May 5, 2025

https://issues.rudder.io/issues/26861

This is part of the plan to remove the dependency to the lift library from Rudder and Rudder plugins.
This PR migrates the following classes in XmlUnserialisation :

  • DirectiveUnserialisationImpl
  • NodeGroupCategoryUnserialisationImpl
  • NodeGroupUnserialisationImpl
  • RuleUnserialisationImpl
  • RuleCategoryUnserialisationImpl
  • GlobalParameterUnserialisationImpl
  • ChangeRequestChangesUnserialisationImpl

This change also includes a new XmlUtils object, which offers methods to look up a specific child node or attribute of a given XML node, and the error handling that comes with it. XmlUtils may be used in order to migrate the remaining classes in XmlUnserialisation

This PR is part of the migration from Box to ZIO in change-validation, and is linked to the following PR in the Rudder plugins repository : Normation/rudder-plugins#828

@skaerg skaerg self-assigned this May 6, 2025
@skaerg
Copy link
Contributor Author

skaerg commented May 6, 2025

PR updated with a new commit

@skaerg
Copy link
Contributor Author

skaerg commented May 6, 2025

Commit modified

@skaerg skaerg force-pushed the arch_26861/migration_from_box_to_zio_refactor_xmlunserialisation branch 3 times, most recently from 5d5d85c to c47cc2c Compare May 6, 2025 14:54
@skaerg
Copy link
Contributor Author

skaerg commented May 6, 2025

PR updated with a new commit

@skaerg
Copy link
Contributor Author

skaerg commented May 7, 2025

PR updated with a new commit

1 similar comment
@skaerg
Copy link
Contributor Author

skaerg commented May 7, 2025

PR updated with a new commit

@skaerg skaerg force-pushed the arch_26861/migration_from_box_to_zio_refactor_xmlunserialisation branch from 2234554 to 8a0f048 Compare May 14, 2025 12:56
Copy link
Contributor

@clarktsiory clarktsiory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is great having such a migration, it covers already a lot.

There were some other methods in CommitAndDeployChangeRequestServiceImpl that still could be migrated, as propagated changes (to avoid toBox).

Also the XmlUtils API is nice, I have some suggestions to make it easier to use.

@skaerg
Copy link
Contributor Author

skaerg commented May 15, 2025

PR updated with a new commit

@skaerg
Copy link
Contributor Author

skaerg commented May 19, 2025

PR updated with a new commit

@skaerg
Copy link
Contributor Author

skaerg commented May 20, 2025

PR updated with a new commit

Comment on lines 130 to 133
(config, trigger) <- changeRequest match {
case config: ConfigurationChangeRequest =>
if (!isMergeableConfigurationChangeRequest(config)) {
ChangeRequestLogger.info(
logger.info(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right above this, there is some code that can be put in the for-comprehension instead :

workflowEnabled().either.runNow match {
      case Right(b) => if (b) logger.info(s"Saving and deploying change request ${changeRequest.id.value}")
      case _        => ()
}

@skaerg
Copy link
Contributor Author

skaerg commented May 21, 2025

PR updated with a new commit


for {
workflowEnabled <- workflowEnabled().toBox
_ = if (workflowEnabled) logger.info(s"Saving and deploying change request ${changeRequest.id.value}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the logger is pure, so this will just skip the log. It needs to be <-

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the for-comprehension likely needs to be for IOResult, and not Box, the toIO at the end should be avoided

@skaerg
Copy link
Contributor Author

skaerg commented May 21, 2025

PR updated with a new commit

Comment on lines 125 to 127
_ <- workflowEnabled().toBox.map(workflowEnabled => {
if (workflowEnabled) logger.info(s"Saving and deploying change request ${changeRequest.id.value}")
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will still not do the log, the pure logger needs to be evaluated (the result of this expression is Box[IOResult[Unit]]).

The whole for-comprehension needs to be a IOResult one, there are nested toBox and toIO and we don't want that. In fact the toIO and the end needs to be removed (you will likely need to do saveConfigurationChangeRequest(...).toIO)

@skaerg
Copy link
Contributor Author

skaerg commented May 21, 2025

PR updated with a new commit

@Normation-Quality-Assistant
Copy link
Contributor

OK, squash merging this PR

 #XmlUnserialisationImpl: chain additional error if unserialisation fails ; CmdbQueryParser pure implementation
@Normation-Quality-Assistant Normation-Quality-Assistant force-pushed the arch_26861/migration_from_box_to_zio_refactor_xmlunserialisation branch from 88fd787 to e371c1b Compare May 21, 2025 17:15
@Normation-Quality-Assistant Normation-Quality-Assistant merged commit e371c1b into Normation:branches/rudder/9.0 May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants