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

Implement DdevGlobalConfig initialization in one place #5007

Merged
merged 6 commits into from
Jun 22, 2023

Conversation

rfay
Copy link
Member

@rfay rfay commented Jun 21, 2023

The Issue

@gilbertsoft pointed out elsewhere that globalconfig.DdevGlobalConfig initialization should be encapsulated in a New() function.

How This PR Solves The Issue

Do it and work it all out.

This one ends up being a pre-requisite for some other PRs, especially

@rfay rfay force-pushed the 20230621_globalconfig_new branch from 42063cc to f060fff Compare June 21, 2023 21:59
@github-actions
Copy link

github-actions bot commented Jun 21, 2023

@rfay rfay requested a review from gilbertsoft June 21, 2023 22:19
rfay added 5 commits June 21, 2023 22:26
In ddev#4995 we had to do initialization of RouterHTTPPort
deep in unrelated code. Since it's now done in globalconfig initialization
we don't have to do that now
@rfay rfay force-pushed the 20230621_globalconfig_new branch from b968bcf to b7b5f17 Compare June 22, 2023 04:49
Copy link
Member

@gilbertsoft gilbertsoft left a comment

Choose a reason for hiding this comment

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

Looks very good! A minor change request. I did not check tests, only normal code btw.

Comment on lines +226 to +229
// Remove some items that are defaults
if cfgCopy.RequiredDockerComposeVersion == RequiredDockerComposeVersionDefault {
cfgCopy.RequiredDockerComposeVersion = ""
}
Copy link
Member

Choose a reason for hiding this comment

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

I'd avoid this completely. Instead use a getter function which returns a sane default if the config value is empty. Similar you did with the http ports above.

Copy link
Member

Choose a reason for hiding this comment

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

Oh I see the function bellow which is used in the code. There you also could check for a value in the global config or use the default if empty.

Copy link
Member

Choose a reason for hiding this comment

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

Instead of this code, better fix it on loading.

Copy link
Member Author

Choose a reason for hiding this comment

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

No, the problem here is on writing. We just want to hide this value from people. We need it on reading (normally the default). But note upcoming

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that's clear, the default value should never be written to the file. But still I think validation and removal should better be done after reading and a getter function should take care to return the default value. Anyway, that's not a stopper, go ahead.

@rfay rfay marked this pull request as ready for review June 22, 2023 19:51
@rfay rfay requested a review from a team as a code owner June 22, 2023 19:51
Comment on lines +75 to +80
TableStyle: "default",
RouterHTTPPort: "80",
RouterHTTPSPort: "443",
LastStartedVersion: "v0.0",
NoBindMounts: nodeps.NoBindMountsDefault,
UseTraefik: nodeps.UseTraefikDefault,
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 see that these should be constants, I don't want to do it right now but will try to fix that up in the traefik PR.

@rfay rfay merged commit 76790f2 into ddev:master Jun 22, 2023
15 of 16 checks passed
@rfay rfay deleted the 20230621_globalconfig_new branch June 22, 2023 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants