chore: raise go directive to 1.27 and fix modernize findings (#32810)
Dependabot bumps that pull in a dependency requiring Go 1.27 (#32786, #32755) raise the go directive in go.mod, which in turn activates the modernize analyzer's embedlit and stringscut checks. Those checks then fire on pre-existing code and fail golangci-lint, so every such bump is blocked on a cleanup it does not own. Do the cleanup once, here, together with the directive bump that makes it legal: neither fix compiles at go 1.26.0 (promoted-field keys in composite literals and strings.CutLast are both Go 1.27). Changes are the modernize autofix, reviewed: - embedlit: drop the embedded field type from struct literals, mostly ObjectMeta/TypeMeta in tests, plus a few in production code. - stringscut: parseTemplateSimpleErrorString now uses strings.CutLast instead of strings.LastIndex with manual slicing. CI already builds with Go 1.27 (GOLANG_VERSION in .github/env), so this only aligns the module's declared language version with the toolchain. Signed-off-by: Terry Howe <thowe@nvidia.com>
This commit is contained in:
1 parent
86612766c6
commit
818fd2e734
29 files changed
+150
-218
No files matched your search
@@ -1,6 +1,6 @@
|
||||
module helm.sh/helm/v4
|
||||
|
||||
go 1.26.0
|
||||
go 1.27.0
|
||||
|
||||
require (
|
||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24
|
||||
|
||||
@@ -26,7 +26,6 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
batchv1 "k8s.io/api/batch/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
||||
@@ -58,9 +57,7 @@ func TestJobConditions(t *testing.T) {
|
||||
{
|
||||
name: "job without Complete condition returns InProgress status",
|
||||
job: &batchv1.Job{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "job-no-condition",
|
||||
},
|
||||
Name: "job-no-condition",
|
||||
Spec: batchv1.JobSpec{},
|
||||
Status: batchv1.JobStatus{},
|
||||
},
|
||||
@@ -69,9 +66,7 @@ func TestJobConditions(t *testing.T) {
|
||||
{
|
||||
name: "job with Complete condition as True returns Current status",
|
||||
job: &batchv1.Job{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "job-complete",
|
||||
},
|
||||
Name: "job-complete",
|
||||
Spec: batchv1.JobSpec{},
|
||||
Status: batchv1.JobStatus{
|
||||
Conditions: []batchv1.JobCondition{
|
||||
@@ -87,9 +82,7 @@ func TestJobConditions(t *testing.T) {
|
||||
{
|
||||
name: "job with Failed condition as True returns Failed status",
|
||||
job: &batchv1.Job{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "job-failed",
|
||||
},
|
||||
Name: "job-failed",
|
||||
Spec: batchv1.JobSpec{},
|
||||
Status: batchv1.JobStatus{
|
||||
Conditions: []batchv1.JobCondition{
|
||||
|
||||
@@ -22,7 +22,6 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fluxcd/cli-utils/pkg/kstatus/status"
|
||||
)
|
||||
@@ -36,17 +35,17 @@ func TestPodConditions(t *testing.T) {
|
||||
{
|
||||
name: "pod without status returns in progress",
|
||||
pod: &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pod-no-status"},
|
||||
Spec: v1.PodSpec{},
|
||||
Status: v1.PodStatus{},
|
||||
Name: "pod-no-status",
|
||||
Spec: v1.PodSpec{},
|
||||
Status: v1.PodStatus{},
|
||||
},
|
||||
expectedStatus: status.InProgressStatus,
|
||||
},
|
||||
{
|
||||
name: "pod succeeded returns current status",
|
||||
pod: &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pod-succeeded"},
|
||||
Spec: v1.PodSpec{},
|
||||
Name: "pod-succeeded",
|
||||
Spec: v1.PodSpec{},
|
||||
Status: v1.PodStatus{
|
||||
Phase: v1.PodSucceeded,
|
||||
},
|
||||
@@ -56,8 +55,8 @@ func TestPodConditions(t *testing.T) {
|
||||
{
|
||||
name: "pod failed returns failed status",
|
||||
pod: &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pod-failed"},
|
||||
Spec: v1.PodSpec{},
|
||||
Name: "pod-failed",
|
||||
Spec: v1.PodSpec{},
|
||||
Status: v1.PodStatus{
|
||||
Phase: v1.PodFailed,
|
||||
},
|
||||
@@ -67,8 +66,8 @@ func TestPodConditions(t *testing.T) {
|
||||
{
|
||||
name: "pod pending returns in progress status",
|
||||
pod: &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pod-pending"},
|
||||
Spec: v1.PodSpec{},
|
||||
Name: "pod-pending",
|
||||
Spec: v1.PodSpec{},
|
||||
Status: v1.PodStatus{
|
||||
Phase: v1.PodPending,
|
||||
},
|
||||
@@ -78,8 +77,8 @@ func TestPodConditions(t *testing.T) {
|
||||
{
|
||||
name: "pod running returns in progress status",
|
||||
pod: &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pod-running"},
|
||||
Spec: v1.PodSpec{},
|
||||
Name: "pod-running",
|
||||
Spec: v1.PodSpec{},
|
||||
Status: v1.PodStatus{
|
||||
Phase: v1.PodRunning,
|
||||
},
|
||||
@@ -89,8 +88,8 @@ func TestPodConditions(t *testing.T) {
|
||||
{
|
||||
name: "pod with unknown phase returns in progress status",
|
||||
pod: &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pod-unknown"},
|
||||
Spec: v1.PodSpec{},
|
||||
Name: "pod-unknown",
|
||||
Spec: v1.PodSpec{},
|
||||
Status: v1.PodStatus{
|
||||
Phase: v1.PodUnknown,
|
||||
},
|
||||
|
||||
@@ -281,10 +281,8 @@ func newConfigMapsObject(key string, rls *rspb.Release, lbs labels) (*v1.ConfigM
|
||||
|
||||
// create and return configmap object
|
||||
return &v1.ConfigMap{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: key,
|
||||
Labels: lbs.toMap(),
|
||||
},
|
||||
Data: map[string]string{"release": s},
|
||||
Name: key,
|
||||
Labels: lbs.toMap(),
|
||||
Data: map[string]string{"release": s},
|
||||
}, nil
|
||||
}
|
||||
@@ -277,11 +277,9 @@ func newSecretsObject(key string, rls *rspb.Release, lbs labels) (*v1.Secret, er
|
||||
// This would potentially be a breaking change
|
||||
// and should only happen between major versions.
|
||||
return &v1.Secret{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: key,
|
||||
Labels: lbs.toMap(),
|
||||
},
|
||||
Type: "helm.sh/release.v2",
|
||||
Data: map[string][]byte{"release": []byte(s)},
|
||||
Name: key,
|
||||
Labels: lbs.toMap(),
|
||||
Type: "helm.sh/release.v2",
|
||||
Data: map[string][]byte{"release": []byte(s)},
|
||||
}, nil
|
||||
}
|
||||
@@ -62,7 +62,7 @@ func actionConfigFixtureWithDummyResources(t *testing.T, dummyResources kube.Res
|
||||
|
||||
return &Configuration{
|
||||
Releases: storage.Init(driver.NewMemory()),
|
||||
KubeClient: &kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}, DummyResources: dummyResources},
|
||||
KubeClient: &kubefake.FailingKubeClient{Out: io.Discard, DummyResources: dummyResources},
|
||||
Capabilities: common.DefaultCapabilities,
|
||||
RegistryClient: registryClient,
|
||||
}
|
||||
|
||||
@@ -435,7 +435,7 @@ func TestGetMetadata_Run_DifferentStatuses(t *testing.T) {
|
||||
|
||||
func TestGetMetadata_Run_UnreachableKubeClient(t *testing.T) {
|
||||
cfg := actionConfigFixture(t)
|
||||
failingKubeClient := kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}, DummyResources: nil}
|
||||
failingKubeClient := kubefake.FailingKubeClient{Out: io.Discard, DummyResources: nil}
|
||||
failingKubeClient.ConnectionError = errors.New("connection refused")
|
||||
cfg.KubeClient = &failingKubeClient
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ func TestGetRun(t *testing.T) {
|
||||
|
||||
func TestGetRun_UnreachableKubeClient(t *testing.T) {
|
||||
config := actionConfigFixture(t)
|
||||
failingKubeClient := kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}, DummyResources: nil}
|
||||
failingKubeClient := kubefake.FailingKubeClient{Out: io.Discard, DummyResources: nil}
|
||||
failingKubeClient.ConnectionError = errors.New("connection refused")
|
||||
config.KubeClient = &failingKubeClient
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ func TestGetValues_Run_EmptyValues(t *testing.T) {
|
||||
|
||||
func TestGetValues_Run_UnreachableKubeClient(t *testing.T) {
|
||||
cfg := actionConfigFixture(t)
|
||||
failingKubeClient := kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}, DummyResources: nil}
|
||||
failingKubeClient := kubefake.FailingKubeClient{Out: io.Discard, DummyResources: nil}
|
||||
failingKubeClient.ConnectionError = errors.New("connection refused")
|
||||
cfg.KubeClient = &failingKubeClient
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ func TestHistoryRun(t *testing.T) {
|
||||
|
||||
func TestHistoryRun_UnreachableKubeClient(t *testing.T) {
|
||||
config := actionConfigFixture(t)
|
||||
failingKubeClient := kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}, DummyResources: nil}
|
||||
failingKubeClient := kubefake.FailingKubeClient{Out: io.Discard, DummyResources: nil}
|
||||
failingKubeClient.ConnectionError = errors.New("connection refused")
|
||||
config.KubeClient = &failingKubeClient
|
||||
|
||||
|
||||
@@ -451,7 +451,7 @@ func TestExecHook_WaitOptionsPassedDownstream(t *testing.T) {
|
||||
req := require.New(t)
|
||||
|
||||
failer := &kubefake.FailingKubeClient{
|
||||
PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard},
|
||||
Out: io.Discard,
|
||||
}
|
||||
|
||||
configuration := &Configuration{
|
||||
|
||||
+5
-10
@@ -37,7 +37,6 @@ import (
|
||||
v1 "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/cli-runtime/pkg/resource"
|
||||
"sigs.k8s.io/yaml"
|
||||
|
||||
@@ -438,15 +437,11 @@ func (i *Install) RunWithContext(ctx context.Context, ch ci.Charter, vals map[st
|
||||
|
||||
if i.CreateNamespace {
|
||||
ns := &v1.Namespace{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: "v1",
|
||||
Kind: "Namespace",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: i.Namespace,
|
||||
Labels: map[string]string{
|
||||
"name": i.Namespace,
|
||||
},
|
||||
APIVersion: "v1",
|
||||
Kind: "Namespace",
|
||||
Name: i.Namespace,
|
||||
Labels: map[string]string{
|
||||
"name": i.Namespace,
|
||||
},
|
||||
}
|
||||
buf, err := yaml.Marshal(ns)
|
||||
|
||||
+10
-14
@@ -65,10 +65,8 @@ type nameTemplateTestCase struct {
|
||||
|
||||
func createDummyResourceList(owned bool) kube.ResourceList {
|
||||
obj := &appsv1.Deployment{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "dummyName",
|
||||
Namespace: "spaced",
|
||||
},
|
||||
Name: "dummyName",
|
||||
Namespace: "spaced",
|
||||
}
|
||||
|
||||
if owned {
|
||||
@@ -113,10 +111,8 @@ func createDummyResourceList(owned bool) kube.ResourceList {
|
||||
|
||||
func createDummyCRDList(owned bool) kube.ResourceList {
|
||||
obj := &appsv1.Deployment{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "dummyName",
|
||||
Namespace: "spaced",
|
||||
},
|
||||
Name: "dummyName",
|
||||
Namespace: "spaced",
|
||||
}
|
||||
|
||||
if owned {
|
||||
@@ -1067,7 +1063,7 @@ func TestUrlEqual(t *testing.T) {
|
||||
|
||||
func TestInstallRun_UnreachableKubeClient(t *testing.T) {
|
||||
config := actionConfigFixture(t)
|
||||
failingKubeClient := kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}, DummyResources: nil}
|
||||
failingKubeClient := kubefake.FailingKubeClient{Out: io.Discard, DummyResources: nil}
|
||||
failingKubeClient.ConnectionError = errors.New("connection refused")
|
||||
config.KubeClient = &failingKubeClient
|
||||
|
||||
@@ -1109,7 +1105,7 @@ func TestInstallCRDs(t *testing.T) {
|
||||
|
||||
func TestInstallCRDs_AlreadyExist(t *testing.T) {
|
||||
dummyResources := createDummyCRDList(false)
|
||||
failingKubeClient := kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}, DummyResources: dummyResources}
|
||||
failingKubeClient := kubefake.FailingKubeClient{Out: io.Discard, DummyResources: dummyResources}
|
||||
mockError := &apierrors.StatusError{ErrStatus: metav1.Status{
|
||||
Status: metav1.StatusFailure,
|
||||
Reason: metav1.StatusReasonAlreadyExists,
|
||||
@@ -1132,7 +1128,7 @@ func TestInstallCRDs_AlreadyExist(t *testing.T) {
|
||||
|
||||
func TestInstallCRDs_KubeClient_BuildError(t *testing.T) {
|
||||
config := actionConfigFixture(t)
|
||||
failingKubeClient := kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}, DummyResources: nil}
|
||||
failingKubeClient := kubefake.FailingKubeClient{Out: io.Discard, DummyResources: nil}
|
||||
failingKubeClient.BuildError = errors.New("build error")
|
||||
config.KubeClient = &failingKubeClient
|
||||
instAction := NewInstall(config)
|
||||
@@ -1149,7 +1145,7 @@ func TestInstallCRDs_KubeClient_BuildError(t *testing.T) {
|
||||
|
||||
func TestInstallCRDs_KubeClient_CreateError(t *testing.T) {
|
||||
config := actionConfigFixture(t)
|
||||
failingKubeClient := kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}, DummyResources: nil}
|
||||
failingKubeClient := kubefake.FailingKubeClient{Out: io.Discard, DummyResources: nil}
|
||||
failingKubeClient.CreateError = errors.New("create error")
|
||||
config.KubeClient = &failingKubeClient
|
||||
instAction := NewInstall(config)
|
||||
@@ -1166,7 +1162,7 @@ func TestInstallCRDs_KubeClient_CreateError(t *testing.T) {
|
||||
|
||||
func TestInstallCRDs_WaiterError(t *testing.T) {
|
||||
config := actionConfigFixture(t)
|
||||
failingKubeClient := kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}, DummyResources: nil}
|
||||
failingKubeClient := kubefake.FailingKubeClient{Out: io.Discard, DummyResources: nil}
|
||||
failingKubeClient.WaitError = errors.New("wait error")
|
||||
failingKubeClient.BuildDummy = true
|
||||
config.KubeClient = &failingKubeClient
|
||||
@@ -1188,7 +1184,7 @@ func TestInstallCRDs_WaiterError(t *testing.T) {
|
||||
// StatusWatcherStrategy waiter for CRD establishment instead.
|
||||
func TestInstallCRDs_HookOnlyStrategyStillWaitsForEstablishment(t *testing.T) {
|
||||
config := actionConfigFixture(t)
|
||||
failingKubeClient := kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}, BuildDummy: true}
|
||||
failingKubeClient := kubefake.FailingKubeClient{Out: io.Discard, BuildDummy: true}
|
||||
config.KubeClient = &failingKubeClient
|
||||
instAction := NewInstall(config)
|
||||
instAction.WaitStrategy = kube.HookOnlyStrategy
|
||||
|
||||
@@ -410,7 +410,7 @@ func TestSelectorList(t *testing.T) {
|
||||
|
||||
func TestListRun_UnreachableKubeClient(t *testing.T) {
|
||||
config := actionConfigFixture(t)
|
||||
failingKubeClient := kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}, DummyResources: nil}
|
||||
failingKubeClient := kubefake.FailingKubeClient{Out: io.Discard, DummyResources: nil}
|
||||
failingKubeClient.ConnectionError = errors.New("connection refused")
|
||||
config.KubeClient = &failingKubeClient
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
fakeclientset "k8s.io/client-go/kubernetes/fake"
|
||||
|
||||
"helm.sh/helm/v4/pkg/cli"
|
||||
@@ -46,7 +45,7 @@ func TestNewReleaseTesting(t *testing.T) {
|
||||
|
||||
func TestReleaseTestingRun_UnreachableKubeClient(t *testing.T) {
|
||||
config := actionConfigFixture(t)
|
||||
failingKubeClient := kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}, DummyResources: nil}
|
||||
failingKubeClient := kubefake.FailingKubeClient{Out: io.Discard, DummyResources: nil}
|
||||
failingKubeClient.ConnectionError = errors.New("connection refused")
|
||||
config.KubeClient = &failingKubeClient
|
||||
|
||||
@@ -174,10 +173,8 @@ func TestReleaseTesting_WaitOptionsPassedDownstream(t *testing.T) {
|
||||
|
||||
func TestGetContainerLogs_MultipleContainers(t *testing.T) {
|
||||
pod := &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test-pod",
|
||||
Namespace: "default",
|
||||
},
|
||||
Name: "test-pod",
|
||||
Namespace: "default",
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{
|
||||
{Name: "main"},
|
||||
@@ -198,10 +195,8 @@ func TestGetContainerLogs_MultipleContainers(t *testing.T) {
|
||||
|
||||
func TestGetContainerLogs_WithInitContainers(t *testing.T) {
|
||||
pod := &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test-pod",
|
||||
Namespace: "default",
|
||||
},
|
||||
Name: "test-pod",
|
||||
Namespace: "default",
|
||||
Spec: v1.PodSpec{
|
||||
InitContainers: []v1.Container{
|
||||
{Name: "init-setup"},
|
||||
@@ -233,10 +228,8 @@ func TestGetContainerLogs_PodNotFound(t *testing.T) {
|
||||
|
||||
func TestGetContainerLogs_OutputHeaderFormat(t *testing.T) {
|
||||
pod := &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "multi-test",
|
||||
Namespace: "default",
|
||||
},
|
||||
Name: "multi-test",
|
||||
Namespace: "default",
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{
|
||||
{Name: "container-a"},
|
||||
|
||||
@@ -52,7 +52,7 @@ func TestNewRollback(t *testing.T) {
|
||||
|
||||
func TestRollbackRun_UnreachableKubeClient(t *testing.T) {
|
||||
config := actionConfigFixture(t)
|
||||
failingKubeClient := kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}, DummyResources: nil}
|
||||
failingKubeClient := kubefake.FailingKubeClient{Out: io.Discard, DummyResources: nil}
|
||||
failingKubeClient.ConnectionError = errors.New("connection refused")
|
||||
config.KubeClient = &failingKubeClient
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func TestNewStatus(t *testing.T) {
|
||||
|
||||
func TestStatusRun(t *testing.T) {
|
||||
config := actionConfigFixture(t)
|
||||
failingKubeClient := kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}, DummyResources: nil}
|
||||
failingKubeClient := kubefake.FailingKubeClient{Out: io.Discard, DummyResources: nil}
|
||||
failingKubeClient.BuildDummy = true
|
||||
config.KubeClient = &failingKubeClient
|
||||
client := NewStatus(config)
|
||||
@@ -59,7 +59,7 @@ func TestStatusRun(t *testing.T) {
|
||||
|
||||
func TestStatusRun_KubeClientNotReachable(t *testing.T) {
|
||||
config := actionConfigFixture(t)
|
||||
failingKubeClient := kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}, DummyResources: nil}
|
||||
failingKubeClient := kubefake.FailingKubeClient{Out: io.Discard, DummyResources: nil}
|
||||
failingKubeClient.ConnectionError = errors.New("connection refused")
|
||||
config.KubeClient = &failingKubeClient
|
||||
|
||||
@@ -72,7 +72,7 @@ func TestStatusRun_KubeClientNotReachable(t *testing.T) {
|
||||
|
||||
func TestStatusRun_KubeClientBuildTableError(t *testing.T) {
|
||||
config := actionConfigFixture(t)
|
||||
failingKubeClient := kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}, DummyResources: nil}
|
||||
failingKubeClient := kubefake.FailingKubeClient{Out: io.Discard, DummyResources: nil}
|
||||
failingKubeClient.BuildTableError = errors.New("build table error")
|
||||
config.KubeClient = &failingKubeClient
|
||||
|
||||
@@ -90,7 +90,7 @@ func TestStatusRun_KubeClientBuildTableError(t *testing.T) {
|
||||
|
||||
func TestStatusRun_KubeClientBuildError(t *testing.T) {
|
||||
config := actionConfigFixture(t)
|
||||
failingKubeClient := kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}, DummyResources: nil}
|
||||
failingKubeClient := kubefake.FailingKubeClient{Out: io.Discard, DummyResources: nil}
|
||||
failingKubeClient.BuildError = errors.New("build error")
|
||||
config.KubeClient = &failingKubeClient
|
||||
|
||||
@@ -107,7 +107,7 @@ func TestStatusRun_KubeClientBuildError(t *testing.T) {
|
||||
|
||||
func TestStatusRun_KubeClientGetError(t *testing.T) {
|
||||
config := actionConfigFixture(t)
|
||||
failingKubeClient := kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}, DummyResources: nil}
|
||||
failingKubeClient := kubefake.FailingKubeClient{Out: io.Discard, DummyResources: nil}
|
||||
failingKubeClient.BuildError = errors.New("get error")
|
||||
config.KubeClient = &failingKubeClient
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ func TestUninstallRelease_Cascade(t *testing.T) {
|
||||
func TestUninstallRun_UnreachableKubeClient(t *testing.T) {
|
||||
t.Helper()
|
||||
config := actionConfigFixture(t)
|
||||
failingKubeClient := kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}, DummyResources: nil}
|
||||
failingKubeClient := kubefake.FailingKubeClient{Out: io.Discard, DummyResources: nil}
|
||||
failingKubeClient.ConnectionError = errors.New("connection refused")
|
||||
config.KubeClient = &failingKubeClient
|
||||
|
||||
|
||||
@@ -727,7 +727,7 @@ func TestGetUpgradeServerSideValue(t *testing.T) {
|
||||
func TestUpgradeRun_UnreachableKubeClient(t *testing.T) {
|
||||
t.Helper()
|
||||
config := actionConfigFixture(t)
|
||||
failingKubeClient := kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}, DummyResources: nil}
|
||||
failingKubeClient := kubefake.FailingKubeClient{Out: io.Discard, DummyResources: nil}
|
||||
failingKubeClient.ConnectionError = errors.New("connection refused")
|
||||
config.KubeClient = &failingKubeClient
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import (
|
||||
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/cli-runtime/pkg/resource"
|
||||
@@ -45,11 +44,9 @@ func newDeploymentResource(name, namespace, generateName string) *resource.Info
|
||||
GroupVersionKind: schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "Deployment"},
|
||||
},
|
||||
Object: &appsv1.Deployment{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
GenerateName: generateName,
|
||||
},
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
GenerateName: generateName,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -64,10 +61,8 @@ func newMissingDeployment(name, namespace string) *resource.Info {
|
||||
Scope: meta.RESTScopeNamespace,
|
||||
},
|
||||
Object: &appsv1.Deployment{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
},
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
},
|
||||
Client: fakeClientWith(http.StatusNotFound, appsV1GV, ""),
|
||||
}
|
||||
@@ -77,12 +72,10 @@ func newMissingDeployment(name, namespace string) *resource.Info {
|
||||
|
||||
func newDeploymentWithOwner(name, namespace string, labels, annotations map[string]string) *resource.Info {
|
||||
obj := &appsv1.Deployment{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
Labels: labels,
|
||||
Annotations: annotations,
|
||||
},
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
Labels: labels,
|
||||
Annotations: annotations,
|
||||
}
|
||||
return &resource.Info{
|
||||
Name: name,
|
||||
|
||||
@@ -62,7 +62,7 @@ func TestReleaseTestNotesHandling(t *testing.T) {
|
||||
// Set up action configuration properly
|
||||
actionConfig := &action.Configuration{
|
||||
Releases: store,
|
||||
KubeClient: &kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}},
|
||||
KubeClient: &kubefake.FailingKubeClient{Out: io.Discard},
|
||||
Capabilities: common.DefaultCapabilities,
|
||||
}
|
||||
|
||||
|
||||
@@ -438,9 +438,7 @@ func parseTemplateNoTemplateError(s, remainder string) (TraceableError, bool) {
|
||||
// Use LastIndex to avoid splitting colons within line:col info.
|
||||
// Matches https://cs.opensource.google/go/go/+/refs/tags/go1.23.6:src/text/template/exec.go;l=138
|
||||
func parseTemplateSimpleErrorString(remainder string) (TraceableError, bool) {
|
||||
if sep := strings.LastIndex(remainder, ": "); sep != -1 {
|
||||
templateName := remainder[:sep]
|
||||
errMsg := remainder[sep+2:]
|
||||
if templateName, errMsg, found := strings.CutLast(remainder, ": "); found {
|
||||
if cut := strings.Index(errMsg, " template:"); cut != -1 {
|
||||
errMsg = errMsg[:cut]
|
||||
}
|
||||
|
||||
@@ -76,10 +76,8 @@ func newPodWithStatus(name string, status v1.PodStatus, namespace string) v1.Pod
|
||||
ns = namespace
|
||||
}
|
||||
return v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: ns,
|
||||
},
|
||||
Name: name,
|
||||
Namespace: ns,
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{{
|
||||
Name: "app:v4",
|
||||
|
||||
+34
-56
@@ -1309,11 +1309,9 @@ func newDaemonSet(name string, maxUnavailable, numberReady, desiredNumberSchedul
|
||||
generation = 2
|
||||
}
|
||||
return &appsv1.DaemonSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: defaultNamespace,
|
||||
Generation: generation,
|
||||
},
|
||||
Name: name,
|
||||
Namespace: defaultNamespace,
|
||||
Generation: generation,
|
||||
Spec: appsv1.DaemonSetSpec{
|
||||
UpdateStrategy: appsv1.DaemonSetUpdateStrategy{
|
||||
Type: appsv1.RollingUpdateDaemonSetStrategyType,
|
||||
@@ -1351,11 +1349,9 @@ func newStatefulSet(name string, replicas, partition, readyReplicas, updatedRepl
|
||||
generation = 2
|
||||
}
|
||||
return &appsv1.StatefulSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: defaultNamespace,
|
||||
Generation: generation,
|
||||
},
|
||||
Name: name,
|
||||
Namespace: defaultNamespace,
|
||||
Generation: generation,
|
||||
Spec: appsv1.StatefulSetSpec{
|
||||
UpdateStrategy: appsv1.StatefulSetUpdateStrategy{
|
||||
Type: appsv1.RollingUpdateStatefulSetStrategyType,
|
||||
@@ -1393,11 +1389,9 @@ func newDeployment(name string, replicas, maxSurge, maxUnavailable int, generati
|
||||
generation = 2
|
||||
}
|
||||
return &appsv1.Deployment{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: defaultNamespace,
|
||||
Generation: generation,
|
||||
},
|
||||
Name: name,
|
||||
Namespace: defaultNamespace,
|
||||
Generation: generation,
|
||||
Spec: appsv1.DeploymentSpec{
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
Type: appsv1.RollingUpdateDeploymentStrategyType,
|
||||
@@ -1434,10 +1428,8 @@ func newReplicationController(name string, generationInSync bool) *corev1.Replic
|
||||
generation = 2
|
||||
}
|
||||
return &corev1.ReplicationController{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Generation: generation,
|
||||
},
|
||||
Name: name,
|
||||
Generation: generation,
|
||||
Status: corev1.ReplicationControllerStatus{
|
||||
ObservedGeneration: observedGeneration,
|
||||
},
|
||||
@@ -1447,13 +1439,11 @@ func newReplicationController(name string, generationInSync bool) *corev1.Replic
|
||||
func newReplicaSet(name string, replicas, readyReplicas int, generationInSync bool) *appsv1.ReplicaSet {
|
||||
d := newDeployment(name, replicas, 0, 0, generationInSync)
|
||||
return &appsv1.ReplicaSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: defaultNamespace,
|
||||
Labels: d.Spec.Selector.MatchLabels,
|
||||
OwnerReferences: []metav1.OwnerReference{*metav1.NewControllerRef(d, d.GroupVersionKind())},
|
||||
Generation: d.Generation,
|
||||
},
|
||||
Name: name,
|
||||
Namespace: defaultNamespace,
|
||||
Labels: d.Spec.Selector.MatchLabels,
|
||||
OwnerReferences: []metav1.OwnerReference{*metav1.NewControllerRef(d, d.GroupVersionKind())},
|
||||
Generation: d.Generation,
|
||||
Spec: appsv1.ReplicaSetSpec{
|
||||
Selector: d.Spec.Selector,
|
||||
Replicas: intToInt32(replicas),
|
||||
@@ -1468,11 +1458,9 @@ func newReplicaSet(name string, replicas, readyReplicas int, generationInSync bo
|
||||
|
||||
func newPodWithCondition(name string, podReadyCondition corev1.ConditionStatus) *corev1.Pod {
|
||||
return &corev1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: defaultNamespace,
|
||||
Labels: map[string]string{"name": name},
|
||||
},
|
||||
Name: name,
|
||||
Namespace: defaultNamespace,
|
||||
Labels: map[string]string{"name": name},
|
||||
Spec: corev1.PodSpec{
|
||||
Containers: []corev1.Container{
|
||||
{
|
||||
@@ -1493,10 +1481,8 @@ func newPodWithCondition(name string, podReadyCondition corev1.ConditionStatus)
|
||||
|
||||
func newPersistentVolumeClaim(name string, phase corev1.PersistentVolumeClaimPhase) *corev1.PersistentVolumeClaim {
|
||||
return &corev1.PersistentVolumeClaim{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: defaultNamespace,
|
||||
},
|
||||
Name: name,
|
||||
Namespace: defaultNamespace,
|
||||
Status: corev1.PersistentVolumeClaimStatus{
|
||||
Phase: phase,
|
||||
},
|
||||
@@ -1505,10 +1491,8 @@ func newPersistentVolumeClaim(name string, phase corev1.PersistentVolumeClaimPha
|
||||
|
||||
func newJob(name string, backoffLimit int, completions *int32, succeeded, failed int) *batchv1.Job {
|
||||
return &batchv1.Job{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: defaultNamespace,
|
||||
},
|
||||
Name: name,
|
||||
Namespace: defaultNamespace,
|
||||
Spec: batchv1.JobSpec{
|
||||
BackoffLimit: intToInt32(backoffLimit),
|
||||
Completions: completions,
|
||||
@@ -1535,11 +1519,9 @@ func newJob(name string, backoffLimit int, completions *int32, succeeded, failed
|
||||
|
||||
func newService(name string, serviceSpec corev1.ServiceSpec) *corev1.Service {
|
||||
return &corev1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: defaultNamespace,
|
||||
},
|
||||
Spec: serviceSpec,
|
||||
Name: name,
|
||||
Namespace: defaultNamespace,
|
||||
Spec: serviceSpec,
|
||||
Status: corev1.ServiceStatus{
|
||||
LoadBalancer: corev1.LoadBalancerStatus{
|
||||
Ingress: nil,
|
||||
@@ -1550,23 +1532,19 @@ func newService(name string, serviceSpec corev1.ServiceSpec) *corev1.Service {
|
||||
|
||||
func newcrdBetaReady(name string, crdBetaStatus apiextv1beta1.CustomResourceDefinitionStatus) apiextv1beta1.CustomResourceDefinition {
|
||||
return apiextv1beta1.CustomResourceDefinition{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: defaultNamespace,
|
||||
},
|
||||
Spec: apiextv1beta1.CustomResourceDefinitionSpec{},
|
||||
Status: crdBetaStatus,
|
||||
Name: name,
|
||||
Namespace: defaultNamespace,
|
||||
Spec: apiextv1beta1.CustomResourceDefinitionSpec{},
|
||||
Status: crdBetaStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func newcrdReady(name string, crdBetaStatus apiextv1.CustomResourceDefinitionStatus) apiextv1.CustomResourceDefinition {
|
||||
return apiextv1.CustomResourceDefinition{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: defaultNamespace,
|
||||
},
|
||||
Spec: apiextv1.CustomResourceDefinitionSpec{},
|
||||
Status: crdBetaStatus,
|
||||
Name: name,
|
||||
Namespace: defaultNamespace,
|
||||
Spec: apiextv1.CustomResourceDefinitionSpec{},
|
||||
Status: crdBetaStatus,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-11
@@ -186,7 +186,7 @@ func TestSelectorsForObject(t *testing.T) {
|
||||
{
|
||||
name: "corev1 Service with selector",
|
||||
object: &corev1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "svc"},
|
||||
Name: "svc",
|
||||
Spec: corev1.ServiceSpec{
|
||||
Selector: map[string]string{"svc": "yes"},
|
||||
},
|
||||
@@ -197,8 +197,8 @@ func TestSelectorsForObject(t *testing.T) {
|
||||
{
|
||||
name: "corev1 Service without selector",
|
||||
object: &corev1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "svc"},
|
||||
Spec: corev1.ServiceSpec{Selector: map[string]string{}},
|
||||
Name: "svc",
|
||||
Spec: corev1.ServiceSpec{Selector: map[string]string{}},
|
||||
},
|
||||
expectError: true,
|
||||
errorContains: "invalid service 'svc': Service is defined without a selector",
|
||||
@@ -250,8 +250,8 @@ func TestLegacyWaiter_waitForPodSuccess(t *testing.T) {
|
||||
{
|
||||
name: "pod succeeded",
|
||||
obj: &corev1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pod1"},
|
||||
Status: corev1.PodStatus{Phase: corev1.PodSucceeded},
|
||||
Name: "pod1",
|
||||
Status: corev1.PodStatus{Phase: corev1.PodSucceeded},
|
||||
},
|
||||
wantDone: true,
|
||||
wantErr: false,
|
||||
@@ -259,8 +259,8 @@ func TestLegacyWaiter_waitForPodSuccess(t *testing.T) {
|
||||
{
|
||||
name: "pod failed",
|
||||
obj: &corev1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pod2"},
|
||||
Status: corev1.PodStatus{Phase: corev1.PodFailed},
|
||||
Name: "pod2",
|
||||
Status: corev1.PodStatus{Phase: corev1.PodFailed},
|
||||
},
|
||||
wantDone: true,
|
||||
wantErr: true,
|
||||
@@ -269,8 +269,8 @@ func TestLegacyWaiter_waitForPodSuccess(t *testing.T) {
|
||||
{
|
||||
name: "pod pending",
|
||||
obj: &corev1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pod3"},
|
||||
Status: corev1.PodStatus{Phase: corev1.PodPending},
|
||||
Name: "pod3",
|
||||
Status: corev1.PodStatus{Phase: corev1.PodPending},
|
||||
},
|
||||
wantDone: false,
|
||||
wantErr: false,
|
||||
@@ -278,8 +278,8 @@ func TestLegacyWaiter_waitForPodSuccess(t *testing.T) {
|
||||
{
|
||||
name: "pod running",
|
||||
obj: &corev1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pod4"},
|
||||
Status: corev1.PodStatus{Phase: corev1.PodRunning},
|
||||
Name: "pod4",
|
||||
Status: corev1.PodStatus{Phase: corev1.PodRunning},
|
||||
},
|
||||
wantDone: false,
|
||||
wantErr: false,
|
||||
|
||||
@@ -32,7 +32,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/Masterminds/semver/v3"
|
||||
"github.com/opencontainers/image-spec/specs-go"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"oras.land/oras-go/v2"
|
||||
"oras.land/oras-go/v2/content/memory"
|
||||
@@ -915,10 +914,10 @@ func (c *Client) tagManifest(ctx context.Context, memoryStore *memory.Store,
|
||||
ociAnnotations map[string]string, parsedRef reference,
|
||||
) (ocispec.Descriptor, error) {
|
||||
manifest := ocispec.Manifest{
|
||||
Versioned: specs.Versioned{SchemaVersion: 2},
|
||||
Config: configDescriptor,
|
||||
Layers: layers,
|
||||
Annotations: ociAnnotations,
|
||||
SchemaVersion: 2,
|
||||
Config: configDescriptor,
|
||||
Layers: layers,
|
||||
Annotations: ociAnnotations,
|
||||
}
|
||||
|
||||
manifestData, err := json.Marshal(manifest)
|
||||
|
||||
+20
-22
@@ -113,34 +113,32 @@ func (c *GenericClient) PullGeneric(ref string, options GenericPullOptions) (*Ge
|
||||
|
||||
var mu sync.Mutex
|
||||
manifest, err := oras.Copy(ctx, repository, parsedRef.String(), memoryStore, "", oras.CopyOptions{
|
||||
CopyGraphOptions: oras.CopyGraphOptions{
|
||||
PreCopy: func(ctx context.Context, desc ocispec.Descriptor) error {
|
||||
// Apply a custom PreCopy function if provided
|
||||
if options.PreCopy != nil {
|
||||
if err := options.PreCopy(ctx, desc); err != nil {
|
||||
return err
|
||||
}
|
||||
PreCopy: func(ctx context.Context, desc ocispec.Descriptor) error {
|
||||
// Apply a custom PreCopy function if provided
|
||||
if options.PreCopy != nil {
|
||||
if err := options.PreCopy(ctx, desc); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
mediaType := desc.MediaType
|
||||
mediaType := desc.MediaType
|
||||
|
||||
// Skip media types if specified
|
||||
if slices.Contains(options.SkipMediaTypes, mediaType) {
|
||||
// Skip media types if specified
|
||||
if slices.Contains(options.SkipMediaTypes, mediaType) {
|
||||
return oras.SkipNode
|
||||
}
|
||||
|
||||
// Filter by allowed media types if specified
|
||||
if len(allowedMediaTypes) > 0 {
|
||||
if i := sort.SearchStrings(allowedMediaTypes, mediaType); i >= len(allowedMediaTypes) || allowedMediaTypes[i] != mediaType {
|
||||
return oras.SkipNode
|
||||
}
|
||||
}
|
||||
|
||||
// Filter by allowed media types if specified
|
||||
if len(allowedMediaTypes) > 0 {
|
||||
if i := sort.SearchStrings(allowedMediaTypes, mediaType); i >= len(allowedMediaTypes) || allowedMediaTypes[i] != mediaType {
|
||||
return oras.SkipNode
|
||||
}
|
||||
}
|
||||
|
||||
mu.Lock()
|
||||
descriptors = append(descriptors, desc)
|
||||
mu.Unlock()
|
||||
return nil
|
||||
},
|
||||
mu.Lock()
|
||||
descriptors = append(descriptors, desc)
|
||||
mu.Unlock()
|
||||
return nil
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -279,10 +279,8 @@ func newConfigMapsObject(key string, rls *rspb.Release, lbs labels) (*v1.ConfigM
|
||||
|
||||
// create and return configmap object
|
||||
return &v1.ConfigMap{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: key,
|
||||
Labels: lbs.toMap(),
|
||||
},
|
||||
Data: map[string]string{"release": s},
|
||||
Name: key,
|
||||
Labels: lbs.toMap(),
|
||||
Data: map[string]string{"release": s},
|
||||
}, nil
|
||||
}
|
||||
@@ -277,11 +277,9 @@ func newSecretsObject(key string, rls *rspb.Release, lbs labels) (*v1.Secret, er
|
||||
// This would potentially be a breaking change
|
||||
// and should only happen between major versions.
|
||||
return &v1.Secret{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: key,
|
||||
Labels: lbs.toMap(),
|
||||
},
|
||||
Type: "helm.sh/release.v1",
|
||||
Data: map[string][]byte{"release": []byte(s)},
|
||||
Name: key,
|
||||
Labels: lbs.toMap(),
|
||||
Type: "helm.sh/release.v1",
|
||||
Data: map[string][]byte{"release": []byte(s)},
|
||||
}, nil
|
||||
}
|
||||
Reference in new issue
Block a user