Skip to content

Commit 9fa97ef

Browse files
Idiomatic resource naming for asoctl (#4487)
* Add conc library * Create importFactory and test * Consume factory * Move naming to the factory * Add createUniqueKubernetesName and consume * Format code * Avoid deadlock when panic occurs during import * Avoid closing the chan early * Remove use of github.com/pkg/errors * go mod tidy * Fix specifier
1 parent 32fe311 commit 9fa97ef

File tree

9 files changed

+440
-348
lines changed

9 files changed

+440
-348
lines changed

v2/cmd/asoctl/cmd/import_azure_resource.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package cmd
77

88
import (
99
"context"
10+
"fmt"
1011
"io"
1112
"os"
1213
"sync"
@@ -169,8 +170,15 @@ func importAzureResource(
169170

170171
output = bar
171172

172-
// Ensure the progress bar is closed when we're done
173-
defer bar.Wait()
173+
// Ensure the progress bar is closed when we're done, but skip if a panic has happened
174+
defer func() {
175+
if p := recover(); p != nil {
176+
os.Stderr.Write([]byte(fmt.Sprintf("panic: %s\n", p)))
177+
} else {
178+
// No panic
179+
defer bar.Wait()
180+
}
181+
}()
174182
}
175183

176184
importerOptions := importresources.ResourceImporterOptions{

v2/cmd/asoctl/go.mod

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -51,25 +51,16 @@ require (
5151
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.6.0 // indirect
5252
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/subscription/armsubscription v1.2.0 // indirect
5353
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect
54-
github.com/NYTimes/gziphandler v1.1.1 // indirect
5554
github.com/VividCortex/ewma v1.2.0 // indirect
5655
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
5756
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
58-
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
5957
github.com/benbjohnson/clock v1.3.5 // indirect
6058
github.com/beorn7/perks v1.0.1 // indirect
61-
github.com/blang/semver/v4 v4.0.0 // indirect
62-
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
6359
github.com/cespare/xxhash/v2 v2.3.0 // indirect
64-
github.com/coreos/go-semver v0.3.1 // indirect
65-
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
6660
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
6761
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
6862
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
69-
github.com/felixge/httpsnoop v1.0.4 // indirect
70-
github.com/fsnotify/fsnotify v1.7.0 // indirect
7163
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
72-
github.com/go-logr/stdr v1.2.2 // indirect
7364
github.com/go-openapi/jsonpointer v0.21.0 // indirect
7465
github.com/go-openapi/jsonreference v0.21.0 // indirect
7566
github.com/go-openapi/swag v0.23.0 // indirect
@@ -85,9 +76,6 @@ require (
8576
github.com/google/go-cmp v0.6.0 // indirect
8677
github.com/google/gofuzz v1.2.0 // indirect
8778
github.com/google/uuid v1.6.0 // indirect
88-
github.com/gorilla/websocket v1.5.0 // indirect
89-
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
90-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
9179
github.com/hbollon/go-edlib v1.6.0 // indirect
9280
github.com/imdario/mergo v0.3.16 // indirect
9381
github.com/inconshreveable/mousetrap v1.1.0 // indirect
@@ -105,11 +93,9 @@ require (
10593
github.com/mattn/go-isatty v0.0.20 // indirect
10694
github.com/mattn/go-runewidth v0.0.16 // indirect
10795
github.com/microsoft/go-mssqldb v1.8.0 // indirect
108-
github.com/moby/spdystream v0.4.0 // indirect
10996
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
11097
github.com/modern-go/reflect2 v1.0.2 // indirect
11198
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
112-
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
11399
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
114100
github.com/pkg/errors v0.9.1 // indirect
115101
github.com/prometheus/client_golang v1.20.5 // indirect
@@ -121,20 +107,6 @@ require (
121107
github.com/spf13/pflag v1.0.5 // indirect
122108
github.com/stoewer/go-strcase v1.3.0 // indirect
123109
github.com/x448/float16 v0.8.4 // indirect
124-
go.etcd.io/etcd/api/v3 v3.5.14 // indirect
125-
go.etcd.io/etcd/client/pkg/v3 v3.5.14 // indirect
126-
go.etcd.io/etcd/client/v3 v3.5.14 // indirect
127-
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.53.0 // indirect
128-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
129-
go.opentelemetry.io/otel v1.29.0 // indirect
130-
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.29.0 // indirect
131-
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.29.0 // indirect
132-
go.opentelemetry.io/otel/metric v1.29.0 // indirect
133-
go.opentelemetry.io/otel/sdk v1.29.0 // indirect
134-
go.opentelemetry.io/otel/trace v1.29.0 // indirect
135-
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
136-
go.uber.org/multierr v1.11.0 // indirect
137-
go.uber.org/zap v1.27.0 // indirect
138110
golang.org/x/crypto v0.30.0 // indirect
139111
golang.org/x/net v0.32.0 // indirect
140112
golang.org/x/oauth2 v0.22.0 // indirect
@@ -146,20 +118,14 @@ require (
146118
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
147119
google.golang.org/genproto/googleapis/api v0.0.0-20240827150818-7e3bb234dfed // indirect
148120
google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed // indirect
149-
google.golang.org/grpc v1.65.0 // indirect
150121
google.golang.org/protobuf v1.35.1 // indirect
151122
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
152123
gopkg.in/inf.v0 v0.9.1 // indirect
153-
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
154124
gopkg.in/yaml.v2 v2.4.0 // indirect
155125
gopkg.in/yaml.v3 v3.0.1 // indirect
156-
k8s.io/apiserver v0.31.3 // indirect
157-
k8s.io/component-base v0.31.3 // indirect
158126
k8s.io/klog/v2 v2.130.1 // indirect
159-
k8s.io/kms v0.31.3 // indirect
160127
k8s.io/kube-openapi v0.0.0-20240827152857-f7e401e7b4c2 // indirect
161128
k8s.io/utils v0.0.0-20240821151609-f90d01438635 // indirect
162-
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3 // indirect
163129
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
164130
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
165131
)

0 commit comments

Comments
 (0)