Skip to content

Commit 1c18372

Browse files
authored
Merge pull request #3121 from devspace-sh/DSP-156
Update loft utils for helm v4
2 parents 680b4d3 + fd19932 commit 1c18372

28 files changed

Lines changed: 418 additions & 525 deletions

File tree

.github/workflows/unit-tests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
strategy:
2222
matrix:
2323
os: [macos-latest, ubuntu-latest]
24-
24+
2525
name: unit-test-${{ matrix.os }}
2626
runs-on: ${{ matrix.os }}
27-
27+
2828
steps:
2929
- name: Set up Go
3030
uses: actions/setup-go@v5

cmd/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
"github.com/loft-sh/devspace/pkg/util/fsutil"
3636
"github.com/loft-sh/devspace/pkg/util/log"
3737
"github.com/loft-sh/devspace/pkg/util/survey"
38-
"github.com/loft-sh/loft-util/pkg/command"
38+
"github.com/loft-sh/utils/pkg/command"
3939
"github.com/mgutz/ansi"
4040
"github.com/pkg/errors"
4141
"github.com/spf13/cobra"

cmd/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"github.com/loft-sh/devspace/pkg/util/exit"
2121
"github.com/loft-sh/devspace/pkg/util/interrupt"
2222
"github.com/loft-sh/devspace/pkg/util/log"
23-
"github.com/loft-sh/loft-util/pkg/command"
23+
"github.com/loft-sh/utils/pkg/command"
2424
"mvdan.cc/sh/v3/interp"
2525

2626
"github.com/loft-sh/devspace/cmd/flags"

e2e/tests/render/testdata/helm/rendered.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ metadata:
99
"app.kubernetes.io/component": "test"
1010
"app.kubernetes.io/managed-by": "Helm"
1111
annotations:
12-
"helm.sh/chart": "component-chart-0.9.1"
12+
"helm.sh/chart": "component-chart-0.9.2"
1313
spec:
1414
replicas: 1
1515
strategy:
@@ -26,7 +26,7 @@ spec:
2626
"app.kubernetes.io/component": "test"
2727
"app.kubernetes.io/managed-by": "Helm"
2828
annotations:
29-
"helm.sh/chart": "component-chart-0.9.1"
29+
"helm.sh/chart": "component-chart-0.9.2"
3030
spec:
3131
imagePullSecrets:
3232
nodeSelector:
@@ -78,7 +78,6 @@ spec:
7878
volumeMounts:
7979
initContainers:
8080
volumes:
81-
volumeClaimTemplates:
8281
---
8382
# Source: component-chart/templates/deployment.yaml
8483
# Create headless service for StatefulSet

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ require (
3131
github.com/json-iterator/go v1.1.12
3232
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213
3333
github.com/loft-sh/go-github-selfupdate v1.0.0
34-
github.com/loft-sh/loft-util v0.0.9-alpha
3534
github.com/loft-sh/notify v0.0.0-20210827094439-0720dcc7feee
3635
github.com/loft-sh/programming-language-detection v0.0.5
3736
github.com/loft-sh/utils v0.0.16

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,6 @@ github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhn
343343
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE=
344344
github.com/loft-sh/go-github-selfupdate v1.0.0 h1:YS8iSsIWXw3BygBdPK2xDO4K84XYu2YuYgVS7eQNtik=
345345
github.com/loft-sh/go-github-selfupdate v1.0.0/go.mod h1:LDkR6J2QpqQLIMcYvNaSinVwvjPAkg8278oZBPGnrb8=
346-
github.com/loft-sh/loft-util v0.0.9-alpha h1:kGcyTQWxWHWy7bbjhS8Hsq/JRdlSztAU++anV6P+sqk=
347-
github.com/loft-sh/loft-util v0.0.9-alpha/go.mod h1:lsjG5Exh5iEf7Z/87nqwkxx3GRQTizFRLGuS1knF6Cg=
348346
github.com/loft-sh/notify v0.0.0-20210827094439-0720dcc7feee h1:hZ79+pKEbCBrH1dVmgZ4jtFrrDPxgM4zqEP1lHlSnvI=
349347
github.com/loft-sh/notify v0.0.0-20210827094439-0720dcc7feee/go.mod h1:pq83B8lgfCY7tKdegTTXU6DZxGQkcWMowUTOTpTQmqk=
350348
github.com/loft-sh/programming-language-detection v0.0.5 h1:XiWlxtrf4t6Z7SQiob0JMKaCeMHCP3kWhB80wLt+EMY=

hack/build-all.bash

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,32 @@ fi
4141
# Create the release directory
4242
mkdir -p "${DEVSPACE_ROOT}/release"
4343

44-
# Install Helm 3
44+
# Install Helm 4
4545
echo "Installing helm"
46-
curl -s https://get.helm.sh/helm-v3.3.4-darwin-amd64.tar.gz > helm3.tar.gz && tar -zxvf helm3.tar.gz darwin-amd64/helm && chmod +x darwin-amd64/helm
46+
HELM_OS=$(uname -s | tr '[:upper:]' '[:lower:]')
47+
HELM_ARCH=$(uname -m)
48+
case "${HELM_ARCH}" in
49+
x86_64)
50+
HELM_ARCH="amd64"
51+
;;
52+
aarch64|arm64)
53+
HELM_ARCH="arm64"
54+
;;
55+
i386|i686)
56+
HELM_ARCH="386"
57+
;;
58+
esac
59+
HELM_PLATFORM="${HELM_OS}-${HELM_ARCH}"
60+
HELM_VERSION=$(sed -nE 's/^const helmVersion = "([^"]+)"/\1/p' pkg/util/downloader/commands/helm_v4.go)
61+
if [[ -z "${HELM_VERSION}" ]]; then
62+
echo "unable to determine Helm version" 1>&2
63+
exit 1
64+
fi
65+
curl -s "https://get.helm.sh/helm-${HELM_VERSION}-${HELM_PLATFORM}.tar.gz" > helm4.tar.gz && tar -zxvf helm4.tar.gz "${HELM_PLATFORM}/helm" && chmod +x "${HELM_PLATFORM}/helm"
4766

4867
# Pull the component chart
4968
COMPONENT_CHART_VERSION=$(cat pkg/devspace/deploy/deployer/helm/client.go | grep 'Version: "' | sed -nE 's/[^"]+"(.+)",\s*/\1/p')
50-
darwin-amd64/helm pull component-chart --repo https://charts.devspace.sh --version $COMPONENT_CHART_VERSION
69+
"${HELM_PLATFORM}/helm" pull component-chart --repo https://charts.devspace.sh --version $COMPONENT_CHART_VERSION
5170

5271
# Move ui.tar.gz to releases
5372
echo "Moving ui"
@@ -74,28 +93,28 @@ for OS in ${DEVSPACE_BUILD_PLATFORMS[@]}; do
7493
if [[ "${OS}" == "windows" ]]; then
7594
NAME="${NAME}.exe"
7695
fi
77-
96+
7897
# darwin 386 is deprecated and shouldn't be used anymore
7998
if [[ "${ARCH}" == "386" && "${OS}" == "darwin" ]]; then
8099
echo "Building for ${OS}/${ARCH} not supported."
81100
continue
82101
fi
83-
102+
84103
# arm64 build is only supported for darwin
85104
if [[ "${ARCH}" == "arm64" && "${OS}" == "windows" ]]; then
86105
echo "Building for ${OS}/${ARCH} not supported."
87106
continue
88107
fi
89-
108+
90109
echo "Building for ${OS}/${ARCH}"
91-
110+
92111
# build darwin with CGO_ENABLED=1
93112
if [[ "${OS}" == "darwin" ]]; then
94113
CGO_ENABLED=1
95114
else
96-
CGO_ENABLED=0
115+
CGO_ENABLED=0
97116
fi
98-
117+
99118
# build the DevSpace binary
100119
CGO_ENABLED=${CGO_ENABLED} GOARCH=${ARCH} GOOS=${OS} ${GO_BUILD_CMD} -ldflags "${GO_BUILD_LDFLAGS}"\
101120
-o "${DEVSPACE_ROOT}/release/${NAME}" .

pkg/devspace/config/loader/variable/predefined_variable.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,25 @@ import (
66
"encoding/json"
77
"errors"
88
"fmt"
9-
"github.com/loft-sh/devspace/pkg/devspace/config/constants"
109
"os"
1110
"path/filepath"
1211
"strconv"
1312
"strings"
1413
"time"
1514

15+
"github.com/loft-sh/devspace/pkg/devspace/config/constants"
16+
"github.com/loft-sh/devspace/pkg/devspace/config/versions/latest"
1617
"github.com/loft-sh/devspace/pkg/devspace/context/values"
1718
"github.com/loft-sh/devspace/pkg/devspace/kubectl"
18-
"github.com/loft-sh/devspace/pkg/util/log"
19-
"github.com/loft-sh/utils/pkg/downloader"
20-
"github.com/loft-sh/utils/pkg/downloader/commands"
21-
"github.com/sirupsen/logrus"
22-
23-
"github.com/loft-sh/devspace/pkg/devspace/config/versions/latest"
2419
"github.com/loft-sh/devspace/pkg/devspace/plugin"
2520
"github.com/loft-sh/devspace/pkg/devspace/upgrade"
2621
"github.com/loft-sh/devspace/pkg/util/git"
22+
"github.com/loft-sh/devspace/pkg/util/log"
2723
"github.com/loft-sh/devspace/pkg/util/randutil"
24+
"github.com/loft-sh/utils/pkg/downloader"
25+
"github.com/loft-sh/utils/pkg/downloader/commands"
2826
"github.com/mitchellh/go-homedir"
27+
"github.com/sirupsen/logrus"
2928
)
3029

3130
// PredefinedVariableOptions holds the options for a predefined variable to load
@@ -54,8 +53,8 @@ var predefinedVars = map[string]PredefinedVariableFunction{
5453
}
5554
return ex, nil
5655
},
57-
"DEVSPACE_KUBECTL_EXECUTABLE": func(ctx context.Context, options *PredefinedVariableOptions, log log.Logger) (interface{}, error) {
58-
debugLog := log.WithLevel(logrus.DebugLevel)
56+
"DEVSPACE_KUBECTL_EXECUTABLE": func(ctx context.Context, options *PredefinedVariableOptions, logger log.Logger) (interface{}, error) {
57+
debugLog := logger.WithLevel(logrus.DebugLevel)
5958
path, err := downloader.NewDownloader(commands.NewKubectlCommand(), debugLog, constants.DefaultHomeDevSpaceFolder).EnsureCommand(ctx)
6059
if err != nil {
6160
debugLog.Debugf("Error downloading kubectl: %v", err)

pkg/devspace/deploy/deployer/helm/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const ComponentChartFolder = "component-chart"
2323
// DevSpaceChartConfig is the config that holds the devspace chart information
2424
var DevSpaceChartConfig = &latest.ChartConfig{
2525
Name: "component-chart",
26-
Version: "0.9.1",
26+
Version: "0.9.2",
2727
RepoURL: "https://charts.devspace.sh",
2828
}
2929

pkg/devspace/helm/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package helm
22

33
import (
44
"github.com/loft-sh/devspace/pkg/devspace/helm/types"
5-
v3 "github.com/loft-sh/devspace/pkg/devspace/helm/v3"
5+
v4 "github.com/loft-sh/devspace/pkg/devspace/helm/v4"
66
"github.com/loft-sh/devspace/pkg/util/log"
77
)
88

99
// NewClient creates a new helm client based on the config
1010
func NewClient(log log.Logger) (types.Client, error) {
11-
return v3.NewClient(log)
11+
return v4.NewClient(log)
1212
}

0 commit comments

Comments
 (0)