feat: Use --dry-run=server to make lookup work properly while diff (#501)

Signed-off-by: iiiceoo <iiiceoo@foxmail.com>
This commit is contained in:
iiice_oo
2024-01-23 17:59:47 +08:00
committed by GitHub
parent 9481c9afed
commit e954b7a37c
6 changed files with 162 additions and 738 deletions

View File

@@ -2,7 +2,6 @@ package dashboard
import (
"context"
"github.com/komodorio/helm-dashboard/pkg/frontend"
"html"
"net/http"
"os"
@@ -11,6 +10,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/komodorio/helm-dashboard/pkg/dashboard/handlers"
"github.com/komodorio/helm-dashboard/pkg/dashboard/objects"
"github.com/komodorio/helm-dashboard/pkg/frontend"
log "github.com/sirupsen/logrus"
)

View File

@@ -297,8 +297,8 @@ func TestE2E(t *testing.T) {
form.Add("values", "dashboard:\n allowWriteActions: true\n")
req, err = http.NewRequest("POST", "/api/helm/releases/test1/release1", strings.NewReader(form.Encode()))
assert.NilError(t, err)
newRouter.ServeHTTP(w, req)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
newRouter.ServeHTTP(w, req)
assert.Equal(t, w.Code, http.StatusAccepted)
// get history of revisions for release

View File

@@ -4,8 +4,6 @@ import (
"encoding/json"
"errors"
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/testapigroup/v1"
"net/http"
"sort"
"strconv"
@@ -24,6 +22,8 @@ import (
"helm.sh/helm/v3/pkg/chartutil"
"helm.sh/helm/v3/pkg/release"
helmtime "helm.sh/helm/v3/pkg/time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/testapigroup/v1"
"k8s.io/utils/strings/slices"
)

View File

@@ -2,8 +2,6 @@ package objects
import (
"bytes"
"gopkg.in/yaml.v3"
"helm.sh/helm/v3/pkg/registry"
"io"
"os"
"path"
@@ -12,12 +10,14 @@ import (
"github.com/joomcode/errorx"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chart/loader"
"helm.sh/helm/v3/pkg/cli"
"helm.sh/helm/v3/pkg/downloader"
"helm.sh/helm/v3/pkg/getter"
"helm.sh/helm/v3/pkg/registry"
"helm.sh/helm/v3/pkg/release"
v1 "k8s.io/apimachinery/pkg/apis/testapigroup/v1"
)
@@ -94,6 +94,9 @@ func (a *Releases) Install(namespace string, name string, repoChart string, vers
cmd.Version = version
cmd.DryRun = justTemplate
if cmd.DryRun {
cmd.DryRunOption = "server"
}
chrt, err := locateChart(cmd.ChartPathOptions, repoChart, a.Settings)
if err != nil {
@@ -332,6 +335,9 @@ func (r *Release) Upgrade(repoChart string, version string, justTemplate bool, v
cmd.Version = version
cmd.DryRun = justTemplate
if cmd.DryRun {
cmd.DryRunOption = "server"
}
cmd.ResetValues = true
chrt, err := locateChart(cmd.ChartPathOptions, repoChart, r.Settings)