Enable custom profiling in kubectl debug as default

This commit is contained in:
Arda Güçlü 2024-06-04 14:59:17 +03:00
parent e6d641651a
commit 4e650a9954
2 changed files with 67 additions and 75 deletions

View File

@ -211,7 +211,7 @@ func (o *DebugOptions) AddFlags(cmd *cobra.Command) {
cmd.Flags().StringVar(&o.TargetContainer, "target", "", i18n.T("When using an ephemeral container, target processes in this container name."))
cmd.Flags().BoolVarP(&o.TTY, "tty", "t", o.TTY, i18n.T("Allocate a TTY for the debugging container."))
cmd.Flags().StringVar(&o.Profile, "profile", ProfileLegacy, i18n.T(`Options are "legacy", "general", "baseline", "netadmin", "restricted" or "sysadmin".`))
if cmdutil.DebugCustomProfile.IsEnabled() {
if !cmdutil.DebugCustomProfile.IsDisabled() {
cmd.Flags().StringVar(&o.CustomProfileFile, "custom", o.CustomProfileFile, i18n.T("Path to a JSON file containing a partial container spec to customize built-in debug profiles."))
}
}

View File

@ -22,8 +22,6 @@ import (
"testing"
"time"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/spf13/cobra"
@ -2088,7 +2086,6 @@ func TestGenerateNodeDebugPodCustomProfile(t *testing.T) {
} {
t.Run(tc.name, func(t *testing.T) {
cmdtesting.WithAlphaEnvs([]cmdutil.FeatureGate{cmdutil.DebugCustomProfile}, t, func(t *testing.T) {
var err error
kflags := KeepFlags{
Labels: tc.opts.KeepLabels,
@ -2113,7 +2110,6 @@ func TestGenerateNodeDebugPodCustomProfile(t *testing.T) {
t.Error("unexpected diff in generated object: (-want +got):\n", diff)
}
})
})
}
}
@ -2296,7 +2292,6 @@ func TestGenerateCopyDebugPodCustomProfile(t *testing.T) {
} {
t.Run(tc.name, func(t *testing.T) {
cmdtesting.WithAlphaEnvs([]cmdutil.FeatureGate{cmdutil.DebugCustomProfile}, t, func(t *testing.T) {
var err error
kflags := KeepFlags{
Labels: tc.opts.KeepLabels,
@ -2321,7 +2316,6 @@ func TestGenerateCopyDebugPodCustomProfile(t *testing.T) {
t.Error("unexpected diff in generated object: (-want +got):\n", diff)
}
})
})
}
}
@ -2510,7 +2504,6 @@ func TestGenerateEphemeralDebugPodCustomProfile(t *testing.T) {
} {
t.Run(tc.name, func(t *testing.T) {
cmdtesting.WithAlphaEnvs([]cmdutil.FeatureGate{cmdutil.DebugCustomProfile}, t, func(t *testing.T) {
var err error
kflags := KeepFlags{
Labels: tc.opts.KeepLabels,
@ -2535,7 +2528,6 @@ func TestGenerateEphemeralDebugPodCustomProfile(t *testing.T) {
t.Error("unexpected diff in generated object: (-want +got):\n", diff)
}
})
})
}
}