Skip to content

Commit

Permalink
Remove existing support for progress bar.
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilsbhat committed Jun 13, 2023
1 parent 53d1185 commit 38a41fc
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 33 deletions.
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.19

require (
github.com/olekukonko/tablewriter v0.0.5
github.com/schollz/progressbar/v3 v3.13.1
github.com/sirupsen/logrus v1.9.0
github.com/spf13/cobra v1.6.1
github.com/stretchr/testify v1.8.2
Expand Down Expand Up @@ -75,7 +74,6 @@ require (
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
Expand Down
5 changes: 0 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,6 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1e29fT/6vq2aBdFsgNPmy8qMdSay1npru+Sw=
github.com/karrick/godirwalk v1.16.1 h1:DynhcF+bztK8gooS0+NDJFrdNZjJ3gzVzC545UNA9iw=
github.com/karrick/godirwalk v1.16.1/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
Expand Down Expand Up @@ -431,8 +430,6 @@ github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfr
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4=
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ=
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw=
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
Expand Down Expand Up @@ -551,8 +548,6 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/schollz/progressbar/v3 v3.13.1 h1:o8rySDYiQ59Mwzy2FELeHY5ZARXZTVJC7iHD6PEFUiE=
github.com/schollz/progressbar/v3 v3.13.1/go.mod h1:xvrbki8kfT1fzWzBT/UZd9L6GA+jdL7HAgq2RFnO6fQ=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
Expand Down
19 changes: 11 additions & 8 deletions pkg/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/nikhilsbhat/helm-drift/pkg/deviation"
"github.com/nikhilsbhat/helm-drift/pkg/errors"
log "github.com/sirupsen/logrus"
)

const (
Expand All @@ -19,8 +20,6 @@ func (drift *Drift) renderToDisk(manifests []string, chartName, releaseName, rel
manifests = NewHelmTemplates(manifests).FilterByKind(drift)
manifests = NewHelmTemplates(manifests).FilterByName(drift)

diskProgressBar := NewProgress(len(manifests), "rendering manifests to disk")

releaseDrifted := deviation.DriftedRelease{
Namespace: releaseNamespace.(string),
Release: releaseName.(string),
Expand All @@ -36,25 +35,29 @@ func (drift *Drift) renderToDisk(manifests []string, chartName, releaseName, rel
drift.log.Debugf("creating directories '%s' to generate manifests", templatePath)

if err := os.MkdirAll(templatePath, templatePathPermission); err != nil {
log.Errorf("creating template path '%s' errored with '%v'", templatePath, err)

return releaseDrifted, err
}

templates := make([]deviation.Deviation, 0)

for _, manifest := range manifests {
if err := diskProgressBar.Add(1); err != nil {
return deviation.DriftedRelease{}, err
}
drift.log.Debugf("rendering manifest to disc, hold on for a moment....")

template, err := NewHelmTemplate(manifest).Get()
if err != nil {
log.Errorf("getting manifest information from template errored with '%v'", err)

return deviation.DriftedRelease{}, err
}

drift.log.Debugf("generating manifest '%s'", template.Resource)

manifestPath := filepath.Join(templatePath, fmt.Sprintf("%s.%s.%s.yaml", template.Resource, template.Kind, releaseName))
if err = os.WriteFile(manifestPath, []byte(manifest), manifestFilePermission); err != nil {
log.Errorf("writting manifest '%s' to disk errored with '%v'", manifestPath, err)

return deviation.DriftedRelease{}, err
}

Expand All @@ -74,6 +77,8 @@ func (drift *Drift) renderToDisk(manifests []string, chartName, releaseName, rel
if len(templates) != len(manifests) {
resourceFromManifests, err := NewHelmTemplates(manifests).Get()
if err != nil {
log.Errorf("getting manifests information from templates errored with '%v'", err)

return deviation.DriftedRelease{}, err
}

Expand All @@ -82,9 +87,7 @@ func (drift *Drift) renderToDisk(manifests []string, chartName, releaseName, rel

releaseDrifted.Deviations = templates

if err := diskProgressBar.Finish(); err != nil {
return deviation.DriftedRelease{}, err
}
drift.log.Debugf("all manifests from release '%s' was successfully rendered to disk...", releaseName.(string))

return releaseDrifted, nil
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/from_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ func (drift *Drift) getChartFromRelease() ([]byte, error) {

helmRelease, err := client.Run(drift.release)
if err != nil {
drift.log.Errorf("fetching helm release '%s' errored with '%v'", drift.release, err)

return nil, err
}

Expand Down
18 changes: 0 additions & 18 deletions pkg/progress.go

This file was deleted.

0 comments on commit 38a41fc

Please sign in to comment.