Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/2.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmccallister committed Mar 4, 2021
2 parents 2550f39 + baff35c commit e763f14
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion command/add/add.go
Expand Up @@ -92,7 +92,7 @@ func NewCommand(home string, docker client.CommonAPIClient, output terminal.Outp
}

// prompt for a database
database, dbhost, dbname, port, driver, err := prompt.CreateDatabase(cmd.Context(), docker, output)
database, dbhost, dbname, port, driver, err := prompt.CreateDatabase(cmd, docker, output)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion command/create/create.go
Expand Up @@ -118,7 +118,7 @@ func NewCommand(home string, docker client.CommonAPIClient, getter downloader.Ge
}

// prompt for a new database
database, dbhost, dbname, port, driver, err := prompt.CreateDatabase(cmd.Context(), docker, output)
database, dbhost, dbname, port, driver, err := prompt.CreateDatabase(cmd, docker, output)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/certinstall/certinstall.go
Expand Up @@ -93,7 +93,7 @@ func findLinuxDistribution(description string) (string, error) {
return "arch", nil
}

if strings.Contains(description, "Ubuntu") {
if strings.Contains(description, "Ubuntu") || strings.Contains(description, "Pop!_OS") {
return "debian", nil
}

Expand Down
18 changes: 14 additions & 4 deletions pkg/prompt/prompt.go
Expand Up @@ -23,7 +23,7 @@ import (

// CreateDatabase is used to interactively walk a user through creating a new database. It will return true if the user created a database along
// with the hostname, database, port, and driver for the database container.
func CreateDatabase(ctx context.Context, docker client.CommonAPIClient, output terminal.Outputer) (bool, string, string, string, string, error) {
func CreateDatabase(cmd *cobra.Command, docker client.CommonAPIClient, output terminal.Outputer) (bool, string, string, string, string, error) {
confirm, err := output.Confirm("Add a database for the site", true, "")
if err != nil {
return false, "", "", "", "", err
Expand All @@ -33,13 +33,19 @@ func CreateDatabase(ctx context.Context, docker client.CommonAPIClient, output t
return false, "", "", "", "", nil
}

// make sure the context is not nil
ctx := cmd.Context()
if ctx == nil {
ctx = context.Background()
}

// add filters to show only the environment and database containers
filter := filters.NewArgs()
filter.Add("label", labels.Nitro)
filter.Add("label", labels.Type+"=database")

// get a list of all the databases
containers, err := docker.ContainerList(ctx, types.ContainerListOptions{Filters: filter})
containers, err := docker.ContainerList(ctx, types.ContainerListOptions{Filters: filter, All: true})
if err != nil {
return false, "", "", "", "", err
}
Expand All @@ -54,8 +60,12 @@ func CreateDatabase(ctx context.Context, docker client.CommonAPIClient, output t
for _, c := range containers {
// start the container if not running
if c.State != "running" {
if err := docker.ContainerStart(ctx, c.ID, types.ContainerStartOptions{}); err != nil {
return false, "", "", "", "", err
for _, command := range cmd.Root().Commands() {
if command.Use == "start" {
if err := command.RunE(cmd, []string{}); err != nil {
return false, "", "", "", "", err
}
}
}
}

Expand Down

0 comments on commit e763f14

Please sign in to comment.