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: avoid type: php to detected project type but instead show a warning, fixes #4403, fixes #1919 #5011

Merged
merged 3 commits into from
Jul 4, 2023

Conversation

gilbertsoft
Copy link
Member

@gilbertsoft gilbertsoft commented Jun 22, 2023

The Issue

How This PR Solves The Issue

If an app type was set already before running ddev config it won't longer be overwritten by the detected app type but a warning is shown to let the user know about. The only way to change the type config is to provide a new value using --projecttype flag.

Not implemented so far but could be an option to allow the type auto to enforce the value from the detection. But to me this currently looks superfluous.

Manual Testing Instructions

Use ddev config --projecttype=... with an other type than already specified in the project. This should set the new value and not using the auto detected type.

Automated Testing Overview

No new tests are introduced.

Related Issue Link(s)

Release/Deployment Notes

@rfay rfay changed the title Avoid changing an already set type but show a warning Avoid changing an already set type but show a warning, fixes #4403 Jun 22, 2023
@github-actions
Copy link

github-actions bot commented Jun 22, 2023

@gilbertsoft gilbertsoft force-pushed the bugfix/config-command branch 10 times, most recently from 2c81c2a to 121f225 Compare June 25, 2023 18:25
@gilbertsoft gilbertsoft marked this pull request as ready for review June 26, 2023 07:35
@gilbertsoft gilbertsoft requested a review from a team as a code owner June 26, 2023 07:35
@rfay rfay changed the title Avoid changing an already set type but show a warning, fixes #4403 Avoid changing an already set type but show a warning, fixes #4403, fixes #1919 Jun 26, 2023
Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

This seems to work as specified, but still emits the message:
You have specified a project type of 'php' but a project of type 'drupal9' was discovered in /home/rfay/workspace/d9/web - is that intended? (Edit: I see from the title that it is intended.)

However, if you use the simple ddev config command, it discovers the docroot and then switches to the discovered type. That's not what you want is it?

Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

Thanks for solving this problem.

It looks to me like this mostly solves the problem, except that it doesn't respect existing with ddev config interactive configuration.

Could we use none for the no-project-type option? Have a better idea?

The ddev config --project-type would then have to take "none", but I imagine it already would with GetAppTypes() having the listed items.

Docs will need update to explain the situation of "none"; I'm pretty sure they say "php" is the default.

Don't forget that "none" in a python or django4 project would be controlled by webserver_type and may be a bit different.

pkg/ddevapp/config.go Show resolved Hide resolved
pkg/ddevapp/config.go Show resolved Hide resolved
@@ -82,6 +82,7 @@ var ValidNodeJSVersions = []string{"14", "16", "18", "20"}

// App types
const (
AppTypeNone = ""
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 this would be better as "none", not sure. Hate empty values like this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Just an internal thing which never gets saved to the config, so value is not important here but we can change it to none if you prefer.

@rfay rfay changed the title Avoid changing an already set type but show a warning, fixes #4403, fixes #1919 Avoid type: php to detected project type but instead show a warning, fixes #4403, fixes #1919 Jun 27, 2023
@gilbertsoft
Copy link
Member Author

However, if you use the simple ddev config command, it discovers the docroot and then switches to the discovered type. That's not what you want is it?

Have to check interactive config again...

@gilbertsoft
Copy link
Member Author

It looks to me like this mostly solves the problem, except that it doesn't respect existing with ddev config interactive configuration.

Will check again...

Could we use none for the no-project-type option? Have a better idea?

The ddev config --project-type would then have to take "none", but I imagine it already would with GetAppTypes() having the listed items.

No, like explained above none is an internal value only during the init of the ddevapp and is no valid option for the user. If it's still none on saving it gets replaced by php instead.

Docs will need update to explain the situation of "none"; I'm pretty sure they say "php" is the default.

php is still the default, has not changed see above.

@gilbertsoft
Copy link
Member Author

Interactive config works for me so far. Can you please explain your exact case a bit more @rfay ?
grafik

@rfay
Copy link
Member

rfay commented Jun 27, 2023

Here's interactive config with it changing the project type from php back to drupal9. Maybe this is intended and OK? But it's changing it back when not expected probably.

# Existing drupal9
$ ddev config --project-type=php
You are reconfiguring the project at /Users/rfay/workspace/d9.
The existing configuration will be updated and replaced.
You have specified a project type of 'php' but a project of type 'drupal9' was discovered in /Users/rfay/workspace/d9/web
2023-06-27T07:10:37.163 Flushed mutagen sync session 'd9'
Configuration complete. You may now run 'ddev start'.
rfay@rfay-tag1-m1:~/workspace/d9$ ddev describe
2023-06-27T07:10:48.242 detected terminal width=98 urlPortWidth=39.2 infoWidth=24
┌────────────────────────────────────────────────────────────────────────────────────┐
│ Project: d9 ~/workspace/d9 https://d9.ddev.site                                    │
│ Docker provider: Colima                                                            │
│ Router: traefik                                                                    │
├────────────┬──────┬─────────────────────────────────────────┬──────────────────────┤
│ SERVICE    │ STAT │ URL/PORT                                │ INFO                 │
├────────────┼──────┼─────────────────────────────────────────┼──────────────────────┤
│ web        │ OK   │ https://d9.ddev.site                    │ php PHP8.1           │
│            │      │ InDocker: web:443,80,8025               │ nginx-fpm            │
│            │      │ Host: 127.0.0.1:49565,49564             │ docroot:'web'        │
│            │      │                                         │ Mutagen enabled (ok) │
│            │      │                                         │ NodeJS:14            │
├────────────┼──────┼─────────────────────────────────────────┼──────────────────────┤
│ db         │ OK   │ InDocker: db:3306                       │ mariadb:10.4         │
│            │      │ Host: 127.0.0.1:9102                    │ User/Pass: 'db/db'   │
│            │      │                                         │ or 'root/root'       │
├────────────┼──────┼─────────────────────────────────────────┼──────────────────────┤
│ PHPMyAdmin │ OK   │ https://d9.ddev.site:8037               │                      │
│            │      │ InDocker: dba:80,80                     │                      │
│            │      │ `ddev launch -p`                        │                      │
├────────────┼──────┼─────────────────────────────────────────┼──────────────────────┤
│ Mailhog    │      │ MailHog: https://d9.ddev.site:8026      │                      │
│            │      │ `ddev launch -m`                        │                      │
├────────────┼──────┼─────────────────────────────────────────┼──────────────────────┤
│ All URLs   │      │ https://d9.ddev.site,                   │                      │
│            │      │ https://127.0.0.1:49564,                │                      │
│            │      │ http://d9.ddev.site,                    │                      │
│            │      │ http://127.0.0.1:49565                  │                      │
└────────────┴──────┴─────────────────────────────────────────┴──────────────────────┘

rfay@rfay-tag1-m1:~/workspace/d9$ ddev config
You are reconfiguring the project at /Users/rfay/workspace/d9.
The existing configuration will be updated and replaced.
Project name (d9):

The docroot is the directory from which your site is served.
This is a relative path from your project root at /Users/rfay/workspace/d9
You may leave this value blank if your site files are in the project root
Docroot Location (web):
Found a drupal9 codebase at /Users/rfay/workspace/d9/web.
Project Type [backdrop, craftcms, django4, drupal10, drupal6, drupal7, drupal8, drupal9, laravel, magento, magento2, php, python, shopware6, typo3, wordpress] (drupal9):
2023-06-27T07:11:09.019 Ensuring write permissions for d9
2023-06-27T07:11:09.02 Existing settings.php file includes settings.ddev.php
Configuration complete. You may now run 'ddev start'.
rfay@rfay-tag1-m1:~/workspace/d9$ ddev describe
2023-06-27T07:11:16.734 detected terminal width=98 urlPortWidth=39.2 infoWidth=24
┌────────────────────────────────────────────────────────────────────────────────────┐
│ Project: d9 ~/workspace/d9 https://d9.ddev.site                                    │
│ Docker provider: Colima                                                            │
│ Router: traefik                                                                    │
├────────────┬──────┬─────────────────────────────────────────┬──────────────────────┤
│ SERVICE    │ STAT │ URL/PORT                                │ INFO                 │
├────────────┼──────┼─────────────────────────────────────────┼──────────────────────┤
│ web        │ OK   │ https://d9.ddev.site                    │ drupal9 PHP8.1       │
│            │      │ InDocker: web:8025,443,80               │ nginx-fpm            │
│            │      │ Host: 127.0.0.1:49564,49565             │ docroot:'web'        │
│            │      │                                         │ Mutagen enabled (ok) │
│            │      │                                         │ NodeJS:14            │
├────────────┼──────┼─────────────────────────────────────────┼──────────────────────┤
│ db         │ OK   │ InDocker: db:3306                       │ mariadb:10.4         │
│            │      │ Host: 127.0.0.1:9102                    │ User/Pass: 'db/db'   │
│            │      │                                         │ or 'root/root'       │
├────────────┼──────┼─────────────────────────────────────────┼──────────────────────┤
│ PHPMyAdmin │ OK   │ https://d9.ddev.site:8037               │                      │
│            │      │ InDocker: dba:80,80                     │                      │
│            │      │ `ddev launch -p`                        │                      │
├────────────┼──────┼─────────────────────────────────────────┼──────────────────────┤
│ Mailhog    │      │ MailHog: https://d9.ddev.site:8026      │                      │
│            │      │ `ddev launch -m`                        │                      │
├────────────┼──────┼─────────────────────────────────────────┼──────────────────────┤
│ All URLs   │      │ https://d9.ddev.site,                   │                      │
│            │      │ https://127.0.0.1:49564,                │                      │
│            │      │ http://d9.ddev.site,                    │                      │
│            │      │ http://127.0.0.1:49565                  │                      │
└────────────┴──────┴─────────────────────────────────────────┴──────────────────────┘

@gilbertsoft
Copy link
Member Author

gilbertsoft commented Jun 27, 2023

Here's interactive config with it changing the project type from php back to drupal9. Maybe this is intended and OK? But it's changing it back when not expected probably.

Got it now. Okay, we have to discuss the desired behavior then. At the moment the discovered project type is suggested during interactive setup but the user can change it again to another type. To me this looks fine but well, one could have an other opinion. I'm open for both ways...

@gilbertsoft gilbertsoft changed the title Avoid type: php to detected project type but instead show a warning, fixes #4403, fixes #1919 fix: avoid type: php to detected project type but instead show a warning, fixes #4403, fixes #1919 Jun 28, 2023
@rfay
Copy link
Member

rfay commented Jul 3, 2023

Rebased

@github-actions github-actions bot added the bugfix label Jul 3, 2023
Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

Seems good to me, did manual testing again. Thanks!

@rfay rfay merged commit a22c463 into ddev:master Jul 4, 2023
19 checks passed
@rfay rfay deleted the bugfix/config-command branch July 4, 2023 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants