Skip to content

Commit

Permalink
add panics
Browse files Browse the repository at this point in the history
  • Loading branch information
weikanglim committed Nov 7, 2024
1 parent e7ffa92 commit ac10b48
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cli/azd/pkg/account/subscriptions_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (m *SubscriptionsManager) LookupTenant(ctx context.Context, subscriptionId
func (m *SubscriptionsManager) GetSubscriptions(ctx context.Context) ([]Subscription, error) {
res, err := m.getSubscriptions(ctx)
if err != nil {
return nil, err
log.Panicf("getSubscriptions: %v", err)
}

return res.subscriptions, nil
Expand Down Expand Up @@ -181,15 +181,21 @@ func (m *SubscriptionsManager) getSubscriptions(ctx context.Context) (getSubscri
func (m *SubscriptionsManager) GetSubscription(ctx context.Context, subscriptionId string) (*Subscription, error) {
subscriptions, err := m.GetSubscriptions(ctx)
if err != nil {
return nil, err
log.Panicf("getSubscriptions: %v", err)
}

for _, sub := range subscriptions {
if sub.Id == subscriptionId {
return &sub, nil
}
}
return m.getSubscription(ctx, subscriptionId)

sub, err := m.getSubscription(ctx, subscriptionId)
if err != nil {
log.Panicf("getSubscription: %v", err)
}

return sub, nil
}

type tenantSubsResult struct {
Expand Down

0 comments on commit ac10b48

Please sign in to comment.