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

If the database is already initialized, use 0 as the return value #1033

Merged
merged 2 commits into from
Mar 25, 2021
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
19 changes: 11 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ Canonical reference for changes, improvements, and bugfixes for Boundary.

## Next

### New and Improved

* server: When performing recursive listing, `list` action is not longer
required to be granted to the calling user. Instead, the given scope acts as
the root point (so only results under that scope will be shown), and `list`
grant is evaluated per-scope.
[PR](https://github.com/hashicorp/boundary/pull/1016)

### Deprecations/Changes

* authentication: The `auth-methods/<id>:authenticate:login` action is
Expand All @@ -27,6 +19,17 @@ Canonical reference for changes, improvements, and bugfixes for Boundary.
now but will be removed in a few releases. Finally, in the Go SDK, the
`Authenticate` function now requires a `command` value to be passed in.

### New and Improved

* server: When performing recursive listing, `list` action is not longer
required to be granted to the calling user. Instead, the given scope acts as
the root point (so only results under that scope will be shown), and `list`
grant is evaluated per-scope.
[PR](https://github.com/hashicorp/boundary/pull/1016)
* database init: If the database is already initialized, return 0 as the exit
code. This matches how the `database migrate` command works.
[PR](https://github.com/hashicorp/boundary/pull/1033)

### Bug Fixes

* server: Roles for auto generated scopes are now generated at database init.
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/commands/database/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ func migrateDatabase(ctx context.Context, ui cli.Ui, dialect, u string, requireF
return unlock, 2
}
if requireFresh && st.InitializationStarted {
ui.Error(base.WrapAtLength("Database has already been initialized. Please use 'boundary database migrate'."))
return unlock, 2
ui.Output(base.WrapAtLength("Database has already been initialized. Please use 'boundary database migrate' for any upgrade needs."))
return unlock, -1
}
if st.Dirty {
ui.Error(base.WrapAtLength("Database is in a bad state. Please revert back to the last known good state."))
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/commands/database/funcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ func TestMigrateDatabase(t *testing.T) {
require.NoError(t, err)
return u
},
expectedCode: 2,
expectedError: "Database has already been initialized. Please use 'boundary database\nmigrate'.\n",
expectedCode: -1,
expectedOutput: "Database has already been initialized. Please use 'boundary database migrate'\nfor any upgrade needs.\n",
},
{
name: "bad_url_require_fresh",
Expand Down
6 changes: 5 additions & 1 deletion internal/cmd/commands/database/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,11 @@ func (c *InitCommand) Run(args []string) (retCode int) {

clean, errCode := migrateDatabase(c.Context, c.UI, dialect, migrationUrl, true)
defer clean()
if errCode != 0 {
switch errCode {
case 0:
case -1:
return 0
default:
return errCode
}

Expand Down