Skip to content

Commit 1d142ab

Browse files
lexbritvindavidferlayiignatevich
authored
Refactor to new actions. (#69)
* Refactor to new actions. * show progress-bar if log level is zero --------- Co-authored-by: David Ferlay <[email protected]> Co-authored-by: Igor Ignatyev <[email protected]>
1 parent d0011f7 commit 1d142ab

File tree

7 files changed

+205
-175
lines changed

7 files changed

+205
-175
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FIRST_GOPATH:=$(firstword $(subst :, ,$(GOPATH)))
33

44
# Build available information.
55
GIT_HASH:=$(shell git log --format="%h" -n 1 2> /dev/null)
6-
GIT_BRANCH:=$(shell git branch 2> /dev/null | grep '*' | cut -f2 -d' ')
6+
GIT_BRANCH:=$(shell git rev-parse --abbrev-ref HEAD)
77
APP_VERSION:="$(GIT_BRANCH)-$(GIT_HASH)"
88
# LAUNCHRPKG is used to set launchr version.
99
LAUNCHRPKG:=github.com/launchrctl/launchr

action.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
runtime: plugin
2+
action:
3+
title: Bump
4+
description: "Bump or sync versions of updated components"
5+
options:
6+
- name: sync
7+
shorthand: s
8+
title: Sync
9+
description: Propagate versions of updated components to their dependencies
10+
type: boolean
11+
default: false
12+
- name: dry-run
13+
title: Dry-run
14+
description: Simulate bump or sync without updating any file
15+
type: boolean
16+
default: false
17+
- name: allow-override
18+
title: Allow override
19+
description: Allow override committed version by current build value
20+
type: boolean
21+
default: false
22+
- name: vault-pass
23+
title: Vault password
24+
description: Password for Ansible Vault
25+
type: string
26+
default: ""
27+
- name: last
28+
shorthand: l
29+
title: Last
30+
description: Bump resources modified in last commit only
31+
type: boolean
32+
default: false

actionBump.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"path/filepath"
55

66
"github.com/launchrctl/launchr"
7+
78
"github.com/skilld-labs/plasmactl-bump/v2/pkg/repository"
89
"github.com/skilld-labs/plasmactl-bump/v2/pkg/sync"
910
)

actionSync.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ type SyncAction struct {
5555
// options.
5656
dryRun bool
5757
allowOverride bool
58+
showProgress bool
5859
vaultPass string
59-
verbosity int
6060
}
6161

