-
Notifications
You must be signed in to change notification settings - Fork 36
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
provisioner: merge galaxy config into common #41
base: main
Are you sure you want to change the base?
Conversation
@SwampDragons this is where I got to on the refactor. Sharing in case you find anything usable. |
Thanks. I'll take a look at it when I have some downtime. |
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.
Just a few nits/typos/questions, other than that LGTM, that's a good improvement
c477912
to
d9ed1db
Compare
e018859
to
b7223d3
Compare
The Ansible galaxy arguments for both provisioners were duplicated among the provisioners although they are essentially the same. Since they're the same, we move the common code and arguments into a common package so it can be reused between both provisioners.
b7223d3
to
3fa204b
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.
Ready for a review @nywilken
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.
Thanks for re-rolling this change. Overall it looks good. I left a suggestion on the BuildGalaxyArgs function to always return something.
// If roles keyword present (v2 format), or no collections keyword present (v1), install roles | ||
if hasRoles || !hasCollections { | ||
return roleArgs, nil | ||
} | ||
|
||
// If collections keyword present (v2 format), install collections | ||
if hasCollections { | ||
return collectionArgs, nil | ||
} | ||
|
||
return nil, nil |
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.
Return nil,nil feels like there is an error case we are missing. As it stands if we do return nil args with no error the execution of the args returned from BuildGalaxyArgs would fail. Would it be more appropriate to always return roleArgs or maybe an error if have no roles since the Galaxy file is invalid?
// If collections keyword present (v2 format), install collections
if hasCollections {
return collectionArgs, nil
}
// If roles keyword present (v2 format), or no collections keyword present (v1), install roles
if hasRoles {
return roleArgs, nil
}
return nil, fmt.Errorf("messaging about the requirements file not containing any roles or collections")
Alternatively you can just return the roleArgs and let Ansible handle the errors
// If collections keyword present (v2 format), install collections
if hasCollections {
return collectionArgs, nil
}
return roleArgs, nil
}
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.
Agreed, I missed that one when adapting the code, but definitely that looks fishy, thanks for pointing it out
The Ansible galaxy arguments for both provisioners were duplicated among the provisioners although they are essentially the same.
Since they're the same, we move the common code and arguments into a common package so it can be reused between both provisioners.