Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions vcr/mongo/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,20 @@ func runCreate(ctx context.Context, opts *Options) error {
return fmt.Errorf("failed to create database: %w", err)
}
fmt.Fprintf(io.Out, heredoc.Doc(`
%s Database created:
username: %s
password: %s
database: %s
connectionString: %s
%s Database created
%s username: %s
%s password: %s
%s database: %s
%s connectionString: %s
`),
c.SuccessIcon(),
c.Blue(cmdutil.InfoIcon),
result.Username,
c.Blue(cmdutil.InfoIcon),
result.Password,
c.Blue(cmdutil.InfoIcon),
result.Database,
c.Blue(cmdutil.InfoIcon),
result.ConnectionString)
return nil
}
10 changes: 5 additions & 5 deletions vcr/mongo/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ func TestMongoCreate(t *testing.T) {
},
want: want{
stdout: heredoc.Doc(`
✓ Database created:
username: test
password: test
database: TestDB
connectionString: mongodb://test:test@localhost:27017/TestDB
✓ Database created
username: test
password: test
database: TestDB
connectionString: mongodb://test:test@localhost:27017/TestDB
`),
},
},
Expand Down
14 changes: 9 additions & 5 deletions vcr/mongo/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,20 @@ func runInfo(ctx context.Context, opts *Options) error {
return fmt.Errorf("failed to get database info: %w", err)
}
fmt.Fprintf(io.Out, heredoc.Doc(`
%s Database info:
username: %s
password: %s
database: %s
connectionString: %s
%s Database info
%s username: %s
%s password: %s
%s database: %s
%s connectionString: %s
`),
c.SuccessIcon(),
c.Blue(cmdutil.InfoIcon),
result.Username,
c.Blue(cmdutil.InfoIcon),
result.Password,
c.Blue(cmdutil.InfoIcon),
result.Database,
c.Blue(cmdutil.InfoIcon),
result.ConnectionString)
return nil
}
10 changes: 5 additions & 5 deletions vcr/mongo/info/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ func TestMongoInfo(t *testing.T) {
},
want: want{
stdout: heredoc.Doc(`
✓ Database info:
username: test
password: test
database: TestDB
connectionString: mongodb://test:test@localhost:27017/TestDB
✓ Database info
username: test
password: test
database: TestDB
connectionString: mongodb://test:test@localhost:27017/TestDB
`),
},
},
Expand Down
15 changes: 12 additions & 3 deletions vcr/mongo/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"vonage-cloud-runtime-cli/pkg/cmdutil"

"github.com/MakeNowJust/heredoc"
"github.com/cli/cli/v2/utils"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -43,7 +44,7 @@ func runList(ctx context.Context, opts *Options) error {
io := opts.IOStreams()
c := opts.IOStreams().ColorScheme()

spinner := cmdutil.DisplaySpinnerMessageWithHandle(" Creating Database")
spinner := cmdutil.DisplaySpinnerMessageWithHandle(" Listing Databases")
result, err := opts.DeploymentClient().ListMongoDatabases(ctx, opts.Version)
spinner.Stop()
if err != nil {
Expand All @@ -55,9 +56,17 @@ func runList(ctx context.Context, opts *Options) error {
return nil
}

fmt.Fprintf(io.Out, "%s Databases:\n", c.SuccessIcon())
//nolint
tp := utils.NewTablePrinter(io)
tp.AddField(c.Bold("Database"), nil, nil)
tp.EndRow()
for _, db := range result {
fmt.Fprintf(io.Out, " - %s\n", db)
tp.AddField(db, nil, nil)
tp.EndRow()
}

if err := tp.Render(); err != nil {
return fmt.Errorf("error rending databases: %w", err)
}

return nil
Expand Down
6 changes: 3 additions & 3 deletions vcr/mongo/list/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ func TestMongoList(t *testing.T) {
},
want: want{
stdout: heredoc.Doc(`
✓ Databases:
- TestDB1
- TestDB2
Database
TestDB1
TestDB2
`),
},
},
Expand Down