backport of commit 87f702e6af (#5897)

Co-authored-by: Ryan Derr <ryan.derr@hashicorp.com>
pull/5902/head
hc-github-team-secure-boundary 10 months ago committed by GitHub
parent c36055afd7
commit 8a4c84ded3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -95,12 +95,18 @@ func (r *Repository) UpdateControllerStatus(ctx context.Context, controller *Con
db.ExpBackoff{},
func(reader db.Reader, w db.Writer) error {
var err error
rowsUpdated, err = w.Exec(ctx, updateController,
[]any{
sql.Named("controller_address", controller.Address),
sql.Named("controller_description", controller.Description),
sql.Named("controller_private_id", controller.PrivateId),
})
params := []any{
sql.Named("controller_private_id", controller.PrivateId),
sql.Named("controller_address", controller.Address),
}
if controller.Description != "" {
params = append(params, sql.Named("controller_description", controller.Description))
} else {
params = append(params, sql.Named("controller_description", nil))
}
rowsUpdated, err = w.Exec(ctx, updateController, params)
switch {
case err != nil:
return errors.Wrap(ctx, err, op+":Update")

@ -184,6 +184,28 @@ func TestRepository_UpdateControllerStatus(t *testing.T) {
require.Equal(t, 1, c)
},
},
"valid-ipv4-controller-remove-description": {
originalController: NewController("test", WithAddress("127.0.0.1"), WithDescription("short name description")),
updatedController: NewController("test", WithAddress("127.0.0.2")),
wantCount: 1,
cleanUpFunc: func(t *testing.T, rw *db.Db, privateId string) {
t.Helper()
c, err := rw.Exec(ctx, removeControllerSql, []any{privateId})
require.NoError(t, err)
require.Equal(t, 1, c)
},
},
"valid-ipv4-controller-no-description": {
originalController: NewController("test", WithAddress("127.0.0.1")),
updatedController: NewController("test", WithAddress("127.0.0.2")),
wantCount: 1,
cleanUpFunc: func(t *testing.T, rw *db.Db, privateId string) {
t.Helper()
c, err := rw.Exec(ctx, removeControllerSql, []any{privateId})
require.NoError(t, err)
require.Equal(t, 1, c)
},
},
}
for name, tt := range tests {

Loading…
Cancel
Save