Skip to content

Commit

Permalink
Refactor to new actions. (#69)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Jan 16, 2025
1 parent d0011f7 commit 1d142ab
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 175 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FIRST_GOPATH:=$(firstword $(subst :, ,$(GOPATH)))

# Build available information.
GIT_HASH:=$(shell git log --format="%h" -n 1 2> /dev/null)
GIT_BRANCH:=$(shell git branch 2> /dev/null | grep '*' | cut -f2 -d' ')
GIT_BRANCH:=$(shell git rev-parse --abbrev-ref HEAD)
APP_VERSION:="$(GIT_BRANCH)-$(GIT_HASH)"
# LAUNCHRPKG is used to set launchr version.
LAUNCHRPKG:=github.com/launchrctl/launchr
Expand Down
32 changes: 32 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
runtime: plugin
action:
title: Bump
description: "Bump or sync versions of updated components"
options:
- name: sync
shorthand: s
title: Sync
description: Propagate versions of updated components to their dependencies
type: boolean
default: false
- name: dry-run
title: Dry-run
description: Simulate bump or sync without updating any file
type: boolean
default: false
- name: allow-override
title: Allow override
description: Allow override committed version by current build value
type: boolean
default: false
- name: vault-pass
title: Vault password
description: Password for Ansible Vault
type: string
default: ""
- name: last
shorthand: l
title: Last
description: Bump resources modified in last commit only
type: boolean
default: false
1 change: 1 addition & 0 deletions actionBump.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"path/filepath"

"github.com/launchrctl/launchr"

"github.com/skilld-labs/plasmactl-bump/v2/pkg/repository"
"github.com/skilld-labs/plasmactl-bump/v2/pkg/sync"
)
Expand Down
12 changes: 6 additions & 6 deletions actionSync.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ type SyncAction struct {
// options.
dryRun bool
allowOverride bool
showProgress bool
vaultPass string
verbosity int
}

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

var p *pterm.ProgressbarPrinter
var err error
if s.verbosity < 1 {
if s.showProgress {
p, err = pterm.DefaultProgressbar.WithTotal(resources[name].Len()).WithWriter(multi.NewWriter()).Start(fmt.Sprintf("Collecting resources from %s", name))
if err != nil {
return err
Expand All @@ -377,7 +377,7 @@ func (s *SyncAction) populateTimelineResources(resources map[string]*sync.Ordere
}
close(workChan)
go func() {
if s.verbosity < 1 {
if s.showProgress {
_, err := multi.Start()
if err != nil {
errorChan <- fmt.Errorf("error starting multi progress bar: %w", err)
Expand All @@ -395,7 +395,7 @@ func (s *SyncAction) populateTimelineResources(resources map[string]*sync.Ordere
}

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

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

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

var p *pterm.ProgressbarPrinter
if s.verbosity < 1 {
if s.showProgress {
p, _ = pterm.DefaultProgressbar.WithTotal(len(sortList)).WithTitle("Updating resources").Start()
}
for _, key := range sortList {
Expand Down
67 changes: 35 additions & 32 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ go 1.23.2

require (
github.com/cespare/xxhash/v2 v2.3.0
github.com/go-git/go-git/v5 v5.12.0
github.com/launchrctl/compose v0.11.0
github.com/launchrctl/keyring v0.2.5
github.com/launchrctl/launchr v0.16.4
github.com/pterm/pterm v0.12.79
github.com/go-git/go-git/v5 v5.13.1
github.com/launchrctl/compose v0.14.0
github.com/launchrctl/keyring v0.3.0
github.com/launchrctl/launchr v0.17.1
github.com/pterm/pterm v0.12.80
github.com/sosedoff/ansible-vault-go v0.2.0
github.com/spf13/cobra v1.8.1
github.com/stevenle/topsort v0.2.0
)

Expand All @@ -19,26 +18,26 @@ require (
atomicgo.dev/keyboard v0.2.9 // indirect
atomicgo.dev/schedule v0.1.0 // indirect
dario.cat/mergo v1.0.1 // indirect
filippo.io/age v1.2.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
filippo.io/age v1.2.1 // indirect
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/ProtonMail/go-crypto v1.0.0 // indirect
github.com/ProtonMail/go-crypto v1.1.5 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/catppuccin/go v0.2.0 // indirect
github.com/charmbracelet/bubbles v0.20.0 // indirect
github.com/charmbracelet/bubbletea v1.1.1 // indirect
github.com/charmbracelet/bubbletea v1.2.4 // indirect
github.com/charmbracelet/huh v0.6.0 // indirect
github.com/charmbracelet/lipgloss v0.13.1 // indirect
github.com/charmbracelet/x/ansi v0.3.2 // indirect
github.com/charmbracelet/x/exp/strings v0.0.0-20241022174419-46d9bb99a691 // indirect
github.com/charmbracelet/x/term v0.2.0 // indirect
github.com/charmbracelet/lipgloss v1.0.0 // indirect
github.com/charmbracelet/x/ansi v0.7.0 // indirect
github.com/charmbracelet/x/exp/strings v0.0.0-20250116134054-e10c5c25afb9 // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/cloudflare/circl v1.5.0 // indirect
github.com/containerd/console v1.0.4 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/cyphar/filepath-securejoin v0.3.4 // indirect
github.com/cyphar/filepath-securejoin v0.4.0 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/docker v27.3.1+incompatible // indirect
github.com/docker/docker v27.5.0+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
Expand All @@ -47,11 +46,11 @@ require (
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.6.0 // indirect
github.com/go-git/go-billy/v5 v5.6.2 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/gookit/color v1.5.4 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
Expand All @@ -67,43 +66,47 @@ require (
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/mmcloughlin/avo v0.6.0 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/sequential v0.6.0 // indirect
github.com/moby/sys/signal v0.7.1 // indirect
github.com/moby/sys/user v0.3.0 // indirect
github.com/moby/sys/userns v0.1.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/moby/term v0.5.2 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pjbgf/sha1cd v0.3.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/skeema/knownhosts v1.3.0 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 // indirect
go.opentelemetry.io/otel v1.31.0 // indirect
go.opentelemetry.io/otel/metric v1.31.0 // indirect
go.opentelemetry.io/otel/trace v1.31.0 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0 // indirect
go.opentelemetry.io/otel v1.33.0 // indirect
go.opentelemetry.io/otel/metric v1.33.0 // indirect
go.opentelemetry.io/otel/trace v1.33.0 // indirect
go.uber.org/mock v0.5.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/term v0.25.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/term v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
golang.org/x/tools v0.29.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
Expand Down
Loading

0 comments on commit 1d142ab

Please sign in to comment.