-
-
Notifications
You must be signed in to change notification settings - Fork 585
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
Use --file
for import-db and rework import-db and export-db, fixes #4593
#5013
Conversation
Download the artifacts for this pull request:
See Testing a PR |
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.
I don't completely grok this yet, but please update the description here to
- explain the new internal/text package (and why you call it "text", which is not very descriptive)
- explain what the heredoc package is and why it's used
Although this is apparently simple, it is definitely not easy to review.
Since this will apparently be a pattern for future updates, could you please remove all the var
usages with pointers, and instead use flags, as is done in newer commands? start.go uses this technique, for example
Lines 36 to 47 in bbb2cac
skip, err := cmd.Flags().GetBool("skip-confirmation") | |
if err != nil { | |
util.Failed(err.Error()) | |
} | |
// Look for version change and opt-in to instrumentation if it has changed. | |
err = checkDdevVersionAndOptInInstrumentation(skip) | |
if err != nil { | |
util.Failed(err.Error()) | |
} | |
selectFlag, err := cmd.Flags().GetBool("select") |
ec12f71
to
e6bce72
Compare
Highly inspired by GH cli. It's about text helpper functions so the name looks fine to me.
It's explained in the PR, it's about the heredoc syntax which allows to indent texts so we do not longer have texts starting on the first col but can be indented properly like the code.
Yeah, the main thing which has changed is the indentation but the diff view is not very helpful here. The biggest change is the access to the flags like requested.
Done. |
Just read the heredoc readme, I like that feature! Not sure why they named it "heredoc", which means something completely different in bash. |
heredoc is a name in the PHP world, not sure if somewhere else too. See https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc |
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.
This seems like a great improvement and good example of command setup, thanks! I manually tested and everything seems to work fine.
- Please don't change import-db's --target-db. There was no request for this, and there's no reason to break people's existing scripts and such.
- I can cope with the way you've implemented
--file
but the idea was to support it as an alternate rather than as a replacement for--src
. It's OK though. - Please credit @miromichalicka in the commit when this goes in.
- Would you mind changing the text package to something like "indent" instead? "text" is already the name of dozens of packages.
- Interested why the package doesn't just go into pkg; that would be the natural place for it. Unless you have a strong argument I'd prefer for it to be there.
--file
for import-db, fixes #4593
--file
for import-db, fixes #4593--file
for import-db and rework import-db and export-db, fixes #4593
Nothing will break, --target-db still exists. And I really like to have this streamlined with other tools e.g. mysqldump, that's why I've changed it in the first place. We should always try to use standards from other tools so it easier for people to use.
Same as above, src still exists. But we can not use source for import because there it's the target or destination but file we can use in all places.
Changed it to heredoc, best name I've found and also moved to pkg now. |
e6bce72
to
91982d4
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.
No, --target-db
does not work here, which is why the tests are failing. Looks like it's just a bug that makes it not work though. Please manually test.
$ ddev import-db --src=.tarballs/db.sql.gz --target-db=junk
Flag --src has been deprecated, please use --file instead
Flag --target-db has been deprecated, please use --database instead
Error: failed to import database 'db' for d9: Unable to validate import asset junk: invalid asset: file not found
Usage:
ddev import-db [project] [flags]
Examples:
$ ddev import-db
$ ddev import-db --file=.tarballs/junk.sql
$ ddev import-db --file=.tarballs/junk.sql.gz
$ ddev import-db --database=other_db --file=.tarballs/db.sql.gz
$ ddev import-db --file=.tarballs/db.sql.bz2
$ ddev import-db --file=.tarballs/db.sql.xz
$ ddev import-db < db.sql
$ ddev import-db some-project < db.sql
$ gzip -dc db.sql.gz | ddev import-db
Flags:
-d, --database string Target database to import into (default "db")
--extract-path string Path to extract within the archive
-f, --file string Path to a SQL dump file, plain text or compressed (tar/tar.gz/tgz/zip)
-h, --help help for import-db
--no-drop Do not drop the database before importing
--no-progress Do not output progress
Global Flags:
-j, --json-output If true, user-oriented output will be in JSON format.
Looks like a bug while reading the flags. Will have a look.... |
Found the problem, copy&paste issue. Same in the db-export :( |
91982d4
to
330762f
Compare
330762f
to
54d62ea
Compare
Did you intentionally re-add the -z flag? It's still there...
|
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.
As far as I can tell, --target-db still doesn't work:
Edit: I messed up the command, it's working
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.
Looks like it's ready to go, thanks! Manually tested as well.
The Issue
How This PR Solves The Issue
This PR streamlines the flags and descriptions of the import-db and export-db commands. It introduces a new package which makes it possible to write cleaner command definitions regarding indentation. Commands are created with a factory function.
Old flags are still here and marked as deprecated to avoid BC issues.
Thanks to @miromichalicka for the initial work done in #4647.
Manual Testing Instructions
The impact is minimal and everything should be covered by automated testing.
Automated Testing Overview
Related Issue Link(s)
Closes:
Replaces:
Release/Deployment Notes