6262
type hashStruct struct {
@@ -366,7 +366,7 @@ func (s *SyncAction) populateTimelineResources(resources map[string]*sync.Ordere
366366

367367
var p *pterm.ProgressbarPrinter
368368
var err error
369-
if s.verbosity < 1 {
369+
if s.showProgress {
370370
p, err = pterm.DefaultProgressbar.WithTotal(resources[name].Len()).WithWriter(multi.NewWriter()).Start(fmt.Sprintf("Collecting resources from %s", name))
371371
if err != nil {
372372
return err
@@ -377,7 +377,7 @@ func (s *SyncAction) populateTimelineResources(resources map[string]*sync.Ordere
377377
}
378378
close(workChan)
379379
go func() {
380-
if s.verbosity < 1 {
380+
if s.showProgress {
381381
_, err := multi.Start()
382382
if err != nil {
383383
errorChan <- fmt.Errorf("error starting multi progress bar: %w", err)
@@ -395,7 +395,7 @@ func (s *SyncAction) populateTimelineResources(resources map[string]*sync.Ordere
395395
}
396396

397397
// Sleep to re-render progress bar. Needed to achieve latest state.
398-
if s.verbosity < 1 {
398+
if s.showProgress {
399399
time.Sleep(multi.UpdateDelay)
400400
multi.Stop() //nolint
401401
}
@@ -616,7 +616,7 @@ func (s *SyncAction) populateTimelineVars() error {
616616
errorChan := make(chan error, 1)
617617

618618
var p *pterm.ProgressbarPrinter
619-
if s.verbosity < 1 {
619+
if s.showProgress {
620620
p, _ = pterm.DefaultProgressbar.WithTotal(len(varsFiles)).WithTitle("Processing variables files").Start()
621621
}
622622

@@ -980,7 +980,7 @@ func (s *SyncAction) updateResources(resourceVersionMap map[string]string, toPro
980980
launchr.Log().Info("Propagating versions")
981981

982982
var p *pterm.ProgressbarPrinter
983-
if s.verbosity < 1 {
983+
if s.showProgress {
984984
p, _ = pterm.DefaultProgressbar.WithTotal(len(sortList)).WithTitle("Updating resources").Start()
985985
}
986986
for _, key := range sortList {

go.mod

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ go 1.23.2
44

55
require (
66
github.com/cespare/xxhash/v2 v2.3.0
7-
github.com/go-git/go-git/v5 v5.12.0
8-
github.com/launchrctl/compose v0.11.0
9-
github.com/launchrctl/keyring v0.2.5
10-
github.com/launchrctl/launchr v0.16.4
11-
github.com/pterm/pterm v0.12.79
7+
github.com/go-git/go-git/v5 v5.13.1
8+
github.com/launchrctl/compose v0.14.0
9+
github.com/launchrctl/keyring v0.3.0
10+
github.com/launchrctl/launchr v0.17.1
11+
github.com/pterm/pterm v0.12.80
1212
github.com/sosedoff/ansible-vault-go v0.2.0
13-
github.com/spf13/cobra v1.8.1
1413
github.com/stevenle/topsort v0.2.0
1514
)
1615

@@ -19,26 +18,26 @@ require (
1918
atomicgo.dev/keyboard v0.2.9 // indirect
2019
atomicgo.dev/schedule v0.1.0 // indirect
2120
dario.cat/mergo v1.0.1 // indirect
22-
filippo.io/age v1.2.0 // indirect
23-
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
21+
filippo.io/age v1.2.1 // indirect
22+
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
2423
github.com/Microsoft/go-winio v0.6.2 // indirect
25-
github.com/ProtonMail/go-crypto v1.0.0 // indirect
24+
github.com/ProtonMail/go-crypto v1.1.5 // indirect
2625
github.com/atotto/clipboard v0.1.4 // indirect
2726
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
2827
github.com/catppuccin/go v0.2.0 // indirect
2928
github.com/charmbracelet/bubbles v0.20.0 // indirect
30-
github.com/charmbracelet/bubbletea v1.1.1 // indirect
29+
github.com/charmbracelet/bubbletea v1.2.4 // indirect
3130
github.com/charmbracelet/huh v0.6.0 // indirect
32-
github.com/charmbracelet/lipgloss v0.13.1 // indirect
33-
github.com/charmbracelet/x/ansi v0.3.2 // indirect
34-
github.com/charmbracelet/x/exp/strings v0.0.0-20241022174419-46d9bb99a691 // indirect
35-
github.com/charmbracelet/x/term v0.2.0 // indirect
31+
github.com/charmbracelet/lipgloss v1.0.0 // indirect
32+
github.com/charmbracelet/x/ansi v0.7.0 // indirect
33+
github.com/charmbracelet/x/exp/strings v0.0.0-20250116134054-e10c5c25afb9 // indirect
34+
github.com/charmbracelet/x/term v0.2.1 // indirect
3635
github.com/cloudflare/circl v1.5.0 // indirect
3736
github.com/containerd/console v1.0.4 // indirect
3837
github.com/containerd/log v0.1.0 // indirect
39-
github.com/cyphar/filepath-securejoin v0.3.4 // indirect
38+
github.com/cyphar/filepath-securejoin v0.4.0 // indirect
4039
github.com/distribution/reference v0.6.0 // indirect
41-
github.com/docker/docker v27.3.1+incompatible // indirect
40+
github.com/docker/docker v27.5.0+incompatible // indirect
4241
github.com/docker/go-connections v0.5.0 // indirect
4342
github.com/docker/go-units v0.5.0 // indirect
4443
github.com/dustin/go-humanize v1.0.1 // indirect
@@ -47,11 +46,11 @@ require (
4746
github.com/felixge/httpsnoop v1.0.4 // indirect
4847
github.com/fsnotify/fsnotify v1.6.0 // indirect
4948
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
50-
github.com/go-git/go-billy/v5 v5.6.0 // indirect
49+
github.com/go-git/go-billy/v5 v5.6.2 // indirect
5150
github.com/go-logr/logr v1.4.2 // indirect
5251
github.com/go-logr/stdr v1.2.2 // indirect
5352
github.com/gogo/protobuf v1.3.2 // indirect
54-
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
53+
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
5554
github.com/gookit/color v1.5.4 // indirect
5655
github.com/inconshreveable/mousetrap v1.1.0 // indirect
5756
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
@@ -67,43 +66,47 @@ require (
6766
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
6867
github.com/mitchellh/mapstructure v1.5.0 // indirect
6968
github.com/mitchellh/reflectwalk v1.0.2 // indirect
69+
github.com/mmcloughlin/avo v0.6.0 // indirect
7070
github.com/moby/docker-image-spec v1.3.1 // indirect
7171
github.com/moby/patternmatcher v0.6.0 // indirect
7272
github.com/moby/sys/sequential v0.6.0 // indirect
7373
github.com/moby/sys/signal v0.7.1 // indirect
7474
github.com/moby/sys/user v0.3.0 // indirect
7575
github.com/moby/sys/userns v0.1.0 // indirect
76-
github.com/moby/term v0.5.0 // indirect
76+
github.com/moby/term v0.5.2 // indirect
7777
github.com/morikuni/aec v1.0.0 // indirect
7878
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
7979
github.com/muesli/cancelreader v0.2.2 // indirect
8080
github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a // indirect
8181
github.com/opencontainers/go-digest v1.0.0 // indirect
8282
github.com/opencontainers/image-spec v1.1.0 // indirect
8383
github.com/pelletier/go-toml v1.9.5 // indirect
84-
github.com/pjbgf/sha1cd v0.3.0 // indirect
84+
github.com/pjbgf/sha1cd v0.3.1 // indirect
8585
github.com/pkg/errors v0.9.1 // indirect
8686
github.com/rivo/uniseg v0.4.7 // indirect
87-
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect
87+
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 // indirect
8888
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
8989
github.com/sirupsen/logrus v1.9.3 // indirect
9090
github.com/skeema/knownhosts v1.3.0 // indirect
91+
github.com/spf13/cobra v1.8.1 // indirect
9192
github.com/spf13/pflag v1.0.5 // indirect
9293
github.com/xanzy/ssh-agent v0.3.3 // indirect
9394
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
94-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 // indirect
95-
go.opentelemetry.io/otel v1.31.0 // indirect
96-
go.opentelemetry.io/otel/metric v1.31.0 // indirect
97-
go.opentelemetry.io/otel/trace v1.31.0 // indirect
95+
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
96+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0 // indirect
97+
go.opentelemetry.io/otel v1.33.0 // indirect
98+
go.opentelemetry.io/otel/metric v1.33.0 // indirect
99+
go.opentelemetry.io/otel/trace v1.33.0 // indirect
98100
go.uber.org/mock v0.5.0 // indirect
99-
golang.org/x/crypto v0.28.0 // indirect
100-
golang.org/x/mod v0.21.0 // indirect
101-
golang.org/x/net v0.30.0 // indirect
102-
golang.org/x/sync v0.8.0 // indirect
103-
golang.org/x/sys v0.26.0 // indirect
104-
golang.org/x/term v0.25.0 // indirect
105-
golang.org/x/text v0.19.0 // indirect
101+
golang.org/x/crypto v0.32.0 // indirect
102+
golang.org/x/mod v0.22.0 // indirect
103+
golang.org/x/net v0.34.0 // indirect
104+
golang.org/x/sync v0.10.0 // indirect
105+
golang.org/x/sys v0.29.0 // indirect
106+
golang.org/x/term v0.28.0 // indirect
107+
golang.org/x/text v0.21.0 // indirect
106108
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
109+
golang.org/x/tools v0.29.0 // indirect
107110
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9 // indirect
108111
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 // indirect
109112
gopkg.in/warnings.v0 v0.1.2 // indirect

0 commit comments

Comments
 (0)