mirror of
https://github.com/helm/helm.git
synced 2026-05-28 04:35:48 -04:00
chore: fix unnecessary-format issues from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
parent
42f78ba60e
commit
7edfff33eb
48 changed files with 108 additions and 106 deletions
2
.github/env
vendored
2
.github/env
vendored
|
|
@ -1,2 +1,2 @@
|
|||
GOLANG_VERSION=1.25
|
||||
GOLANGCI_LINT_VERSION=v2.10.1
|
||||
GOLANGCI_LINT_VERSION=v2.11.3
|
||||
|
|
|
|||
|
|
@ -77,9 +77,11 @@ linters:
|
|||
require-specific: true
|
||||
|
||||
revive:
|
||||
max-open-files: 2048
|
||||
enable-all-rules: false
|
||||
enable-default-rules: true
|
||||
max-open-files: 2048
|
||||
rules:
|
||||
- name: unnecessary-format
|
||||
- name: var-naming
|
||||
arguments:
|
||||
- ["ID"] # AllowList
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ func TestInvalidYaml(t *testing.T) {
|
|||
t.Fatalf("All didn't fail with expected errors, got %#v", m)
|
||||
}
|
||||
if !strings.Contains(m[0].Err.Error(), "deliberateSyntaxError") {
|
||||
t.Errorf("All didn't have the error for deliberateSyntaxError")
|
||||
t.Error("All didn't have the error for deliberateSyntaxError")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ func TestInvalidChartYamlV3(t *testing.T) {
|
|||
t.Fatalf("All didn't fail with expected errors, got %#v", m)
|
||||
}
|
||||
if !strings.Contains(m[0].Err.Error(), "failed to strictly parse chart metadata file") {
|
||||
t.Errorf("All didn't have the error for duplicate YAML keys")
|
||||
t.Error("All didn't have the error for duplicate YAML keys")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -237,7 +237,7 @@ func TestMalformedTemplate(t *testing.T) {
|
|||
t.Fatalf("All didn't fail with expected errors, got %#v", m)
|
||||
}
|
||||
if !strings.Contains(m[0].Err.Error(), "invalid character '{'") {
|
||||
t.Errorf("All didn't have the error for invalid character '{'")
|
||||
t.Error("All didn't have the error for invalid character '{'")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,26 +50,26 @@ func TestValidateChartYamlNotDirectory(t *testing.T) {
|
|||
|
||||
err := validateChartYamlNotDirectory(nonExistingChartFilePath)
|
||||
if err == nil {
|
||||
t.Errorf("validateChartYamlNotDirectory to return a linter error, got no error")
|
||||
t.Error("validateChartYamlNotDirectory to return a linter error, got no error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateChartYamlFormat(t *testing.T) {
|
||||
err := validateChartYamlFormat(errors.New("Read error"))
|
||||
if err == nil {
|
||||
t.Errorf("validateChartYamlFormat to return a linter error, got no error")
|
||||
t.Error("validateChartYamlFormat to return a linter error, got no error")
|
||||
}
|
||||
|
||||
err = validateChartYamlFormat(nil)
|
||||
if err != nil {
|
||||
t.Errorf("validateChartYamlFormat to return no error, got a linter error")
|
||||
t.Error("validateChartYamlFormat to return no error, got a linter error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateChartName(t *testing.T) {
|
||||
err := validateChartName(badChart)
|
||||
if err == nil {
|
||||
t.Errorf("validateChartName to return a linter error, got no error")
|
||||
t.Error("validateChartName to return a linter error, got no error")
|
||||
}
|
||||
|
||||
err = validateChartName(badChartName)
|
||||
|
|
@ -149,7 +149,7 @@ func TestValidateChartMaintainer(t *testing.T) {
|
|||
badChart.Maintainers = []*chart.Maintainer{nil}
|
||||
err := validateChartMaintainer(badChart)
|
||||
if err == nil {
|
||||
t.Errorf("validateChartMaintainer did not return error for nil maintainer as expected")
|
||||
t.Error("validateChartMaintainer did not return error for nil maintainer as expected")
|
||||
}
|
||||
if err.Error() != "a maintainer entry is empty" {
|
||||
t.Errorf("validateChartMaintainer returned unexpected error for nil maintainer: %s", err.Error())
|
||||
|
|
@ -185,7 +185,7 @@ func TestValidateChartIconPresence(t *testing.T) {
|
|||
err := validateChartIconPresence(testChart)
|
||||
|
||||
if err == nil {
|
||||
t.Errorf("validateChartIconPresence to return a linter error, got no error")
|
||||
t.Error("validateChartIconPresence to return a linter error, got no error")
|
||||
} else if !strings.Contains(err.Error(), "icon is recommended") {
|
||||
t.Errorf("expected %q, got %q", "icon is recommended", err.Error())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ func TestValidateDependencyInMetadata(t *testing.T) {
|
|||
c := chartWithBadDependencies()
|
||||
|
||||
if err := validateDependencyInMetadata(&c); err == nil {
|
||||
t.Errorf("chart should have been flagged for missing deps in chart metadata")
|
||||
t.Error("chart should have been flagged for missing deps in chart metadata")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ func TestValidateDependenciesUnique(t *testing.T) {
|
|||
|
||||
for _, tt := range tests {
|
||||
if err := validateDependenciesUnique(&tt.chart); err == nil {
|
||||
t.Errorf("chart should have been flagged for dependency shadowing")
|
||||
t.Error("chart should have been flagged for dependency shadowing")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,6 @@ func TestValidateNoDeprecations(t *testing.T) {
|
|||
APIVersion: "v1",
|
||||
Kind: "Pod",
|
||||
}, nil); err != nil {
|
||||
t.Errorf("Expected a v1 Pod to not be deprecated")
|
||||
t.Error("Expected a v1 Pod to not be deprecated")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ func TestValidateValuesYamlNotDirectory(t *testing.T) {
|
|||
|
||||
err := validateValuesFileExistence(nonExistingValuesFilePath)
|
||||
if err == nil {
|
||||
t.Errorf("validateValuesFileExistence to return a linter error, got no error")
|
||||
t.Error("validateValuesFileExistence to return a linter error, got no error")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ func TestLoadDirWithDevNull(t *testing.T) {
|
|||
t.Fatalf("Failed to load testdata: %s", err)
|
||||
}
|
||||
if _, err := l.Load(); err == nil {
|
||||
t.Errorf("packages with an irregular file (/dev/null) should not load")
|
||||
t.Error("packages with an irregular file (/dev/null) should not load")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,11 +56,11 @@ func verifyChartfile(t *testing.T, f *chart.Metadata, name string) {
|
|||
}
|
||||
|
||||
if f.Maintainers[0].Name != "The Helm Team" {
|
||||
t.Errorf("Unexpected maintainer name.")
|
||||
t.Error("Unexpected maintainer name.")
|
||||
}
|
||||
|
||||
if f.Maintainers[1].Email != "nobody@example.com" {
|
||||
t.Errorf("Unexpected maintainer email.")
|
||||
t.Error("Unexpected maintainer email.")
|
||||
}
|
||||
|
||||
if len(f.Sources) != 1 {
|
||||
|
|
@ -111,7 +111,7 @@ func TestIsChartDir(t *testing.T) {
|
|||
}
|
||||
validChartDir, err = IsChartDir("testdata")
|
||||
if validChartDir || err == nil {
|
||||
t.Errorf("expected error but did not get any")
|
||||
t.Error("expected error but did not get any")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ func TestCreate_Overwrite(t *testing.T) {
|
|||
}
|
||||
|
||||
if errlog.Len() == 0 {
|
||||
t.Errorf("Expected warnings about overwriting files.")
|
||||
t.Error("Expected warnings about overwriting files.")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,16 +53,16 @@ var fakePluginB64 = "H4sIAAAAAAAAA+3SQUvDMBgG4Jz7K0LwapdvSxrwJig6mCKC5xHabBaXdDS
|
|||
|
||||
func TestStripName(t *testing.T) {
|
||||
if stripPluginName("fake-plugin-0.0.1.tar.gz") != "fake-plugin" {
|
||||
t.Errorf("name does not match expected value")
|
||||
t.Error("name does not match expected value")
|
||||
}
|
||||
if stripPluginName("fake-plugin-0.0.1.tgz") != "fake-plugin" {
|
||||
t.Errorf("name does not match expected value")
|
||||
t.Error("name does not match expected value")
|
||||
}
|
||||
if stripPluginName("fake-plugin.tgz") != "fake-plugin" {
|
||||
t.Errorf("name does not match expected value")
|
||||
t.Error("name does not match expected value")
|
||||
}
|
||||
if stripPluginName("fake-plugin.tar.gz") != "fake-plugin" {
|
||||
t.Errorf("name does not match expected value")
|
||||
t.Error("name does not match expected value")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -345,7 +345,7 @@ func TestMediaTypeToExtension(t *testing.T) {
|
|||
t.Errorf("Media type %q failed test", mt)
|
||||
}
|
||||
if shouldPass && ext == "" {
|
||||
t.Errorf("Expected an extension but got empty string")
|
||||
t.Error("Expected an extension but got empty string")
|
||||
}
|
||||
if !shouldPass && len(ext) != 0 {
|
||||
t.Error("Expected extension to be empty for unrecognized type")
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ func InstallWithOptions(i Installer, opts Options) (*VerificationResult, error)
|
|||
// Check if provenance data exists
|
||||
if len(provData) == 0 {
|
||||
// No .prov file found - emit warning but continue installation
|
||||
fmt.Fprintf(os.Stderr, "WARNING: No provenance file found for plugin. Plugin is not signed and cannot be verified.\n")
|
||||
fmt.Fprint(os.Stderr, "WARNING: No provenance file found for plugin. Plugin is not signed and cannot be verified.\n")
|
||||
} else {
|
||||
// Provenance data exists - verify the plugin
|
||||
verification, err := plugin.VerifyPlugin(archiveData, provData, filename, opts.Keyring)
|
||||
|
|
|
|||
|
|
@ -23,18 +23,18 @@ func TestIsRemoteHTTPArchive(t *testing.T) {
|
|||
source := srv.URL + "/plugins/fake-plugin-0.0.1.tar.gz"
|
||||
|
||||
if isRemoteHTTPArchive("/not/a/URL") {
|
||||
t.Errorf("Expected non-URL to return false")
|
||||
t.Error("Expected non-URL to return false")
|
||||
}
|
||||
|
||||
// URLs with valid archive extensions are considered valid archives
|
||||
// even if the server is unreachable (optimization to avoid unnecessary HTTP requests)
|
||||
if !isRemoteHTTPArchive("https://127.0.0.1:123/fake/plugin-1.2.3.tgz") {
|
||||
t.Errorf("URL with .tgz extension should be considered a valid archive")
|
||||
t.Error("URL with .tgz extension should be considered a valid archive")
|
||||
}
|
||||
|
||||
// Test with invalid extension and unreachable server
|
||||
if isRemoteHTTPArchive("https://127.0.0.1:123/fake/plugin-1.2.3.notanarchive") {
|
||||
t.Errorf("Bad URL without valid extension should not succeed")
|
||||
t.Error("Bad URL without valid extension should not succeed")
|
||||
}
|
||||
|
||||
if !isRemoteHTTPArchive(source) {
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ func TestNewOCIInstaller(t *testing.T) {
|
|||
|
||||
if tt.expectError {
|
||||
if err == nil {
|
||||
t.Errorf("expected error but got none")
|
||||
t.Error("expected error but got none")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
@ -416,7 +416,7 @@ func TestOCIInstaller_Install_WithGetterOptions(t *testing.T) {
|
|||
err = Install(installer)
|
||||
if tc.wantErr {
|
||||
if err == nil {
|
||||
t.Errorf("Expected installation to fail, but it succeeded")
|
||||
t.Error("Expected installation to fail, but it succeeded")
|
||||
}
|
||||
} else {
|
||||
if err != nil {
|
||||
|
|
@ -526,13 +526,13 @@ func TestOCIInstaller_Install_ComponentExtraction(t *testing.T) {
|
|||
// Verify plugin.yaml exists
|
||||
pluginYAMLPath := filepath.Join(tempDir, "plugin.yaml")
|
||||
if _, err := os.Stat(pluginYAMLPath); os.IsNotExist(err) {
|
||||
t.Errorf("plugin.yaml not found after extraction")
|
||||
t.Error("plugin.yaml not found after extraction")
|
||||
}
|
||||
|
||||
// Verify bin directory exists
|
||||
binPath := filepath.Join(tempDir, "bin")
|
||||
if _, err := os.Stat(binPath); os.IsNotExist(err) {
|
||||
t.Errorf("bin directory not found after extraction")
|
||||
t.Error("bin directory not found after extraction")
|
||||
}
|
||||
|
||||
// Verify executable exists and has correct permissions
|
||||
|
|
@ -540,12 +540,12 @@ func TestOCIInstaller_Install_ComponentExtraction(t *testing.T) {
|
|||
if info, err := os.Stat(execPath); err != nil {
|
||||
t.Errorf("executable not found: %v", err)
|
||||
} else if info.Mode()&0111 == 0 {
|
||||
t.Errorf("file is not executable")
|
||||
t.Error("file is not executable")
|
||||
}
|
||||
|
||||
// Verify this would be recognized as a plugin
|
||||
if !isPlugin(tempDir) {
|
||||
t.Errorf("extracted directory is not a valid plugin")
|
||||
t.Error("extracted directory is not a valid plugin")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -798,7 +798,7 @@ func TestOCIInstaller_Install_ValidationErrors(t *testing.T) {
|
|||
t.Error("expected valid gzip data")
|
||||
}
|
||||
if !strings.Contains(tt.errorMsg, "is not a gzip compressed archive") {
|
||||
t.Errorf("expected error message to contain 'is not a gzip compressed archive'")
|
||||
t.Error("expected error message to contain 'is not a gzip compressed archive'")
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ func TestInstallWithOptions_VerifyWithValidProvenance(t *testing.T) {
|
|||
|
||||
// Plugin should not be installed due to verification failure
|
||||
if _, err := os.Stat(installer.Path()); !os.IsNotExist(err) {
|
||||
t.Errorf("Plugin should not be installed when verification fails")
|
||||
t.Error("Plugin should not be installed when verification fails")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -150,7 +150,7 @@ func TestInstallWithOptions_VerifyWithInvalidProvenance(t *testing.T) {
|
|||
|
||||
// Should fail with verification error
|
||||
if err == nil {
|
||||
t.Fatalf("Expected installation with invalid .prov file to fail")
|
||||
t.Fatal("Expected installation with invalid .prov file to fail")
|
||||
}
|
||||
if result != nil {
|
||||
t.Errorf("Expected nil verification result when verification fails, got: %+v", result)
|
||||
|
|
@ -164,7 +164,7 @@ func TestInstallWithOptions_VerifyWithInvalidProvenance(t *testing.T) {
|
|||
|
||||
// Plugin should not be installed
|
||||
if _, err := os.Stat(installer.Path()); !os.IsNotExist(err) {
|
||||
t.Errorf("Plugin should not be installed when verification fails")
|
||||
t.Error("Plugin should not be installed when verification fails")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ func TestGetVersionSet(t *testing.T) {
|
|||
}
|
||||
|
||||
if !vs.Has("v1") {
|
||||
t.Errorf("Expected supported versions to at least include v1.")
|
||||
t.Error("Expected supported versions to at least include v1.")
|
||||
}
|
||||
if vs.Has("nosuchversion/v1") {
|
||||
t.Error("Non-existent version is reported found.")
|
||||
|
|
|
|||
|
|
@ -403,11 +403,11 @@ data:
|
|||
}
|
||||
|
||||
if err != nil && !tc.expectError {
|
||||
t.Fatalf("Got an unexpected error.")
|
||||
t.Fatal("Got an unexpected error.")
|
||||
}
|
||||
|
||||
if err == nil && tc.expectError {
|
||||
t.Fatalf("Expected and error but did not get it.")
|
||||
t.Fatal("Expected and error but did not get it.")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1270,7 +1270,7 @@ func TestInstallCRDs_CheckNilErrors(t *testing.T) {
|
|||
|
||||
err := instAction.installCRDs(tt.input)
|
||||
if err == nil {
|
||||
t.Errorf("got nil expected err")
|
||||
t.Error("got nil expected err")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ func TestLintChart(t *testing.T) {
|
|||
case err != nil && !tt.err:
|
||||
t.Errorf("%s", err)
|
||||
case err == nil && tt.err:
|
||||
t.Errorf("Expected a chart parsing error")
|
||||
t.Error("Expected a chart parsing error")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ func TestDefaultCapabilities(t *testing.T) {
|
|||
func TestParseKubeVersion(t *testing.T) {
|
||||
kv, err := ParseKubeVersion("v1.16.0")
|
||||
if err != nil {
|
||||
t.Errorf("Expected v1.16.0 to parse successfully")
|
||||
t.Error("Expected v1.16.0 to parse successfully")
|
||||
}
|
||||
if kv.Version != "v1.16.0" {
|
||||
t.Errorf("Expected parsed KubeVersion.Version to be v1.16.0, got %q", kv.String())
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ func TestToRenderValues(t *testing.T) {
|
|||
t.Error("Expected upgrade to be false.")
|
||||
}
|
||||
if !relmap["IsInstall"].(bool) {
|
||||
t.Errorf("Expected install to be true.")
|
||||
t.Error("Expected install to be true.")
|
||||
}
|
||||
if !res["Capabilities"].(*common.Capabilities).APIVersions.Has("v1") {
|
||||
t.Error("Expected Capabilities to have v1 as an API")
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ chapter:
|
|||
}
|
||||
|
||||
if _, err := d.Table("title"); err == nil {
|
||||
t.Fatalf("Title is not a table.")
|
||||
t.Fatal("Title is not a table.")
|
||||
}
|
||||
|
||||
if _, err := d.Table("chapter"); err != nil {
|
||||
|
|
@ -131,7 +131,7 @@ chapter:
|
|||
}
|
||||
|
||||
if _, err := d.Table("chapter.OneHundredThirtySix"); err == nil {
|
||||
t.Errorf("I think you mean 'Epilogue'")
|
||||
t.Error("I think you mean 'Epilogue'")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -150,13 +150,13 @@ func matchValues(t *testing.T, data map[string]any) {
|
|||
if o, err := ttpl("{{.mariner.shot}}", data); err != nil {
|
||||
t.Errorf(".mariner.shot: %s", err)
|
||||
} else if o != "ALBATROSS" {
|
||||
t.Errorf("Expected that mariner shot ALBATROSS")
|
||||
t.Error("Expected that mariner shot ALBATROSS")
|
||||
}
|
||||
|
||||
if o, err := ttpl("{{.water.water.where}}", data); err != nil {
|
||||
t.Errorf(".water.water.where: %s", err)
|
||||
} else if o != "everywhere" {
|
||||
t.Errorf("Expected water water everywhere")
|
||||
t.Error("Expected water water everywhere")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -199,7 +199,7 @@ chapter:
|
|||
}
|
||||
if v, err := d.PathValue("title"); err == nil {
|
||||
if v != "Moby Dick" {
|
||||
t.Errorf("Failed to return values for root key title")
|
||||
t.Error("Failed to return values for root key title")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ func TestInvalidYaml(t *testing.T) {
|
|||
t.Fatalf("All didn't fail with expected errors, got %#v", m)
|
||||
}
|
||||
if !strings.Contains(m[0].Err.Error(), "deliberateSyntaxError") {
|
||||
t.Errorf("All didn't have the error for deliberateSyntaxError")
|
||||
t.Error("All didn't have the error for deliberateSyntaxError")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ func TestInvalidChartYaml(t *testing.T) {
|
|||
t.Fatalf("All didn't fail with expected errors, got %#v", m)
|
||||
}
|
||||
if !strings.Contains(m[0].Err.Error(), "failed to strictly parse chart metadata file") {
|
||||
t.Errorf("All didn't have the error for duplicate YAML keys")
|
||||
t.Error("All didn't have the error for duplicate YAML keys")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -241,7 +241,7 @@ func TestMalformedTemplate(t *testing.T) {
|
|||
t.Fatalf("All didn't fail with expected errors, got %#v", m)
|
||||
}
|
||||
if !strings.Contains(m[0].Err.Error(), "invalid character '{'") {
|
||||
t.Errorf("All didn't have the error for invalid character '{'")
|
||||
t.Error("All didn't have the error for invalid character '{'")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,26 +50,26 @@ func TestValidateChartYamlNotDirectory(t *testing.T) {
|
|||
|
||||
err := validateChartYamlNotDirectory(nonExistingChartFilePath)
|
||||
if err == nil {
|
||||
t.Errorf("validateChartYamlNotDirectory to return a linter error, got no error")
|
||||
t.Error("validateChartYamlNotDirectory to return a linter error, got no error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateChartYamlFormat(t *testing.T) {
|
||||
err := validateChartYamlFormat(errors.New("Read error"))
|
||||
if err == nil {
|
||||
t.Errorf("validateChartYamlFormat to return a linter error, got no error")
|
||||
t.Error("validateChartYamlFormat to return a linter error, got no error")
|
||||
}
|
||||
|
||||
err = validateChartYamlFormat(nil)
|
||||
if err != nil {
|
||||
t.Errorf("validateChartYamlFormat to return no error, got a linter error")
|
||||
t.Error("validateChartYamlFormat to return no error, got a linter error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateChartName(t *testing.T) {
|
||||
err := validateChartName(badChart)
|
||||
if err == nil {
|
||||
t.Errorf("validateChartName to return a linter error, got no error")
|
||||
t.Error("validateChartName to return a linter error, got no error")
|
||||
}
|
||||
|
||||
err = validateChartName(badChartName)
|
||||
|
|
@ -176,7 +176,7 @@ func TestValidateChartMaintainer(t *testing.T) {
|
|||
badChart.Maintainers = []*chart.Maintainer{nil}
|
||||
err := validateChartMaintainer(badChart)
|
||||
if err == nil {
|
||||
t.Errorf("validateChartMaintainer did not return error for nil maintainer as expected")
|
||||
t.Error("validateChartMaintainer did not return error for nil maintainer as expected")
|
||||
}
|
||||
if err.Error() != "a maintainer entry is empty" {
|
||||
t.Errorf("validateChartMaintainer returned unexpected error for nil maintainer: %s", err.Error())
|
||||
|
|
@ -212,7 +212,7 @@ func TestValidateChartIconPresence(t *testing.T) {
|
|||
err := validateChartIconPresence(testChart)
|
||||
|
||||
if err == nil {
|
||||
t.Errorf("validateChartIconPresence to return a linter error, got no error")
|
||||
t.Error("validateChartIconPresence to return a linter error, got no error")
|
||||
} else if !strings.Contains(err.Error(), "icon is recommended") {
|
||||
t.Errorf("expected %q, got %q", "icon is recommended", err.Error())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ func TestValidateDependencyInMetadata(t *testing.T) {
|
|||
c := chartWithBadDependencies()
|
||||
|
||||
if err := validateDependencyInMetadata(&c); err == nil {
|
||||
t.Errorf("chart should have been flagged for missing deps in chart metadata")
|
||||
t.Error("chart should have been flagged for missing deps in chart metadata")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ func TestValidateDependenciesUnique(t *testing.T) {
|
|||
|
||||
for _, tt := range tests {
|
||||
if err := validateDependenciesUnique(&tt.chart); err == nil {
|
||||
t.Errorf("chart should have been flagged for dependency shadowing")
|
||||
t.Error("chart should have been flagged for dependency shadowing")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,6 @@ func TestValidateNoDeprecations(t *testing.T) {
|
|||
APIVersion: "v1",
|
||||
Kind: "Pod",
|
||||
}, nil); err != nil {
|
||||
t.Errorf("Expected a v1 Pod to not be deprecated")
|
||||
t.Error("Expected a v1 Pod to not be deprecated")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ func TestValidateValuesYamlNotDirectory(t *testing.T) {
|
|||
|
||||
err := validateValuesFileExistence(nonExistingValuesFilePath)
|
||||
if err == nil {
|
||||
t.Errorf("validateValuesFileExistence to return a linter error, got no error")
|
||||
t.Error("validateValuesFileExistence to return a linter error, got no error")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ func LoadFiles(files []*archive.BufferedFile) (*chart.Chart, error) {
|
|||
c.Metadata = new(chart.Metadata)
|
||||
}
|
||||
if c.Metadata.APIVersion != chart.APIVersionV1 {
|
||||
log.Printf("Warning: Dependencies are handled in Chart.yaml since apiVersion \"v2\". We recommend migrating dependencies to Chart.yaml.")
|
||||
log.Print("Warning: Dependencies are handled in Chart.yaml since apiVersion \"v2\". We recommend migrating dependencies to Chart.yaml.")
|
||||
}
|
||||
if err := yaml.Unmarshal(f.Data, c.Metadata); err != nil {
|
||||
return c, fmt.Errorf("cannot load requirements.yaml: %w", err)
|
||||
|
|
@ -138,7 +138,7 @@ func LoadFiles(files []*archive.BufferedFile) (*chart.Chart, error) {
|
|||
c.Metadata = new(chart.Metadata)
|
||||
}
|
||||
if c.Metadata.APIVersion != chart.APIVersionV1 {
|
||||
log.Printf("Warning: Dependency locking is handled in Chart.lock since apiVersion \"v2\". We recommend migrating to Chart.lock.")
|
||||
log.Print("Warning: Dependency locking is handled in Chart.lock since apiVersion \"v2\". We recommend migrating to Chart.lock.")
|
||||
}
|
||||
if c.Metadata.APIVersion == chart.APIVersionV1 {
|
||||
c.Files = append(c.Files, &common.File{Name: f.Name, ModTime: f.ModTime, Data: f.Data})
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ func TestLoadDirWithDevNull(t *testing.T) {
|
|||
t.Fatalf("Failed to load testdata: %s", err)
|
||||
}
|
||||
if _, err := l.Load(); err == nil {
|
||||
t.Errorf("packages with an irregular file (/dev/null) should not load")
|
||||
t.Error("packages with an irregular file (/dev/null) should not load")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,11 +60,11 @@ func verifyChartfile(t *testing.T, f *chart.Metadata, name string) {
|
|||
}
|
||||
|
||||
if f.Maintainers[0].Name != "The Helm Team" {
|
||||
t.Errorf("Unexpected maintainer name.")
|
||||
t.Error("Unexpected maintainer name.")
|
||||
}
|
||||
|
||||
if f.Maintainers[1].Email != "nobody@example.com" {
|
||||
t.Errorf("Unexpected maintainer email.")
|
||||
t.Error("Unexpected maintainer email.")
|
||||
}
|
||||
|
||||
if len(f.Sources) != 1 {
|
||||
|
|
@ -115,7 +115,7 @@ func TestIsChartDir(t *testing.T) {
|
|||
}
|
||||
validChartDir, err = IsChartDir("testdata")
|
||||
if validChartDir || err == nil {
|
||||
t.Errorf("expected error but did not get any")
|
||||
t.Error("expected error but did not get any")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ func TestCreate_Overwrite(t *testing.T) {
|
|||
}
|
||||
|
||||
if errlog.Len() == 0 {
|
||||
t.Errorf("Expected warnings about overwriting files.")
|
||||
t.Error("Expected warnings about overwriting files.")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ func TestReadFileOriginal(t *testing.T) {
|
|||
filePath := "%a.txt"
|
||||
_, err := readFile(filePath, p)
|
||||
if err == nil {
|
||||
t.Errorf("Expected error when has special strings")
|
||||
t.Error("Expected error when has special strings")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ compdef _helm %[1]s
|
|||
}
|
||||
|
||||
// Cobra doesn't source zsh completion file, explicitly doing it here
|
||||
fmt.Fprintf(out, "compdef _helm helm")
|
||||
fmt.Fprint(out, "compdef _helm helm")
|
||||
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ func (o *pluginInstallOptions) run(out io.Writer) error {
|
|||
if localInst, ok := i.(*installer.LocalInstaller); ok && !localInst.SupportsVerification() {
|
||||
// Local directory installations are allowed without verification
|
||||
shouldVerify = false
|
||||
fmt.Fprintf(out, "Installing plugin from local directory (development mode)\n")
|
||||
fmt.Fprint(out, "Installing plugin from local directory (development mode)\n")
|
||||
} else if shouldVerify {
|
||||
// For remote installations, check if verification is supported
|
||||
if verifier, ok := i.(installer.Verifier); !ok || !verifier.SupportsVerification() {
|
||||
|
|
@ -140,7 +140,7 @@ func (o *pluginInstallOptions) run(out io.Writer) error {
|
|||
}
|
||||
} else {
|
||||
// User explicitly disabled verification
|
||||
fmt.Fprintf(out, "WARNING: Skipping plugin signature verification\n")
|
||||
fmt.Fprint(out, "WARNING: Skipping plugin signature verification\n")
|
||||
}
|
||||
|
||||
// Set up installation options
|
||||
|
|
@ -151,7 +151,7 @@ func (o *pluginInstallOptions) run(out io.Writer) error {
|
|||
|
||||
// If verify is requested, show verification output
|
||||
if shouldVerify {
|
||||
fmt.Fprintf(out, "Verifying plugin signature...\n")
|
||||
fmt.Fprint(out, "Verifying plugin signature...\n")
|
||||
}
|
||||
|
||||
// Install the plugin with options
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ func (o *pluginPackageOptions) run(out io.Writer) error {
|
|||
}
|
||||
} else {
|
||||
// User explicitly disabled signing
|
||||
fmt.Fprintf(out, "WARNING: Skipping plugin signing. This is not recommended for plugins intended for distribution.\n")
|
||||
fmt.Fprint(out, "WARNING: Skipping plugin signing. This is not recommended for plugins intended for distribution.\n")
|
||||
}
|
||||
|
||||
// Now create the tarball (only after signing prerequisites are met)
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ func TestRepoAdd(t *testing.T) {
|
|||
}
|
||||
|
||||
if err := o.run(io.Discard); err != nil {
|
||||
t.Errorf("Duplicate repository name was added")
|
||||
t.Error("Duplicate repository name was added")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -162,7 +162,7 @@ func TestRepoAddCheckLegalName(t *testing.T) {
|
|||
t.Fatalf("Actual error %s, not equal to expected error %s", err, wantErrorMsg)
|
||||
}
|
||||
} else {
|
||||
t.Fatalf("expect reported an error.")
|
||||
t.Fatal("expect reported an error.")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ func newRollbackCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
return err
|
||||
}
|
||||
|
||||
fmt.Fprintf(out, "Rollback was a success! Happy Helming!\n")
|
||||
fmt.Fprint(out, "Rollback was a success! Happy Helming!\n")
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ func TestSearchHubCmd_FailOnNoResponseTests(t *testing.T) {
|
|||
_, out, err := executeActionCommandC(storage, tt.cmd)
|
||||
if tt.wantErr {
|
||||
if err == nil {
|
||||
t.Errorf("expected error due to no record in response, got nil")
|
||||
t.Error("expected error due to no record in response, got nil")
|
||||
}
|
||||
} else {
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -1466,7 +1466,7 @@ func TestTraceableError_SimpleForm(t *testing.T) {
|
|||
for _, errString := range testStrings {
|
||||
trace, done := parseTemplateSimpleErrorString(errString)
|
||||
if !done {
|
||||
t.Errorf("Expected parse to pass but did not")
|
||||
t.Error("Expected parse to pass but did not")
|
||||
}
|
||||
if trace.message != "error calling include" {
|
||||
t.Errorf("Expected %q, got %q", errString, trace.message)
|
||||
|
|
@ -1483,7 +1483,7 @@ func TestTraceableError_ExecutingForm(t *testing.T) {
|
|||
expectedLocation := errTuple[1]
|
||||
trace, done := parseTemplateExecutingAtErrorType(errString)
|
||||
if !done {
|
||||
t.Errorf("Expected parse to pass but did not")
|
||||
t.Error("Expected parse to pass but did not")
|
||||
}
|
||||
if trace.location != expectedLocation {
|
||||
t.Errorf("Expected %q, got %q", expectedLocation, trace.location)
|
||||
|
|
@ -1498,7 +1498,7 @@ func TestTraceableError_NoTemplateForm(t *testing.T) {
|
|||
for _, errString := range testStrings {
|
||||
trace, done := parseTemplateNoTemplateError(errString, errString)
|
||||
if !done {
|
||||
t.Errorf("Expected parse to pass but did not")
|
||||
t.Error("Expected parse to pass but did not")
|
||||
}
|
||||
if trace.message != errString {
|
||||
t.Errorf("Expected %q, got %q", errString, trace.message)
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@ func TestLegacyWaiter_waitForPodSuccess(t *testing.T) {
|
|||
done, err := lw.waitForPodSuccess(tt.obj, "foo")
|
||||
if tt.wantErr {
|
||||
if err == nil {
|
||||
t.Errorf("expected error, got none")
|
||||
t.Error("expected error, got none")
|
||||
} else if !strings.Contains(err.Error(), tt.errMessage) {
|
||||
t.Errorf("expected error to contain %q, got %q", tt.errMessage, err.Error())
|
||||
}
|
||||
|
|
@ -391,7 +391,7 @@ func TestLegacyWaiter_waitForJob(t *testing.T) {
|
|||
done, err := lw.waitForJob(tt.obj, "test-job")
|
||||
if tt.wantErr {
|
||||
if err == nil {
|
||||
t.Errorf("expected error, got none")
|
||||
t.Error("expected error, got none")
|
||||
} else if !strings.Contains(err.Error(), tt.errMessage) {
|
||||
t.Errorf("expected error to contain %q, got %q", tt.errMessage, err.Error())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ func TestParseMessageBlock(t *testing.T) {
|
|||
}
|
||||
|
||||
if hash, ok := sc.Files["hashtest-1.2.3.tgz"]; !ok {
|
||||
t.Errorf("hashtest file not found in Files")
|
||||
t.Error("hashtest file not found in Files")
|
||||
} else if hash != "sha256:c6841b3a895f1444a6738b5d04564a57e860ce42f8519c3be807fb6d9bee7888" {
|
||||
t.Errorf("Unexpected hash: %q", hash)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ func TestLogin_ResetsForceAttemptOAuth2_OnSuccess(t *testing.T) {
|
|||
}
|
||||
|
||||
if c.authorizer.ForceAttemptOAuth2 {
|
||||
t.Errorf("ForceAttemptOAuth2 should be false after successful Login")
|
||||
t.Error("ForceAttemptOAuth2 should be false after successful Login")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ func TestLogin_ResetsForceAttemptOAuth2_OnFailure(t *testing.T) {
|
|||
_ = c.Login(host, LoginOptPlainText(true), LoginOptBasicAuth("u", "p"))
|
||||
|
||||
if c.authorizer.ForceAttemptOAuth2 {
|
||||
t.Errorf("ForceAttemptOAuth2 should be false after failed Login")
|
||||
t.Error("ForceAttemptOAuth2 should be false after failed Login")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ func TestGetPluginName(t *testing.T) {
|
|||
|
||||
if tt.expectErr {
|
||||
if err == nil {
|
||||
t.Errorf("expected error but got none")
|
||||
t.Error("expected error but got none")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ func TestIndexCustomSchemeDownload(t *testing.T) {
|
|||
}
|
||||
|
||||
if len(myCustomGetter.repoUrls) != 1 {
|
||||
t.Fatalf("Custom Getter.Get should be called once")
|
||||
t.Fatal("Custom Getter.Get should be called once")
|
||||
}
|
||||
|
||||
expectedRepoIndexURL := repoURL + "/index.yaml"
|
||||
|
|
@ -240,7 +240,7 @@ func TestErrorFindChartInRepoURL(t *testing.T) {
|
|||
})
|
||||
|
||||
if _, err := FindChartInRepoURL("http://someserver/something", "nginx", g); err == nil {
|
||||
t.Errorf("Expected error for bad chart URL, but did not get any errors")
|
||||
t.Error("Expected error for bad chart URL, but did not get any errors")
|
||||
} else if !strings.Contains(err.Error(), `looks like "http://someserver/something" is not a valid chart repository or cannot be reached`) {
|
||||
t.Errorf("Expected error for bad chart URL, but got a different error (%v)", err)
|
||||
}
|
||||
|
|
@ -252,22 +252,22 @@ func TestErrorFindChartInRepoURL(t *testing.T) {
|
|||
defer srv.Close()
|
||||
|
||||
if _, err = FindChartInRepoURL(srv.URL, "nginx1", g); err == nil {
|
||||
t.Errorf("Expected error for chart not found, but did not get any errors")
|
||||
t.Error("Expected error for chart not found, but did not get any errors")
|
||||
} else if err.Error() != `chart "nginx1" not found in `+srv.URL+` repository` {
|
||||
t.Errorf("Expected error for chart not found, but got a different error (%v)", err)
|
||||
}
|
||||
if !errors.Is(err, ChartNotFoundError{}) {
|
||||
t.Errorf("error is not of correct error type structure")
|
||||
t.Error("error is not of correct error type structure")
|
||||
}
|
||||
|
||||
if _, err = FindChartInRepoURL(srv.URL, "nginx1", g, WithChartVersion("0.1.0")); err == nil {
|
||||
t.Errorf("Expected error for chart not found, but did not get any errors")
|
||||
t.Error("Expected error for chart not found, but did not get any errors")
|
||||
} else if err.Error() != `chart "nginx1" version "0.1.0" not found in `+srv.URL+` repository` {
|
||||
t.Errorf("Expected error for chart not found, but got a different error (%v)", err)
|
||||
}
|
||||
|
||||
if _, err = FindChartInRepoURL(srv.URL, "chartWithNoURL", g); err == nil {
|
||||
t.Errorf("Expected error for no chart URLs available, but did not get any errors")
|
||||
t.Error("Expected error for no chart URLs available, but did not get any errors")
|
||||
} else if err.Error() != `chart "chartWithNoURL" has no downloadable URLs` {
|
||||
t.Errorf("Expected error for chart not found, but got a different error (%v)", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,12 +130,12 @@ func TestIndexFile(t *testing.T) {
|
|||
|
||||
cv, err = i.Get("setter", "0.1.9+alpha")
|
||||
if err != nil || cv.Version != "0.1.9+alpha" {
|
||||
t.Errorf("Expected version: 0.1.9+alpha")
|
||||
t.Error("Expected version: 0.1.9+alpha")
|
||||
}
|
||||
|
||||
cv, err = i.Get("setter", "0.1.8")
|
||||
if err != nil || cv.Version != "0.1.8" {
|
||||
t.Errorf("Expected version: 0.1.8")
|
||||
t.Error("Expected version: 0.1.8")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -174,7 +174,7 @@ func TestLoadIndex(t *testing.T) {
|
|||
// TestLoadIndex_Duplicates is a regression to make sure that we don't non-deterministically allow duplicate packages.
|
||||
func TestLoadIndex_Duplicates(t *testing.T) {
|
||||
if _, err := loadIndex([]byte(indexWithDuplicates), "indexWithDuplicates"); err == nil {
|
||||
t.Errorf("Expected an error when duplicate entries are present")
|
||||
t.Error("Expected an error when duplicate entries are present")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -186,7 +186,7 @@ func TestLoadIndex_EmptyEntry(t *testing.T) {
|
|||
|
||||
func TestLoadIndex_Empty(t *testing.T) {
|
||||
if _, err := loadIndex([]byte(""), "indexWithEmpty"); err == nil {
|
||||
t.Errorf("Expected an error when index.yaml is empty.")
|
||||
t.Error("Expected an error when index.yaml is empty.")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -360,7 +360,7 @@ func verifyLocalIndex(t *testing.T, i *IndexFile) {
|
|||
|
||||
alpine, ok := i.Entries["alpine"]
|
||||
if !ok {
|
||||
t.Fatalf("'alpine' section not found.")
|
||||
t.Fatal("'alpine' section not found.")
|
||||
}
|
||||
|
||||
if l := len(alpine); l != 1 {
|
||||
|
|
@ -595,7 +595,7 @@ func TestAddFileIndexEntriesNil(t *testing.T) {
|
|||
{&chart.Metadata{APIVersion: "v2", Name: " ", Version: "8033-5.apinie+s.r"}, "setter-0.1.9+beta.tgz", "http://example.com/charts", "sha256:1234567890abc"},
|
||||
} {
|
||||
if err := i.MustAdd(x.md, x.filename, x.baseURL, x.digest); err == nil {
|
||||
t.Errorf("expected err to be non-nil when entries not initialized")
|
||||
t.Error("expected err to be non-nil when entries not initialized")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -219,9 +219,9 @@ func TestWriteFile(t *testing.T) {
|
|||
|
||||
func TestRepoNotExists(t *testing.T) {
|
||||
if _, err := LoadFile("/this/path/does/not/exist.yaml"); err == nil {
|
||||
t.Errorf("expected err to be non-nil when path does not exist")
|
||||
t.Error("expected err to be non-nil when path does not exist")
|
||||
} else if !strings.Contains(err.Error(), "couldn't load repositories file") {
|
||||
t.Errorf("expected prompt `couldn't load repositories file`")
|
||||
t.Error("expected prompt `couldn't load repositories file`")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ func TestMemoryDelete(t *testing.T) {
|
|||
}
|
||||
_, err = ts.Get(tt.key)
|
||||
if err == nil {
|
||||
t.Errorf("Expected an error when asking for a deleted key")
|
||||
t.Error("Expected an error when asking for a deleted key")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -589,7 +589,7 @@ func TestStorageGetsLoggerFromDriver(t *testing.T) {
|
|||
s := Init(d)
|
||||
_, _ = s.Get("doesnt-matter", 123)
|
||||
if !l.Called {
|
||||
t.Fatalf("Expected storage to use driver's logger, but it did not")
|
||||
t.Fatal("Expected storage to use driver's logger, but it did not")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue