Skip to content

Commit 02f40d4

Browse files
committed
chore: CmdImpl only open panicChan if its going to get used
1 parent 96518b3 commit 02f40d4

4 files changed

+10
-8
lines changed

cmd/list-container-registries.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var listContainerRegistriesCmd = &cobra.Command{
4545

4646
func listContainerRegistriesCmdImpl(cmd *cobra.Command, args []string) {
4747
ctx, stop := signal.NotifyContext(cmd.Context(), os.Interrupt, os.Kill)
48-
panicChan := panicChan()
48+
4949
defer gracefulShutdown(stop)
5050

5151
log.V(1).Info("testing connections")
@@ -56,13 +56,14 @@ func listContainerRegistriesCmdImpl(cmd *cobra.Command, args []string) {
5656
} else {
5757
log.Info("collecting azure container registries...")
5858
start := time.Now()
59+
panicChan := panicChan()
5960
stream := listContainerRegistries(ctx, azClient, panicChan, listSubscriptions(ctx, azClient, panicChan))
61+
handleBubbledPanic(ctx, panicChan, stop)
6062
outputStream(ctx, stream)
6163
duration := time.Since(start)
6264
log.Info("collection completed", "duration", duration.String())
6365
}
6466

65-
handleBubbledPanic(ctx, panicChan, stop)
6667
}
6768

6869
func listContainerRegistries(ctx context.Context, client client.AzureClient, panicChan chan error, subscriptions <-chan interface{}) <-chan interface{} {

cmd/list-logic-apps.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var listLogicAppsCmd = &cobra.Command{
4545

4646
func listLogicAppsCmdImpl(cmd *cobra.Command, args []string) {
4747
ctx, stop := signal.NotifyContext(cmd.Context(), os.Interrupt, os.Kill)
48-
panicChan := panicChan()
48+
4949
defer gracefulShutdown(stop)
5050

5151
log.V(1).Info("testing connections")
@@ -56,13 +56,14 @@ func listLogicAppsCmdImpl(cmd *cobra.Command, args []string) {
5656
} else {
5757
log.Info("collecting azure logic apps...")
5858
start := time.Now()
59+
panicChan := panicChan()
5960
stream := listLogicApps(ctx, azClient, panicChan, listSubscriptions(ctx, azClient, panicChan))
61+
handleBubbledPanic(ctx, panicChan, stop)
6062
outputStream(ctx, stream)
6163
duration := time.Since(start)
6264
log.Info("collection completed", "duration", duration.String())
6365
}
6466

65-
handleBubbledPanic(ctx, panicChan, stop)
6667
}
6768

6869
func listLogicApps(ctx context.Context, client client.AzureClient, panicChan chan error, subscriptions <-chan interface{}) <-chan interface{} {

cmd/list-managed-clusters.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ var listManagedClustersCmd = &cobra.Command{
4545

4646
func listManagedClustersCmdImpl(cmd *cobra.Command, args []string) {
4747
ctx, stop := signal.NotifyContext(cmd.Context(), os.Interrupt, os.Kill)
48-
panicChan := panicChan()
4948
defer gracefulShutdown(stop)
5049

5150
log.V(1).Info("testing connections")
@@ -56,13 +55,14 @@ func listManagedClustersCmdImpl(cmd *cobra.Command, args []string) {
5655
} else {
5756
log.Info("collecting azure managed clusters...")
5857
start := time.Now()
58+
panicChan := panicChan()
5959
stream := listManagedClusters(ctx, azClient, panicChan, listSubscriptions(ctx, azClient, panicChan))
60+
handleBubbledPanic(ctx, panicChan, stop)
6061
outputStream(ctx, stream)
6162
duration := time.Since(start)
6263
log.Info("collection completed", "duration", duration.String())
6364
}
6465

65-
handleBubbledPanic(ctx, panicChan, stop)
6666
}
6767

6868
func listManagedClusters(ctx context.Context, client client.AzureClient, panicChan chan error, subscriptions <-chan interface{}) <-chan interface{} {

cmd/list-vm-scale-sets.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ var listVMScaleSetsCmd = &cobra.Command{
4545

4646
func listVMScaleSetsCmdImpl(cmd *cobra.Command, args []string) {
4747
ctx, stop := signal.NotifyContext(cmd.Context(), os.Interrupt, os.Kill)
48-
panicChan := panicChan()
4948
defer gracefulShutdown(stop)
5049

5150
log.V(1).Info("testing connections")
@@ -56,13 +55,14 @@ func listVMScaleSetsCmdImpl(cmd *cobra.Command, args []string) {
5655
} else {
5756
log.Info("collecting azure virtual machine scale sets...")
5857
start := time.Now()
58+
panicChan := panicChan()
5959
stream := listVMScaleSets(ctx, azClient, panicChan, listSubscriptions(ctx, azClient, panicChan))
60+
handleBubbledPanic(ctx, panicChan, stop)
6061
outputStream(ctx, stream)
6162
duration := time.Since(start)
6263
log.Info("collection completed", "duration", duration.String())
6364
}
6465

65-
handleBubbledPanic(ctx, panicChan, stop)
6666
}
6767

6868
func listVMScaleSets(ctx context.Context, client client.AzureClient, panicChan chan error, subscriptions <-chan interface{}) <-chan interface{} {

0 commit comments

Comments
 (0)