Add version package to allow test imports
Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
parent
36db5c374d
commit
8067504097
|
|
@ -14,13 +14,14 @@ import (
|
|||
"helm.sh/helm/v3/pkg/cli"
|
||||
|
||||
"github.com/helmfile/helmfile/pkg/helmexec"
|
||||
"github.com/helmfile/helmfile/pkg/version"
|
||||
)
|
||||
|
||||
var (
|
||||
manuallyInstallCode = 1
|
||||
windowPackageManagers = map[string]string{
|
||||
"scoop": fmt.Sprintf("scoop install helm@%s", strings.TrimLeft(HelmRecommendedVersion, "v")),
|
||||
"choco": fmt.Sprintf("choco install kubernetes-helm --version %s", strings.TrimLeft(HelmRecommendedVersion, "v")),
|
||||
"scoop": fmt.Sprintf("scoop install helm@%s", strings.TrimLeft(version.HelmRecommendedVersion, "v")),
|
||||
"choco": fmt.Sprintf("choco install kubernetes-helm --version %s", strings.TrimLeft(version.HelmRecommendedVersion, "v")),
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -90,7 +91,7 @@ func (h *HelmfileInit) InstallHelm() error {
|
|||
return h.installHelmOnWindows()
|
||||
}
|
||||
|
||||
err := h.WhetherContinue(fmt.Sprintf("use: '%s'", HelmInstallCommand))
|
||||
err := h.WhetherContinue(fmt.Sprintf("use: '%s'", version.HelmInstallCommand))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -102,14 +103,14 @@ func (h *HelmfileInit) InstallHelm() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = downloadfile(getHelmScript.Name(), HelmInstallCommand)
|
||||
err = downloadfile(getHelmScript.Name(), version.HelmInstallCommand)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = h.runner.Execute("bash", []string{
|
||||
getHelmScript.Name(),
|
||||
"--version",
|
||||
HelmRecommendedVersion,
|
||||
version.HelmRecommendedVersion,
|
||||
}, nil, true)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -182,7 +183,7 @@ func (h *HelmfileInit) CheckHelm() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
requiredHelmVersion, _ := semver.NewVersion(HelmRequiredVersion)
|
||||
requiredHelmVersion, _ := semver.NewVersion(version.HelmRequiredVersion)
|
||||
if helmversion.LessThan(requiredHelmVersion) {
|
||||
h.logger.Infof("helm version is too low, the current version is %s, the required version is %s", helmversion, requiredHelmVersion)
|
||||
err = h.UpdateHelm()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
# Version Package
|
||||
|
||||
## Overview
|
||||
|
||||
The `version` package contains version-related constants and utilities used throughout the Helmfile codebase. It was created as a standalone package to avoid import cycles while making version information accessible to all components.
|
||||
|
||||
## Contents
|
||||
|
||||
This package includes:
|
||||
|
||||
- `HelmRequiredVersion`: The minimum required Helm version for Helmfile
|
||||
- Other version-related constants and utilities
|
||||
|
||||
## Usage
|
||||
|
||||
Import this package when you need access to version information:
|
||||
|
||||
```go
|
||||
import "github.com/helmfile/helmfile/pkg/version"
|
||||
|
||||
func someFunction() {
|
||||
// Use version constants
|
||||
requiredVersion := version.HelmRequiredVersion
|
||||
|
||||
// Example usage
|
||||
fmt.Printf("Helmfile requires Helm version %s or later\n", requiredVersion)
|
||||
}
|
||||
```
|
||||
|
||||
## Design Considerations
|
||||
|
||||
This package is intentionally isolated from other Helmfile packages to prevent import cycles. It should:
|
||||
|
||||
- Contain only version-related constants and simple utilities
|
||||
- Not import other Helmfile packages
|
||||
- Be kept minimal to serve its specific purpose
|
||||
|
||||
When adding new version-related functionality, ensure it belongs here rather than in a more specific package.
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package version
|
||||
|
||||
const (
|
||||
HelmRequiredVersion = "v3.16.4"
|
||||
HelmRecommendedVersion = "v3.17.2"
|
||||
HelmDiffRecommendedVersion = "v3.11.0"
|
||||
HelmSecretsRecommendedVersion = "v4.6.0"
|
||||
HelmGitRecommendedVersion = "v0.15.1"
|
||||
HelmS3RecommendedVersion = "v0.16.0"
|
||||
HelmInstallCommand = "https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3"
|
||||
)
|
||||
Loading…
Reference in New Issue