Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ package-macos-arm64: go_arch=arm64
package-macos-arm64: package


## install: Build and then install the binary to /usr/local/bin. Requires root. Only works on Linux and macOS (tries to guess the OS and architecture).
## install: Build and then install the binary to $HOME/.local/bin. Does not require root. Only works on Linux and macOS (tries to guess the OS and architecture).
.PHONY: install
install: build
sudo install -Dm755 -t /usr/local/bin ${build_dir}/${go_os}/${go_arch}/${binary_name}
install -Dm755 -t "$$HOME/.local/bin" ${build_dir}/${go_os}/${go_arch}/${binary_name}

## install-linux-amd64: Build and then install the binary for Linux (amd64) to /usr/local/bin. Requires root.
.PHONY: install-linux-amd64
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.36.3
0.37.0
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/3lvia/cli

go 1.26
go 1.26.2

require (
github.com/charmbracelet/huh v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ fi
tar -xzf "$TARBALL"

if [[ "$OS" == "mac" ]]; then
sudo install -Dm755 3lv /usr/local/bin/
install -Dm755 3lv "$HOME/.local/bin"
else
sudo install -Dm755 -t /usr/local/bin 3lv
install -Dm755 -t "$HOME/.local/bin" 3lv
fi

echo "3lv version $LATEST_VERSION installed successfully!"
17 changes: 0 additions & 17 deletions pkg/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,6 @@ func Command() *cli.Command {
Name: "run-id",
Usage: "The GitHub Actions run ID to use for deployment annotations.",
},
&cli.StringFlag{
Name: "helm-chart-repository-url",
Usage: "Override the helm chart repository where the elvia-charts are located." +
" Useful for testing feature branches." +
" For instance 'https://raw.githubusercontent.com/3lvia/kubernetes-charts/feature/cool-new-charts'.",
Sources: cli.EnvVars("3LV_HELM_CHART_REPOSITORY_URL"),
},
&cli.BoolFlag{
Name: "allow-deploy",
Hidden: true,
Expand All @@ -172,7 +165,6 @@ func Command() *cli.Command {
}
}

Comment thread
baksetercx marked this conversation as resolved.
//nolint:gocyclo
func Deploy(ctx context.Context, c *cli.Command) error {
if c.NArg() <= 0 {
cli.ShowSubcommandHelpAndExit(c, 1)
Expand Down Expand Up @@ -239,7 +231,6 @@ func Deploy(ctx context.Context, c *cli.Command) error {
runtimeCloudProvider := strings.ToLower(c.String("runtime-cloud-provider"))
dryRun := c.Bool("dry-run")
runID := c.String("run-id")
helmChartRepositoryURL := c.String("helm-chart-repository-url")

if checkKubectlInstalledOutput := checkKubectlInstalledCommand(nil); command.IsError(checkKubectlInstalledOutput) {
return cli.Exit(fmt.Errorf("kubectl is not installed: %w", checkKubectlInstalledOutput.Error), 1)
Expand All @@ -254,14 +245,6 @@ func Deploy(ctx context.Context, c *cli.Command) error {
return cli.Exit(err, 1)
}

if helmRepoAddOutput := helmRepoAddCommand(helmChartRepositoryURL, nil); command.IsError(helmRepoAddOutput) {
return cli.Exit(fmt.Errorf("Failed to add Helm repository: %w", helmRepoAddOutput.Error), 1)
}

if helmRepoUpdateOutput := helmRepoUpdateCommand(nil); command.IsError(helmRepoUpdateOutput) {
return cli.Exit(fmt.Errorf("Failed to update Helm repository: %w", helmRepoUpdateOutput.Error), 1)
}

useISSChart := runtimeCloudProvider == "iss"

if helmDeployOutput := helmDeployCommand(
Expand Down
39 changes: 2 additions & 37 deletions pkg/deploy/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import (
)

const (
chartsNamespace = "elvia-charts"
chartsRepositoryURL = "https://raw.githubusercontent.com/3lvia/kubernetes-charts/master"
chartsRepositoryURL = "oci://ghcr.io/3lvia/charts"
)

func checkHelmInstalledCommand(
Expand All @@ -22,40 +21,6 @@ func checkHelmInstalledCommand(
)
}

func helmRepoAddCommand(
helmChartRepositoryURL string,
runOptions *command.RunOptions,
) command.Output {
url := chartsRepositoryURL
if helmChartRepositoryURL != "" {
url = helmChartRepositoryURL
}

return command.Run(
*exec.Command(
"helm",
"repo",
"add",
chartsNamespace,
url,
),
runOptions,
)
}

func helmRepoUpdateCommand(
runOptions *command.RunOptions,
) command.Output {
return command.Run(
*exec.Command(
"helm",
"repo",
"update",
),
runOptions,
)
}

func helmDeployCommand(
applicationName string,
systemName string,
Expand Down Expand Up @@ -101,7 +66,7 @@ func helmDeployCommand(
"-f",
helmValuesFile,
applicationName,
chartsNamespace+"/"+chartName,
chartsRepositoryURL+"/"+chartName,
"--set-string",
"environment="+environment,
"--set-string",
Expand Down
78 changes: 5 additions & 73 deletions pkg/deploy/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,74 +23,6 @@ func TestCheckHelmInstalledCommand(t *testing.T) {
)
}

func TestHelmRepoAddCommand(t *testing.T) {
t.Parallel()

expectedCommandString := strings.Join(
[]string{
"helm",
"repo",
"add",
"elvia-charts",
"https://raw.githubusercontent.com/3lvia/kubernetes-charts/master",
},
" ",
)

actualCommand := helmRepoAddCommand(
"",
&command.RunOptions{DryRun: true},
)

command.ExpectedCommandStringEqualsActualCommand(
t,
expectedCommandString,
actualCommand,
)
}

func TestHelmRepoAddCommandWithUrl(t *testing.T) {
t.Parallel()

expectedCommandString := strings.Join(
[]string{
"helm",
"repo",
"add",
"elvia-charts",
"https://raw.githubusercontent.com/3lvia/kubernetes-charts/feature/cool-new-charts",
},
" ",
)

actualCommand := helmRepoAddCommand(
"https://raw.githubusercontent.com/3lvia/kubernetes-charts/feature/cool-new-charts",
&command.RunOptions{DryRun: true},
)

command.ExpectedCommandStringEqualsActualCommand(
t,
expectedCommandString,
actualCommand,
)
}

func TestHelmRepoUpdateCommand(t *testing.T) {
t.Parallel()

expectedCommandString := "helm repo update"

actualCommand := helmRepoUpdateCommand(
&command.RunOptions{DryRun: true},
)

command.ExpectedCommandStringEqualsActualCommand(
t,
expectedCommandString,
actualCommand,
)
}

func TestHelmDeployCommand1(t *testing.T) {
t.Setenv("GITHUB_ACTIONS", "false") // Reset GITHUB_ACTIONS env var so tests don't fail in GitHub Actions

Expand All @@ -117,7 +49,7 @@ func TestHelmDeployCommand1(t *testing.T) {
"-f",
helmValuesFile,
applicationName,
"elvia-charts/elvia-" + workloadType,
"oci://ghcr.io/3lvia/charts/elvia-" + workloadType,
"--set-string",
"environment=" + environment,
"--set-string",
Expand Down Expand Up @@ -180,7 +112,7 @@ func TestHelmDeployCommand2(t *testing.T) {
"-f",
helmValuesFile,
applicationName,
"elvia-charts/elvia-" + workloadType,
"oci://ghcr.io/3lvia/charts/elvia-" + workloadType,
"--set-string",
"environment=" + environment,
"--set-string",
Expand Down Expand Up @@ -243,7 +175,7 @@ func TestHelmDeployCommand3(t *testing.T) {
"-f",
helmValuesFile,
applicationName,
"elvia-charts/elvia-" + workloadType,
"oci://ghcr.io/3lvia/charts/elvia-" + workloadType,
"--set-string",
"environment=" + environment,
"--set-string",
Expand Down Expand Up @@ -341,7 +273,7 @@ func TestHelmDeployCommand5(t *testing.T) {
"-f",
helmValuesFile,
applicationName,
"elvia-charts/iss-" + workloadType,
"oci://ghcr.io/3lvia/charts/iss-" + workloadType,
"--set-string",
"environment=" + environment,
"--set-string",
Expand Down Expand Up @@ -435,7 +367,7 @@ func TestHelmDeployCommandWithGitHubActionsEnv(t *testing.T) {
"-f",
helmValuesFile,
applicationName,
"elvia-charts/elvia-" + workloadType,
"oci://ghcr.io/3lvia/charts/elvia-" + workloadType,
"--set-string",
"environment=" + environment,
"--set-string",
Expand Down
4 changes: 2 additions & 2 deletions setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ runs:
fi

echo "git-$version-$(git rev-parse --short HEAD)" > VERSION
sudo make install
make install
3lv --version
exit 0
fi

md5sum -c --quiet 3lv-*linux-amd64.tar.gz.md5
tar -xzf 3lv-*linux-amd64.tar.gz
sudo install -Dm755 -t /usr/local/bin 3lv
install -Dm755 -t "$HOME/.local/bin" 3lv
3lv --version
env:
VERSION: ${{ inputs.version }}
Expand Down
Loading