Skip to content

Commit

Permalink
Fix potential panic in RDS instance selection
Browse files Browse the repository at this point in the history
Fixes a panic if there are no databases to choose from
  • Loading branch information
chrnorm committed Aug 8, 2024
1 parent f226a06 commit c53314f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/granted/rds/rds.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ var proxyCommand = cli.Command{
return err
}

// check here to avoid nil pointer errors later
if len(entitlements) == 0 {
return errors.New("You don't have access to any RDS databases")
}

type Column struct {
Title string
Width int
Expand Down Expand Up @@ -139,7 +144,13 @@ var proxyCommand = cli.Command{
return err
}

entitlement := selector.GetValue().(*accessv1alpha1.Entitlement)
selectorVal := selector.GetValue()

if selectorVal == nil {
return errors.New("No database selected")
}

entitlement := selectorVal.(*accessv1alpha1.Entitlement)

target = entitlement.Target.Eid.Display()
role = entitlement.Role.Eid.Display()
Expand Down

0 comments on commit c53314f

Please sign in to comment.