Skip to content
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 #15265: Migrate ncf delete api and improve workflow #2333

Conversation

VinceMacBuche
Copy link
Member

@VinceMacBuche VinceMacBuche force-pushed the ust_15265/migrate_ncf_delete_api_and_improve_workflow branch from 5916cfb to 8288ce9 Compare July 25, 2019 15:23
@VinceMacBuche
Copy link
Member Author

Commit modified

@VinceMacBuche VinceMacBuche requested a review from fanf July 30, 2019 07:55
cr <- ((d.accumulate { directive =>
val tName = TechniqueName(techniqueName)
for {
a <- readDirectives.getDirectiveWithContext(directive.id).notOptional(s"Could not find Directive ${directive.id.value}")
Copy link
Member

Choose a reason for hiding this comment

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

I think that you should keep the getFullDirectiveLibrary and avoid to request here again. It will avoid ldap requests



} else
Left(Unexpected(s"${d.size} directives are defined for ${techniqueName}/${techniqueVersion} please delete them, or force deletion")).toIO
Copy link
Member

Choose a reason for hiding this comment

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

You can do Unexpected(....).succeed

Copy link
Member

Choose a reason for hiding this comment

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

.fail of course, not succeed here :/

for {
d <- readDirectives.getFullDirectiveLibrary().map(_.allActiveTechniques.values.filter(_.techniqueName.value == techniqueName).flatMap(_.directives).filter(_.techniqueVersion.toString == techniqueVersion))
_ <- (d match {
case Nil => Right(d).toIO
Copy link
Member

Choose a reason for hiding this comment

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

d.succeed

@fanf fanf assigned fanf and VinceMacBuche and unassigned fanf Jul 30, 2019
@VinceMacBuche
Copy link
Member Author

Commit modified

cr <- directives.map(createCr(_,technique.rootSection)).reduceOption(mergeCrs).notOptional(s"Could not create a change request to delete ${techniqueName}/${techniqueVersion} directives")
_ <- wf.startWorkflow(cr, committer, Some(s"Deleting technique ${techniqueName}/${techniqueVersion}")).succeed
} yield {
cr
Copy link
Member

Choose a reason for hiding this comment

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

you should yield () if the result is not used.


technique <- techniqueRepository.get(techniqueId).notOptional(s"No Technique with ID '${techniqueId.toString()}' found in reference library.")
_ <- directives match {
case Nil => directives.succeed
Copy link
Member

Choose a reason for hiding this comment

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

it shoud be UIO.unit if you don't use the result type

}
_ <- archiver.deleteTechnique(techniqueName,techniqueVersion,modId,committer, s"Deleting technique ${techniqueName}/${techniqueVersion}")

libUpdate <- techLibUpdate.update(modId, committer, Some(s"Update Technique library after deletion of Technique ${techniqueName}")).succeed.chainError(s"An error occurred during technique update after deletion of Technique ${techniqueName}")
Copy link
Member

Choose a reason for hiding this comment

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

_ if you don't need libUpdate

ident <- personIdentservice.getPersonIdentOrDefault(commiter.name)
rm <- IOResult.effect(git.rm.addFilepattern(s"techniques/ncf_techniques/${techniqueName}/${techniqueVersion}").call())

commit <- IOResult.effect(git.commit.setCommitter(ident).setMessage(msg).call())
Copy link
Member

Choose a reason for hiding this comment

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

_ if you don't need commit

@VinceMacBuche
Copy link
Member Author

Commit modified

@Normation-Quality-Assistant
Copy link
Contributor

This PR is not mergeable to upper versions.
Since it is "Ready for merge" you must merge it by yourself using the following command:
rudder-dev merge https://github.com/Normation/rudder/pull/2333
-- Your faithful QA
Kant merge: "Happiness is not an ideal of reason, but of imagination."
(https://ci.normation.com/jenkins/job/merge-accepted-pr/13090/console)

@fanf
Copy link
Member

fanf commented Jul 31, 2019

OK, squash merging this PR

@fanf fanf force-pushed the ust_15265/migrate_ncf_delete_api_and_improve_workflow branch from 5d27ecf to 99a69f8 Compare July 31, 2019 21:03
@fanf fanf merged commit 99a69f8 into Normation:master Jul 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants