Skip to content

Commit

Permalink
Add support for public/private host, cleanup summarize view (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
christhemorse authored Oct 23, 2023
1 parent 1516c5c commit f86914e
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions cmd/printer/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ func DatabaseList(databases []govultr.Database, meta *govultr.Meta) { //nolint:
display(columns{"TAG", databases[d].Tag})
display(columns{"DB NAME", databases[d].DBName})
display(columns{"HOST", databases[d].Host})

if databases[d].PublicHost != "" {
display(columns{"PUBLIC HOST", databases[d].PublicHost})
}

display(columns{"USER", databases[d].User})
display(columns{"PASSWORD", databases[d].Password})
display(columns{"PORT", databases[d].Port})
Expand Down Expand Up @@ -129,6 +134,11 @@ func DatabaseList(databases []govultr.Database, meta *govultr.Meta) { //nolint:
display(columns{"TAG", databases[d].ReadReplicas[r].Tag})
display(columns{"DB NAME", databases[d].ReadReplicas[r].DBName})
display(columns{"HOST", databases[d].ReadReplicas[r].Host})

if databases[d].ReadReplicas[r].PublicHost != "" {
display(columns{"PUBLIC HOST", databases[d].ReadReplicas[r].PublicHost})
}

display(columns{"USER", databases[d].ReadReplicas[r].User})
display(columns{"PASSWORD", databases[d].ReadReplicas[r].Password})
display(columns{"PORT", databases[d].ReadReplicas[r].Port})
Expand Down Expand Up @@ -178,10 +188,10 @@ func DatabaseList(databases []govultr.Database, meta *govultr.Meta) { //nolint:
func DatabaseListSummary(databases []govultr.Database, meta *govultr.Meta) {
defer flush()

display(columns{"ID", "REGION", "LABEL", "STATUS", "ENGINE", "VERSION", "HOST", "PORT", "USER", "PASSWORD"})
display(columns{"ID", "REGION", "LABEL", "STATUS", "ENGINE", "VERSION"})

if len(databases) == 0 {
display(columns{"---", "---", "---", "---", "---", "---", "---", "---", "---", "---"})
display(columns{"---", "---", "---", "---", "---", "---"})
MetaDBaaS(meta)
return
}
Expand All @@ -194,10 +204,6 @@ func DatabaseListSummary(databases []govultr.Database, meta *govultr.Meta) {
databases[i].Status,
databases[i].DatabaseEngine,
databases[i].DatabaseEngineVersion,
databases[i].Host,
databases[i].Port,
databases[i].User,
databases[i].Password,
})
}

Expand All @@ -224,6 +230,11 @@ func Database(database *govultr.Database) { //nolint: funlen,gocyclo
display(columns{"TAG", database.Tag})
display(columns{"DB NAME", database.DBName})
display(columns{"HOST", database.Host})

if database.PublicHost != "" {
display(columns{"PUBLIC HOST", database.PublicHost})
}

display(columns{"USER", database.User})
display(columns{"PASSWORD", database.Password})
display(columns{"PORT", database.Port})
Expand Down Expand Up @@ -281,6 +292,11 @@ func Database(database *govultr.Database) { //nolint: funlen,gocyclo
display(columns{"TAG", database.ReadReplicas[r].Tag})
display(columns{"DB NAME", database.ReadReplicas[r].DBName})
display(columns{"HOST", database.ReadReplicas[r].Host})

if database.ReadReplicas[r].PublicHost != "" {
display(columns{"PUBLIC HOST", database.ReadReplicas[r].PublicHost})
}

display(columns{"USER", database.ReadReplicas[r].User})
display(columns{"PASSWORD", database.ReadReplicas[r].Password})
display(columns{"PORT", database.ReadReplicas[r].Port})
Expand Down

0 comments on commit f86914e

Please sign in to comment.