30
vendor/k8s.io/kubectl/pkg/cmd/util/helpers.go
generated
vendored
30
vendor/k8s.io/kubectl/pkg/cmd/util/helpers.go
generated
vendored
@@ -43,7 +43,7 @@ import (
|
||||
"k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/scale"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/klog"
|
||||
"k8s.io/klog/v2"
|
||||
utilexec "k8s.io/utils/exec"
|
||||
)
|
||||
|
||||
@@ -86,10 +86,10 @@ func DefaultBehaviorOnFatal() {
|
||||
fatalErrHandler = fatal
|
||||
}
|
||||
|
||||
// fatal prints the message (if provided) and then exits. If V(2) or greater,
|
||||
// fatal prints the message (if provided) and then exits. If V(6) or greater,
|
||||
// klog.Fatal is invoked for extended information.
|
||||
func fatal(msg string, code int) {
|
||||
if klog.V(2) {
|
||||
if klog.V(6).Enabled() {
|
||||
klog.FatalDepth(2, msg)
|
||||
}
|
||||
if len(msg) > 0 {
|
||||
@@ -430,10 +430,17 @@ func AddDryRunFlag(cmd *cobra.Command) {
|
||||
cmd.Flags().Lookup("dry-run").NoOptDefVal = "unchanged"
|
||||
}
|
||||
|
||||
func AddFieldManagerFlagVar(cmd *cobra.Command, p *string, defaultFieldManager string) {
|
||||
cmd.Flags().StringVar(p, "field-manager", defaultFieldManager, "Name of the manager used to track field ownership.")
|
||||
}
|
||||
|
||||
func AddContainerVarFlags(cmd *cobra.Command, p *string, containerName string) {
|
||||
cmd.Flags().StringVarP(p, "container", "c", containerName, "Container name. If omitted, use the kubectl.kubernetes.io/default-container annotation for selecting the container to be attached or the first container in the pod will be chosen")
|
||||
}
|
||||
|
||||
func AddServerSideApplyFlags(cmd *cobra.Command) {
|
||||
cmd.Flags().Bool("server-side", false, "If true, apply runs in the server instead of the client.")
|
||||
cmd.Flags().Bool("force-conflicts", false, "If true, server-side apply will force the changes against conflicts.")
|
||||
cmd.Flags().String("field-manager", "kubectl", "Name of the manager used to track field ownership.")
|
||||
}
|
||||
|
||||
func AddPodRunningTimeoutFlag(cmd *cobra.Command, defaultTimeout time.Duration) {
|
||||
@@ -520,8 +527,23 @@ func GetFieldManagerFlag(cmd *cobra.Command) string {
|
||||
type DryRunStrategy int
|
||||
|
||||
const (
|
||||
// DryRunNone indicates the client will make all mutating calls
|
||||
DryRunNone DryRunStrategy = iota
|
||||
|
||||
// DryRunClient, or client-side dry-run, indicates the client will prevent
|
||||
// making mutating calls such as CREATE, PATCH, and DELETE
|
||||
DryRunClient
|
||||
|
||||
// DryRunServer, or server-side dry-run, indicates the client will send
|
||||
// mutating calls to the APIServer with the dry-run parameter to prevent
|
||||
// persisting changes.
|
||||
//
|
||||
// Note that clients sending server-side dry-run calls should verify that
|
||||
// the APIServer and the resource supports server-side dry-run, and otherwise
|
||||
// clients should fail early.
|
||||
//
|
||||
// If a client sends a server-side dry-run call to an APIServer that doesn't
|
||||
// support server-side dry-run, then the APIServer will persist changes inadvertently.
|
||||
DryRunServer
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user