civo / cli

Our Command Line Interface (CLI) for interacting with your Civo resources

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Display Database DNS Endpoint

jhanley-com opened this issue · comments

Environment: Windows 10 x64
Version: Civo CLI v1.0.69
Bug Type: Enhancement
Priority: Low
Workaround Possible: Yes
Summary: Civo db show ID does not display the database DNS endpoint

If you create a Civo Database using Terraform (civo_database), the dns_endpoint is available and can be displayed with terraform show. This issue exists for the PostgreSQL database. I did not test with MySQL.

The Civo Web GUI also does not display this information.

A temporary workaround exists. You can manually combine the Civo Database ID with db.civo.com to create the DNS endpoint. However, since using the DNS endpoint instead of IPv4 addresses is a better solution when creating database DSN connection strings.

Hey,
I would like to take up this issue. I see that that the logic to generate output for the db show cmd is in cmd/database/database_show.go and here the required details comes from a db object FindDatabase call to the SDK which returns a Database object https://github.com/civo/civogo/blob/master/database.go#L18

but here the Database struct has no feild for DNS. Here is my take on this.

Approach - 1
Create a new PR in civogo and add DNS feild in SDK and then use it to generate the output.

Approach - 2
As @jhanley-com suggested we can append Civo DB ID to db.civo.com and construct a DNS endpoint. thus i can do something like.

		// Construct the DNS endpoint
		dnsEndpoint := fmt.Sprintf("%s.db.civo.com", db.ID)

		// Old code
		ow.AppendDataWithLabel("dns_endpoint", dnsEndpoint, "DNS Endpoint")