Repository navigation
Add ddev describe command - #116
Conversation
a44ba7a to
be81d5a
Compare
|
Removed WIP but added needs docs. This is good to go from a functionality perspective, but probably still needs a few lines in the docs covering it. |
|
Testing Results
|
rickmanelius
left a comment
There was a problem hiding this comment.
Added my review notes here instead of in this modal. #116 (comment)
Correct. My goal would be to add PHPMyAdmin/xdebug/whatever other info to this list as it lands. Considering the xdebug PR is currently open, this may also need to happen as a followup depending on ordering.
I did cheat a bit here. I believe we need to open up the port on the router to make this actually happen. |
|
Noted on phpMyAdmin being in a separate ticket. Also I know the port/router was a nitpick only because, as an end-user receiving that information, I would expect to be able to use that directly from the command line. However. If that is not the case, then we probably need to provide information/instructions on how to use that information. |
rfay
left a comment
There was a problem hiding this comment.
I would propose that our mysql description could be improved. This text is directly from the issue, but it would be cool if we could find a way to explain where the mysql server actually lives from an internal perspective (host named 'db') and also how to access it from an external perspective (currently mocked)
Agreed. I'm not sure how to convey that, but it's something that gave me pause when adding this functionality. I'm open to any suggestions on how to better get that across. Ultimately I went w/ what I felt was the most common need of the user, but who knows if I hit the mark. I actually wonder if we can make the hostname the same from both outside/inside the container. I may play w/ that this morning. |
rfay
left a comment
There was a problem hiding this comment.
This works pretty nicely, and good work with the code. Thanks for the good effort. It's worth considering whether this would be the time to pioneer the non-binary-run testing technique.
| // DescribeCommand represents the `ddev config` command | ||
| var DescribeCommand = &cobra.Command{ | ||
| Use: "describe", | ||
| Short: "Get a detailed description about a running ddev site.", |
| Short: "Get a detailed description about a running ddev site.", | ||
| Run: func(cmd *cobra.Command, args []string) { | ||
| if len(args) > 1 { | ||
| log.Fatal("Too many arguments detected. Please use `ddev describe` or `ddev describe [appname]`") |
There was a problem hiding this comment.
ddev describe -h shows [flags] as an option, but there are none, right? Is there a way to fix that?
| }, | ||
| } | ||
|
|
||
| func describeApp(appName string) (string, error) { |
There was a problem hiding this comment.
This is not a global, so automated tools are not flagging a required explanatory comment, but should we have one in general anyway? I'd be in favor.
| labels := map[string]string{ | ||
| "com.ddev.site-name": appName, | ||
| "com.ddev.container-type": "web", | ||
| } |
There was a problem hiding this comment.
This general pattern looks like it will show up many places. Does it already? Can/should it be moved into a utility package?
There was a problem hiding this comment.
It is generalized in the platform package. Thus far, I believe that is the only place we need it. Happy to move it into a utils package if we need it elsewhere.
|
|
||
| } | ||
|
|
||
| // TestDevLogs tests that the Dev logs functionality is working. |
There was a problem hiding this comment.
This comment needs to be updated to be informational :) golint doesn't check _test.go so it didn't validate, sadly.
| app.Init() | ||
| app, err := getActiveApp() | ||
| if err != nil { | ||
| log.Fatalf("Could not find an active ddev configuration, have you ran 'ddev config'?: %v", err) |
| app, err := getActiveApp() | ||
| if err != nil { | ||
| log.Fatalf("Could not initialize application: %v", err) | ||
| log.Fatalf("Could not find an active ddev configuration, have you ran 'ddev config'?: %v", err) |
| app.Init() | ||
| app, err := getActiveApp() | ||
| if err != nil { | ||
| log.Fatalf("Could not find an active ddev configuration, have you ran 'ddev config'?: %v", err) |
| return nil | ||
| } | ||
|
|
||
| // FindContainerByLabels takes a map of label names and values and returns any docker containers which match all labels. |
| } | ||
| } | ||
|
|
||
| return docker.APIContainers{}, fmt.Errorf("could not find containers which matched search criteria") |
There was a problem hiding this comment.
This would be better if the search criteria were listed in the error.
| You can also see more detailed information about a site by running `ddev describe` or `ddev describe [site-name]`. | ||
|
|
||
| ``` | ||
| NAME DOCROOT TYPE URL STATUS |
There was a problem hiding this comment.
I don't think we should output docroot here, but instead the root of the project possibly labeled as Location. Docroot is an important detail when it comes to what directory should be served, but I wouldn't consider it the location i want to jump to first when switching to a project. There can often be code or tools at the root of the repo that would be frequently interacted with, so I think its more useful and consistent to provide the root.
There was a problem hiding this comment.
@rickmanelius this is your purview I believe. Care to weigh in?
There was a problem hiding this comment.
I think project location is more valuable to an end-user as a means to know where to change the directory in order to be within scope for ddev commands that are not global.
Offline, it was suggested that perhaps we put both, but I think widening the terminal output wouldn't really be of benefit. My vote would be location and point to the top level directory.
| Username: root | ||
| Password: root | ||
| Database name: data | ||
| Connection Info: drupal8.ddev.local:3306 |
There was a problem hiding this comment.
This is a bit of a confusing scenario, as port 3306 is valid within the compose network, but we actually expose a random port to the host system. If I attempted to connect w/ the provided credentials via mysql cli on the host machine, this would fail to connect. Ideally the port would be consistent inside and out of container, but I'm not sure how we would achieve that when each site would have a port to expose, and I don't believe we can change the internal port expose on the fly. It's not ideal to output 2 different connection options, but I think it's necessary in order to ensure we are providing connection info that will work for utilities regardless of whether they are on the host system or within the compose network.
|
Code looks great and works as advertised. Welcome improvements re: active app as well. 👍 |
…not called on error
…de review feedback
74cef71 to
65b012a
Compare
|
I believe I have responded to all the feedback on this, and if I can get an approval I would like to merge. There is the outstanding issue of the mysql host name, but I have that working and will be opening a PR shortly. I'm comfortable moving forward w/ this as-is if others are but would understand if we want to wait until the mysql proxy PR is opened/merged first. |
|
Go for it, @beeradb - thanks for the good work. |
The Problem:
We need to add a
ddev describecommand which gives extended information about services which are running within a ddev application.The Fix:
The resulting
ddev describecommand returns the following information about a site when run from within the document root:It can also be run using the site name, as in
ddev describe drupal8, from any path.Additional work
As a part of these fixes, I also reworked application instantiation within cobra commands. Gone is the "activeApp" global. It's been replaced with a getActiveApp() which returns an initialized application, along with an error (if an active app can't be found). I also updated all instances of app instantiation to use this new method.
Additionally, all instances of app.Init() now require a path to the application root, as a string parameter. See https://github.com/drud/ddev/pull/116/files#diff-ef6770d9874ceccc0d1f5c859385f6feR36
Overall the goal was to make the process of getting the active application interface more consistent and less reliant on globals.
Automation Overview:
This has reasonably good test coverage as a starting point. Review the cmd/ddev/cmd/describe_test.go file. There are both binary based integration tests and unit tests.
Should we also test the describe method of the local platform struct (in pkg/platform/local.go?) or move some of the more unit-test related functionality there?
Related Issue Link(s):
#35
Release/Deployment notes:
Does this affect anything else, or are there ramifications for other code? Does anything have to be done on deployment?