fix: fixes a regexp issue for release summary (#666)
There was an issue a the regexp reding the version from helm output. Fixes #665
This commit is contained in:
parent
34c793d87e
commit
56c27c2bd9
|
|
@ -3,11 +3,6 @@ package state
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/roboll/helmfile/pkg/environment"
|
|
||||||
"github.com/roboll/helmfile/pkg/event"
|
|
||||||
"github.com/roboll/helmfile/pkg/helmexec"
|
|
||||||
"github.com/roboll/helmfile/pkg/remote"
|
|
||||||
"github.com/roboll/helmfile/pkg/tmpl"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
@ -16,6 +11,12 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/roboll/helmfile/pkg/environment"
|
||||||
|
"github.com/roboll/helmfile/pkg/event"
|
||||||
|
"github.com/roboll/helmfile/pkg/helmexec"
|
||||||
|
"github.com/roboll/helmfile/pkg/remote"
|
||||||
|
"github.com/roboll/helmfile/pkg/tmpl"
|
||||||
|
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
"github.com/tatsushid/go-prettytable"
|
"github.com/tatsushid/go-prettytable"
|
||||||
|
|
@ -434,7 +435,8 @@ func (st *HelmState) getDeployedVersion(context helmexec.HelmContext, helm helme
|
||||||
//retrieve the version
|
//retrieve the version
|
||||||
if out, err := helm.List(context, "^"+release.Name+"$", st.tillerFlags(release)...); err == nil {
|
if out, err := helm.List(context, "^"+release.Name+"$", st.tillerFlags(release)...); err == nil {
|
||||||
chartName := filepath.Base(release.Chart)
|
chartName := filepath.Base(release.Chart)
|
||||||
pat := regexp.MustCompile(chartName + "-(.*?)\\s")
|
//the regexp without escapes : .*\s.*\s.*\s.*\schartName-(.*?)\s
|
||||||
|
pat := regexp.MustCompile(".*\\s.*\\s.*\\s.*\\s" + chartName + "-(.*?)\\s")
|
||||||
versions := pat.FindStringSubmatch(out)
|
versions := pat.FindStringSubmatch(out)
|
||||||
if len(versions) > 0 {
|
if len(versions) > 0 {
|
||||||
return versions[1], nil
|
return versions[1], nil
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
package state
|
package state
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/roboll/helmfile/pkg/helmexec"
|
|
||||||
"github.com/roboll/helmfile/pkg/testhelper"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/roboll/helmfile/pkg/helmexec"
|
||||||
|
"github.com/roboll/helmfile/pkg/testhelper"
|
||||||
|
|
||||||
"errors"
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
|
@ -1232,6 +1233,16 @@ func TestGetDeployedVersion(t *testing.T) {
|
||||||
foo 1 Wed Apr 17 17:39:04 2019 DEPLOYED foo-bar-1.0.0-alpha+001 0.1.0 default`,
|
foo 1 Wed Apr 17 17:39:04 2019 DEPLOYED foo-bar-1.0.0-alpha+001 0.1.0 default`,
|
||||||
installedVersion: "1.0.0-alpha+001",
|
installedVersion: "1.0.0-alpha+001",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "chart version with dash and release with dash",
|
||||||
|
release: ReleaseSpec{
|
||||||
|
Name: "foo-bar",
|
||||||
|
Chart: "registry/foo-bar",
|
||||||
|
},
|
||||||
|
listResult: `NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
|
||||||
|
foo-bar-release 1 Wed Apr 17 17:39:04 2019 DEPLOYED foo-bar-1.0.0-alpha+001 0.1.0 default`,
|
||||||
|
installedVersion: "1.0.0-alpha+001",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for i := range tests {
|
for i := range tests {
|
||||||
tt := tests[i]
|
tt := tests[i]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue