Skip to content

Commit

Permalink
Merge pull request #601 from helmwave/release/0.27.0
Browse files Browse the repository at this point in the history
Release 0.27.0
  • Loading branch information
zhilyaev committed Jun 7, 2023
2 parents 84a5110 + d9a3f50 commit 6cdb955
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 29 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixed-20230602-173911.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixed
body: fixed homebrew tap repo for case-sensitive systems
time: 2023-06-02T17:39:11.50444+04:00
custom:
Author: r3nic1e
Issue: ""
6 changes: 6 additions & 0 deletions .changes/unreleased/New feature-20230604-135036.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: New feature
body: Add `--skip-unchanged` flag for build command
time: 2023-06-04T13:50:36.392755+04:00
custom:
Author: rndmit
Issue: ""
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ brews:
goamd64: v1
description: "HelmWave is like docker-compose for helm"
license: "MIT"
folder: formula
folder: Formula
skip_upload: auto

custom_block: |
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ require (
go.starlark.net v0.0.0-20221020143700-22309ac47eac // indirect
go.uber.org/atomic v1.10.0 // indirect
go4.org/intern v0.0.0-20220617035311-6925f38cc365 // indirect
go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 // indirect
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 // indirect
gocloud.dev v0.27.0 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/mod v0.8.0 // indirect
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1917,8 +1917,9 @@ go4.org/intern v0.0.0-20211027215823-ae77deb06f29/go.mod h1:cS2ma+47FKrLPdXFpr7C
go4.org/intern v0.0.0-20220617035311-6925f38cc365 h1:t9hFvR102YlOqU0fQn1wgwhNvSbHGBbbJxX9JKfU3l0=
go4.org/intern v0.0.0-20220617035311-6925f38cc365/go.mod h1:WXRv3p7T6gzt0CcJm43AAKdKVZmcQbwwC7EwquU5BZU=
go4.org/unsafe/assume-no-moving-gc v0.0.0-20211027215541-db492cf91b37/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E=
go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 h1:FyBZqvoA/jbNzuAWLQE2kG820zMAkcilx6BMjGbL/E4=
go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E=
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 h1:WJhcL4p+YeDxmZWg141nRm7XC8IDmhz7lk5GpadO1Sg=
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E=
gocloud.dev v0.27.0 h1:j0WTUsnKTxCsWO7y8T+YCiBZUmLl9w/WIowqAY3yo0g=
gocloud.dev v0.27.0/go.mod h1:YlYKhYsY5/1JdHGWQDkAuqkezVKowu7qbe9aIeUF6p0=
golang.org/x/crypto v0.0.0-20171113213409-9f005a07e0d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
Expand Down
10 changes: 9 additions & 1 deletion pkg/action/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Build struct {
tags cli.StringSlice
matchAll bool
autoYml bool
skipUnchanged bool

// diffLive *DiffLive
// diffLocal *DiffLocalPlan
Expand Down Expand Up @@ -76,7 +77,7 @@ func (i *Build) Run(ctx context.Context) (err error) {
log.Warnf("I dont know what is %q diff mode. I am skiping diff.", i.diffMode)
}

err = newPlan.Export(ctx)
err = newPlan.Export(ctx, i.skipUnchanged)
if err != nil {
return err
}
Expand Down Expand Up @@ -119,6 +120,13 @@ func (i *Build) flags() []cli.Flag {
EnvVars: []string{"HELMWAVE_AUTO_YML", "HELMWAVE_AUTO_YAML"},
Destination: &i.autoYml,
},
&cli.BoolFlag{
Name: "skip-unchanged",
Usage: "Skip unchanged releases",
Value: false,
EnvVars: []string{"HELMWAVE_SKIP_UNCHANGED"},
Destination: &i.skipUnchanged,
},
}

self = append(self, i.diff.flags()...)
Expand Down
2 changes: 2 additions & 0 deletions pkg/plan/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func (p *Plan) DiffPlan(b *Plan, showSecret bool, diffWide int) {
if !change {
k++
log.Info("🆚 ❎ ", rel.Uniq(), " no changes")
p.unchanged = append(p.unchanged, rel)
}
}

Expand Down Expand Up @@ -100,6 +101,7 @@ func (p *Plan) DiffLive(ctx context.Context, showSecret bool, diffWide int, thre
if !change && !chartChange {
k++
rel.Logger().Info("🆚 ❎ no changes")
p.unchanged = append(p.unchanged, rel)
}
}
}
Expand Down
20 changes: 19 additions & 1 deletion pkg/plan/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (

"github.com/helmwave/helmwave/pkg/helper"
"github.com/helmwave/helmwave/pkg/parallel"
"github.com/helmwave/helmwave/pkg/release"
)

// Export allows save plan to file.
func (p *Plan) Export(ctx context.Context) error {
func (p *Plan) Export(ctx context.Context, skipUnchanged bool) error {
if err := os.RemoveAll(p.dir); err != nil {
return fmt.Errorf("failed to clean plan directory %s: %w", p.dir, err)
}
Expand All @@ -23,6 +24,11 @@ func (p *Plan) Export(ctx context.Context) error {
}
}(p.tmpDir)

if skipUnchanged {
p.removeUnchanged()
p.Logger().Info("removed unchanged releases from plan")
}

wg := parallel.NewWaitGroup()
wg.Add(4)

Expand Down Expand Up @@ -60,6 +66,18 @@ func (p *Plan) Export(ctx context.Context) error {
return helper.SaveInterface(ctx, p.fullPath, p.body)
}

func (p *Plan) removeUnchanged() {
filtered := p.body.Releases[:0]

for _, rel := range p.body.Releases {
if !helper.In[release.Config](rel, p.unchanged) {
filtered = append(filtered, rel)
}
}

p.body.Releases = filtered
}

func (p *Plan) exportCharts() error {
for i, rel := range p.body.Releases {
l := p.Logger().WithField("release", rel.Uniq())
Expand Down
16 changes: 7 additions & 9 deletions pkg/plan/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,15 @@ var (

// Plan contains full helmwave state.
type Plan struct {
body *planBody
dir string
fullPath string

tmpDir string
body *planBody
dir string
fullPath string
tmpDir string
graphMD string
templater string

manifests map[uniqname.UniqName]string

graphMD string

templater string
unchanged release.Configs
}

// NewAndImport wrapper for New and Import in one.
Expand Down
1 change: 1 addition & 0 deletions pkg/release/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type config struct {
DisableHooks bool `yaml:"disable_hooks,omitempty" json:"disable_hooks,omitempty" jsonschema:"default=false"`
DisableOpenAPIValidation bool `yaml:"disable_open_api_validation,omitempty" json:"disable_open_api_validation,omitempty" jsonschema:"default=false"`
dryRun bool `yaml:"dry_run,omitempty" json:"dry_run,omitempty" jsonschema:"default=false"` //nolint:govet
EnableDNS bool `yaml:"enable_dns,omitempty" json:"enable_dns,omitempty" jsonschema:"default=false"`
Force bool `yaml:"force,omitempty" json:"force,omitempty" jsonschema:"default=false"`
Recreate bool `yaml:"recreate,omitempty" json:"recreate,omitempty" jsonschema:"default=false"`
ResetValues bool `yaml:"reset_values,omitempty" json:"reset_values,omitempty" jsonschema:"default=false"`
Expand Down
40 changes: 25 additions & 15 deletions pkg/template/extra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,21 +161,6 @@ func (s *ExtraTestSuite) TestSetValueAtPath() {
}
}

func (s *ExtraTestSuite) TestRequiredEnv() {
name := s.T().Name()

res, err := template.RequiredEnv(name)
s.Require().Error(err)
s.Require().Empty(res)

data := "test"
s.T().Setenv(name, data)

res, err = template.RequiredEnv(name)
s.Require().NoError(err)
s.Require().Equal(data, res)
}

func (s *ExtraTestSuite) TestRequired() {
tests := []struct {
data any
Expand Down Expand Up @@ -329,3 +314,28 @@ func TestExtraTestSuite(t *testing.T) {
t.Parallel()
suite.Run(t, new(ExtraTestSuite))
}

type NonParallelExtraTestSuite struct {
suite.Suite
}

func (s *NonParallelExtraTestSuite) TestRequiredEnv() {
name := s.T().Name()

res, err := template.RequiredEnv(name)
s.Require().Error(err)
s.Require().Empty(res)

data := "test"
s.T().Setenv(name, data)

res, err = template.RequiredEnv(name)
s.Require().NoError(err)
s.Require().Equal(data, res)
}

//nolintlint:paralleltest // cannot parallel because of setenv
func TestNonParallelExtraTestSuite(t *testing.T) {
// t.Parallel()
suite.Run(t, new(NonParallelExtraTestSuite))
}

0 comments on commit 6cdb955

Please sign in to comment.