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 #14041: Replace all RudderUniqueID in paths for inputs list and rudder.json, and correctly generate paths based on agent type #2103

Conversation

ncharles
Copy link
Member

… rudder.json, and correctly generate paths based on agent type
@ncharles
Copy link
Member Author

must be merged after Normation/ldap-inventory#143

Copy link
Member

@fanf fanf left a comment

Choose a reason for hiding this comment

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

It seems that we are not doing the replace of tag at the correct place. It should be possible to have only one place where we build the destination (make unique, and replace tag in path), and use that to both build the correct bundle variables and the correct out path.

Moreover, can you please add a test in dsc agent (or point me to it if I missed ii in an other PR), because the change reach is not trivial and we must keep example of working metadata/templates and corresponding expected generated files.

*/
private[this] def parseResource(techniqueId: TechniqueId, xml: Node, isTemplate:Boolean): (TechniqueResourceId, String) = {
private[this] def parseResource(techniqueId: TechniqueId, xml: Node, isTemplate:Boolean, agentType:Option[AgentType]): (TechniqueResourceId, String) = {
Copy link
Member

Choose a reason for hiding this comment

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

Here, it seems that the problem is that isTemplate is not sufficiently precise, but having both that parameter and agentType is redondant. Can you change (isTemplate, agentType) by templateForAgent:Option[AgentType]

So that we encode the whole information in just that parameter?

Copy link
Member Author

Choose a reason for hiding this comment

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

i'm not sure about this one - what if we add a new agent, that will need isTemplate & agentType at the same time ?

* Replace the Rudder Unique Id also in the path for input list
*/
def replaceRudderUniqueId(path: String, p: Policy): String = {
path.replace(TAG_OF_RUDDER_MULTI_POLICY, p.id.getRudderUniqueId)
Copy link
Member

Choose a reason for hiding this comment

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

it should be a replaceAll to avoid problems in a case where someone put several tag in the path for whatever reason

@@ -378,6 +378,13 @@ final object Policy {
path.replaceFirst(subPath, s"${p.technique.id.name.value}/${p.id.getRudderUniqueId}")
Copy link
Member

Choose a reason for hiding this comment

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

Is their a case where we want to make a unique dest without replacing the tag? I think not (and it would avoid to walk the path several times)

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know - that's why i didn't replaceAll in replaceRudderUniqueId - i was wondering if there was an unknown reason i was missing

@ncharles
Copy link
Member Author

Tests in DSC are here: https://github.com/Normation/rudder-agent-windows/pull/292

@fanf
Copy link
Member

fanf commented Dec 28, 2018

OK, I'm merging like that, but please open an other ticket for me to try to normalize things

@Normation-Quality-Assistant
Copy link
Contributor

OK, merging this PR

@Normation-Quality-Assistant Normation-Quality-Assistant merged commit 826b755 into Normation:branches/rudder/4.3 Dec 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants