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

Fix roles file comparison to use object not string #878

Merged
merged 1 commit into from
Mar 28, 2019

Conversation

plessbd
Copy link
Contributor

@plessbd plessbd commented Mar 27, 2019

Made it so roles.d/cloud.json is updated properly
Fixed comparison to be based on the object not string

@plessbd plessbd force-pushed the fix-cloud-charts branch 3 times, most recently from e622509 to cf3861f Compare March 27, 2019 23:57
Copy link
Member

@jpwhite4 jpwhite4 left a comment

Choose a reason for hiding this comment

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

This does raise an interesting design question: how much effort should we expend in migrating old config files that have been edited by the user. In this pull request we add the summary charts to the default role - but what should we do if the user has already added some alternative summary charts. Should we merge the charts? Merge and deduplicate them? Overwrite the user's charts? Leave the edited charts alone?

My overall preference is that we move to a new paradigm where if a user has edited a configuration file then we do not overwrite the edits and provide sufficient documentation to allow the user to do the merge. Afterall, they are the only ones who know what the original intent and reason for the original edits to the old files - we are not going to be able to guess their intentions. Of course, If the original file has not been edited then it can be safely replaced with the new version

@smgallo
Copy link
Contributor

smgallo commented Mar 28, 2019

I agree with @jpwhite4 and my preference is to follow a similar paradigm as system installs where if the file has been changed, we place a config.json.new file in the directory (it won't be picked up by the Configuration scanner) and let the user sort it out. Migrating configuration files should not be an area where we expend any significant effort.

@plessbd plessbd merged commit 267db77 into ubccr:xdmod8.1 Mar 28, 2019
@plessbd
Copy link
Contributor Author

plessbd commented Mar 28, 2019

I agree.

Do we currently have a way of knowing if they edited the file? Since all we have is the "current" file.

I would say some of these files should have an "enabled" key so that the file doesn't have to have objects deleted, just enabled or disabled, then we would be better able to do some of this.

@plessbd plessbd deleted the fix-cloud-charts branch March 28, 2019 02:49
return file_get_contents(TEMPLATE_DIR . '/roles.d/' . $realm . '.json')
=== file_get_contents($rolesFile);
return JSON::loadFile(TEMPLATE_DIR . '/roles.d/' . $realm . '.json', false)
=== JSON::loadFile($rolesFile, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Two different object instances will never be === (https://www.php.net/manual/en/language.oop5.object-comparison.php).

@plessbd plessbd mentioned this pull request Mar 28, 2019
@plessbd plessbd added Category:Cloud Cloud Realm bug Bugfixes labels Mar 28, 2019
@plessbd plessbd added this to the 8.1.0 milestone Mar 28, 2019
@smgallo smgallo changed the title Update Cloud roles file fix roles file comparison Fix roles file comparison to use object not string Apr 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugfixes Category:Cloud Cloud Realm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants