Skip to content

Commit e8f4730

Browse files
committed
Add yaml format custom profiling support
1 parent 4e650a9 commit e8f4730

File tree

1 file changed

+6
-2
lines changed
  • staging/src/k8s.io/kubectl/pkg/cmd/debug

1 file changed

+6
-2
lines changed

staging/src/k8s.io/kubectl/pkg/cmd/debug/debug.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import (
5656
"k8s.io/kubectl/pkg/util/templates"
5757
"k8s.io/kubectl/pkg/util/term"
5858
"k8s.io/utils/ptr"
59+
"sigs.k8s.io/yaml"
5960
)
6061

6162
var (
@@ -212,7 +213,7 @@ func (o *DebugOptions) AddFlags(cmd *cobra.Command) {
212213
cmd.Flags().BoolVarP(&o.TTY, "tty", "t", o.TTY, i18n.T("Allocate a TTY for the debugging container."))
213214
cmd.Flags().StringVar(&o.Profile, "profile", ProfileLegacy, i18n.T(`Options are "legacy", "general", "baseline", "netadmin", "restricted" or "sysadmin".`))
214215
if !cmdutil.DebugCustomProfile.IsDisabled() {
215-
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."))
216+
cmd.Flags().StringVar(&o.CustomProfileFile, "custom", o.CustomProfileFile, i18n.T("Path to a JSON or YAML file containing a partial container spec to customize built-in debug profiles."))
216217
}
217218
}
218219

@@ -293,7 +294,10 @@ func (o *DebugOptions) Complete(restClientGetter genericclioptions.RESTClientGet
293294

294295
err = json.Unmarshal(customProfileBytes, &o.CustomProfile)
295296
if err != nil {
296-
return fmt.Errorf("%s does not contain a valid container spec: %w", o.CustomProfileFile, err)
297+
err = yaml.Unmarshal(customProfileBytes, &o.CustomProfile)
298+
if err != nil {
299+
return fmt.Errorf("%s does not contain a valid container spec: %w", o.CustomProfileFile, err)
300+
}
297301
}
298302
}
299303

0 commit comments

Comments
 (0)