Skip to content

Commit c677373

Browse files
authored
Streamline and improve JSON UI (#612)
Next step I will move the step output definition into the shared lib, so we can use it server-side for parsing.
1 parent 79626da commit c677373

File tree

7 files changed

+182
-196
lines changed

7 files changed

+182
-196
lines changed

cmd/src/batch_common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ func executeBatchSpec(ctx context.Context, opts executeBatchSpecOpts) (err error
337337
opts.ui.UploadingChangesetSpecsProgress(i+1, len(specs))
338338
}
339339

340-
opts.ui.UploadingChangesetSpecsSuccess()
340+
opts.ui.UploadingChangesetSpecsSuccess(ids)
341341
} else if len(repos) == 0 {
342342
opts.ui.NoChangesetSpecs()
343343
}

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ require (
77
github.com/cockroachdb/errors v1.8.6
88
github.com/cockroachdb/redact v1.1.3 // indirect
99
github.com/derision-test/glock v0.0.0-20210316032053-f5b74334bb29
10+
github.com/dineshappavoo/basex v0.0.0-20170425072625-481a6f6dc663
1011
github.com/dustin/go-humanize v1.0.0
1112
github.com/gobwas/glob v0.2.3
1213
github.com/google/go-cmp v0.5.6

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ github.com/derision-test/go-mockgen v1.1.2/go.mod h1:9H3VGTWYnL1VJoHHCuPKDpPFmNQ
4949
github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4=
5050
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
5151
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
52+
github.com/dineshappavoo/basex v0.0.0-20170425072625-481a6f6dc663 h1:fctNkSsavbXpt8geFWZb8n+noCqS8MrOXRJ/YfdZ2dQ=
53+
github.com/dineshappavoo/basex v0.0.0-20170425072625-481a6f6dc663/go.mod h1:Kad2hux31v/IyD4Rf4wAwIyK48995rs3qAl9IUAhc2k=
5254
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
5355
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
5456
github.com/efritz/pentimento v0.0.0-20190429011147-ade47d831101/go.mod h1:5ALWO82UZwfAtNRUtwzsWimcrcuYzyieTyyXOXrP6EQ=

internal/batches/service/service.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ func (svc *Service) CreateChangesetSpec(ctx context.Context, spec *batcheslib.Ch
152152
//
153153
// Progress information is reported back to the given progress function: perc
154154
// will be a value between 0.0 and 1.0, inclusive.
155-
func (svc *Service) EnsureDockerImages(ctx context.Context, spec *batcheslib.BatchSpec, progress func(perc float64)) (map[string]docker.Image, error) {
156-
total := len(spec.Steps) + 1
157-
progress(0)
155+
func (svc *Service) EnsureDockerImages(ctx context.Context, spec *batcheslib.BatchSpec, progress func(done, total int)) (map[string]docker.Image, error) {
156+
total := len(spec.Steps)
157+
progress(0, total)
158158

159159
// TODO: this _really_ should be parallelised, since the image cache takes
160160
// care to only pull the same image once.
@@ -166,10 +166,9 @@ func (svc *Service) EnsureDockerImages(ctx context.Context, spec *batcheslib.Bat
166166
}
167167
images[spec.Steps[i].Container] = img
168168

169-
progress(float64(i) / float64(total))
169+
progress(i+1, total)
170170
}
171171

172-
progress(1)
173172
return images, nil
174173
}
175174

internal/batches/ui/exec_ui.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type ExecUI interface {
1616
ResolvingNamespaceSuccess(namespace string)
1717

1818
PreparingContainerImages()
19-
PreparingContainerImagesProgress(percent float64)
19+
PreparingContainerImagesProgress(done, total int)
2020
PreparingContainerImagesSuccess()
2121

2222
DeterminingWorkspaceCreatorType()
@@ -39,7 +39,7 @@ type ExecUI interface {
3939
NoChangesetSpecs()
4040
UploadingChangesetSpecs(num int)
4141
UploadingChangesetSpecsProgress(done, total int)
42-
UploadingChangesetSpecsSuccess()
42+
UploadingChangesetSpecsSuccess(ids []graphql.ChangesetSpecID)
4343

4444
CreatingBatchSpec()
4545
CreatingBatchSpecSuccess()

0 commit comments

Comments
 (0)