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

add DDEV_DATABASE_FAMILY variable, fixes #4954 #4991

Merged
merged 12 commits into from
Jun 22, 2023

Conversation

tyler36
Copy link
Collaborator

@tyler36 tyler36 commented Jun 16, 2023

The Issue

I want to generate database resource URLs for use in code and DDEV addons.

Currently, DDEV exposes DDEV_DATABASE which is app.Database.Type + ":" + app.Database.Version,.

This is difficult to use because it must be parsed, and converted (MariaDB uses mysql protocol).

How This PR Solves The Issue

This PR adds a new environmental variable: DDEV_DATABASE_FAMILY

  • Defaults to mysql
  • Set to postgres if database is postgres

Manual Testing Instructions

  1. Start a DDEV project
  2. Type ddev exec set | grep DDEV_DATABASE to check currently set database variables

Automated Testing Overview

Related Issue Link(s)

Fixes #4954

Release/Deployment Notes

@tyler36 tyler36 requested a review from a team as a code owner June 16, 2023 03:05
@rfay
Copy link
Member

rfay commented Jun 16, 2023

Look at you go!

@tyler36
Copy link
Collaborator Author

tyler36 commented Jun 16, 2023

Sorry for the noise. Finally added a "GO" addon to VScode for proper syntax highlighting etc.

@github-actions
Copy link

github-actions bot commented Jun 16, 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.

Thanks!

  • Still needs to be added to docs (custom_commands.md) If you find other things missing there, OK to add.
  • Still needs to be added to test, TestEnvironmentVariables (you may find that some other things like DDEV_DATABASE are missing from test, OK to add.

@tyler36 tyler36 requested a review from a team as a code owner June 19, 2023 00:30
@tyler36 tyler36 force-pushed the 20230616_add_DDEV_DATABASE_PROTOCOL_variable branch 2 times, most recently from ba40e3c to 1d0378c Compare June 19, 2023 01:57
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.

Thanks! Mainly only a minor naming issue.

And you have to add the new variable to the docker-composer template pkg/ddevapp/app_compose_template.yaml.

pkg/ddevapp/ddevapp.go Outdated Show resolved Hide resolved
pkg/ddevapp/ddevapp.go Outdated Show resolved Hide resolved
@tyler36
Copy link
Collaborator Author

tyler36 commented Jun 19, 2023

And you have to add the new variable to the docker-composer template pkg/ddevapp/app_compose_template.yaml.

OK. That was the piece I was missing.

@tyler36
Copy link
Collaborator Author

tyler36 commented Jun 19, 2023

Error: File is not gofmt-ed with -s (gofmt)

Not sure why the golint test is failing.

@gilbertsoft
Copy link
Member

Error: File is not gofmt-ed with -s (gofmt)

Not sure why the golint test is failing.

You just miss two spaces at the mentioned line.

pkg/ddevapp/ddevapp.go Outdated Show resolved Hide resolved
@gilbertsoft gilbertsoft changed the title add DDEV_DATABASE_PROTOCOL variable add DDEV_DATABASE_FAMILY variable Jun 19, 2023
@tyler36 tyler36 requested review from gilbertsoft and rfay June 19, 2023 23:50
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 good. Restarted the failing test which should become green too...

@rfay rfay changed the title add DDEV_DATABASE_FAMILY variable add DDEV_DATABASE_FAMILY variable for #4954 Jun 20, 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.

Looks great to me, thanks! Manually tested fine.

tyler36 and others added 4 commits June 21, 2023 10:50
Resolve "Error: File is not gofmt-ed with -s (gofmt)"

Co-authored-by: Gilbertsoft <25326036+gilbertsoft@users.noreply.github.com>
@tyler36 tyler36 force-pushed the 20230616_add_DDEV_DATABASE_PROTOCOL_variable branch from 0203dcc to cdc58ff Compare June 21, 2023 01:51
@tyler36
Copy link
Collaborator Author

tyler36 commented Jun 21, 2023

Rebase

@rfay rfay changed the title add DDEV_DATABASE_FAMILY variable for #4954 add DDEV_DATABASE_FAMILY variable, fixes #4954 Jun 22, 2023
@rfay rfay merged commit eaf2c11 into ddev:master Jun 22, 2023
17 checks passed
@rfay
Copy link
Member

rfay commented Jun 22, 2023

Congratulations and thanks!

@tyler36 tyler36 deleted the 20230616_add_DDEV_DATABASE_PROTOCOL_variable branch June 29, 2023 00:41
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.

Expose database type as variable for use in scripts
4 participants