mirror of
https://github.com/kubernetes/kubectl.git
synced 2026-04-26 00:27:43 -04:00
Generate and format files
- Run hack/update-codegen.sh - Run hack/update-generated-device-plugin.sh - Run hack/update-generated-protobuf.sh - Run hack/update-generated-runtime.sh - Run hack/update-generated-swagger-docs.sh - Run hack/update-openapi-spec.sh - Run hack/update-gofmt.sh Signed-off-by: Davanum Srinivas <davanum@gmail.com> Kubernetes-commit: a9593d634c6a053848413e600dadbf974627515f
This commit is contained in:
parent
ded91f6296
commit
d3700ce217
10 changed files with 45 additions and 38 deletions
|
|
@ -444,16 +444,18 @@ func NewKubectlCommand(o KubectlOptions) *cobra.Command {
|
|||
}
|
||||
|
||||
// addCmdHeaderHooks performs updates on two hooks:
|
||||
// 1) Modifies the passed "cmds" persistent pre-run function to parse command headers.
|
||||
// These headers will be subsequently added as X-headers to every
|
||||
// REST call.
|
||||
// 2) Adds CommandHeaderRoundTripper as a wrapper around the standard
|
||||
// RoundTripper. CommandHeaderRoundTripper adds X-Headers then delegates
|
||||
// to standard RoundTripper.
|
||||
// 1. Modifies the passed "cmds" persistent pre-run function to parse command headers.
|
||||
// These headers will be subsequently added as X-headers to every
|
||||
// REST call.
|
||||
// 2. Adds CommandHeaderRoundTripper as a wrapper around the standard
|
||||
// RoundTripper. CommandHeaderRoundTripper adds X-Headers then delegates
|
||||
// to standard RoundTripper.
|
||||
//
|
||||
// For beta, these hooks are updated unless the KUBECTL_COMMAND_HEADERS environment variable
|
||||
// is set, and the value of the env var is false (or zero).
|
||||
// See SIG CLI KEP 859 for more information:
|
||||
// https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/859-kubectl-headers
|
||||
//
|
||||
// https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/859-kubectl-headers
|
||||
func addCmdHeaderHooks(cmds *cobra.Command, kubeConfigFlags *genericclioptions.ConfigFlags) {
|
||||
// If the feature gate env var is set to "false", then do no add kubectl command headers.
|
||||
if value, exists := os.LookupEnv(kubectlCmdHeaders); exists {
|
||||
|
|
|
|||
|
|
@ -403,8 +403,9 @@ func (o *DebugOptions) visitNode(ctx context.Context, node *corev1.Node) (*corev
|
|||
}
|
||||
|
||||
// visitPod handles debugging for pod targets by (depending on options):
|
||||
// 1. Creating an ephemeral debug container in an existing pod, OR
|
||||
// 2. Making a copy of pod with certain attributes changed
|
||||
// 1. Creating an ephemeral debug container in an existing pod, OR
|
||||
// 2. Making a copy of pod with certain attributes changed
|
||||
//
|
||||
// visitPod returns a pod and debug container name for subsequent attach, if applicable.
|
||||
func (o *DebugOptions) visitPod(ctx context.Context, pod *corev1.Pod) (*corev1.Pod, string, error) {
|
||||
if len(o.CopyTo) > 0 {
|
||||
|
|
|
|||
|
|
@ -38,12 +38,14 @@ import (
|
|||
var jsonRegexp = regexp.MustCompile(`^\{\.?([^{}]+)\}$|^\.?([^{}]+)$`)
|
||||
|
||||
// RelaxedJSONPathExpression attempts to be flexible with JSONPath expressions, it accepts:
|
||||
// * metadata.name (no leading '.' or curly braces '{...}'
|
||||
// * {metadata.name} (no leading '.')
|
||||
// * .metadata.name (no curly braces '{...}')
|
||||
// * {.metadata.name} (complete expression)
|
||||
// - metadata.name (no leading '.' or curly braces '{...}'
|
||||
// - {metadata.name} (no leading '.')
|
||||
// - .metadata.name (no curly braces '{...}')
|
||||
// - {.metadata.name} (complete expression)
|
||||
//
|
||||
// And transforms them all into a valid jsonpath expression:
|
||||
// {.metadata.name}
|
||||
//
|
||||
// {.metadata.name}
|
||||
func RelaxedJSONPathExpression(pathExpression string) (string, error) {
|
||||
if len(pathExpression) == 0 {
|
||||
return pathExpression, nil
|
||||
|
|
@ -67,8 +69,8 @@ func RelaxedJSONPathExpression(pathExpression string) (string, error) {
|
|||
// NewCustomColumnsPrinterFromSpec creates a custom columns printer from a comma separated list of <header>:<jsonpath-field-spec> pairs.
|
||||
// e.g. NAME:metadata.name,API_VERSION:apiVersion creates a printer that prints:
|
||||
//
|
||||
// NAME API_VERSION
|
||||
// foo bar
|
||||
// NAME API_VERSION
|
||||
// foo bar
|
||||
func NewCustomColumnsPrinterFromSpec(spec string, decoder runtime.Decoder, noHeaders bool) (*CustomColumnsPrinter, error) {
|
||||
if len(spec) == 0 {
|
||||
return nil, fmt.Errorf("custom-columns format specified but no custom columns given")
|
||||
|
|
|
|||
14
pkg/cmd/set/env/env_resolve.go
vendored
14
pkg/cmd/set/env/env_resolve.go
vendored
|
|
@ -131,15 +131,15 @@ func extractFieldPathAsString(obj interface{}, fieldPath string) (string, error)
|
|||
|
||||
// splitMaybeSubscriptedPath checks whether the specified fieldPath is
|
||||
// subscripted, and
|
||||
// - if yes, this function splits the fieldPath into path and subscript, and
|
||||
// returns (path, subscript, true).
|
||||
// - if no, this function returns (fieldPath, "", false).
|
||||
// - if yes, this function splits the fieldPath into path and subscript, and
|
||||
// returns (path, subscript, true).
|
||||
// - if no, this function returns (fieldPath, "", false).
|
||||
//
|
||||
// Example inputs and outputs:
|
||||
// - "metadata.annotations['myKey']" --> ("metadata.annotations", "myKey", true)
|
||||
// - "metadata.annotations['a[b]c']" --> ("metadata.annotations", "a[b]c", true)
|
||||
// - "metadata.labels['']" --> ("metadata.labels", "", true)
|
||||
// - "metadata.labels" --> ("metadata.labels", "", false)
|
||||
// - "metadata.annotations['myKey']" --> ("metadata.annotations", "myKey", true)
|
||||
// - "metadata.annotations['a[b]c']" --> ("metadata.annotations", "a[b]c", true)
|
||||
// - "metadata.labels[”]" --> ("metadata.labels", "", true)
|
||||
// - "metadata.labels" --> ("metadata.labels", "", false)
|
||||
func splitMaybeSubscriptedPath(fieldPath string) (string, string, bool) {
|
||||
if !strings.HasSuffix(fieldPath, "']") {
|
||||
return fieldPath, "", false
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ func (o *SubjectOptions) Run(fn updateSubjects) error {
|
|||
return utilerrors.NewAggregate(allErrs)
|
||||
}
|
||||
|
||||
//Note: the obj mutates in the function
|
||||
// Note: the obj mutates in the function
|
||||
func updateSubjectForObject(obj runtime.Object, subjects []rbacv1.Subject, fn updateSubjects) (bool, error) {
|
||||
switch t := obj.(type) {
|
||||
case *rbacv1.RoleBinding:
|
||||
|
|
|
|||
|
|
@ -5037,7 +5037,7 @@ func (d *Describers) DescribeObject(exact interface{}, extra ...interface{}) (st
|
|||
// Add adds one or more describer functions to the Describer. The passed function must
|
||||
// match the signature:
|
||||
//
|
||||
// func(...) (string, error)
|
||||
// func(...) (string, error)
|
||||
//
|
||||
// Any number of arguments may be provided.
|
||||
func (d *Describers) Add(fns ...interface{}) error {
|
||||
|
|
|
|||
|
|
@ -167,9 +167,9 @@ func (r *DeploymentRollbacker) Rollback(obj runtime.Object, updatedAnnotations m
|
|||
|
||||
// equalIgnoreHash returns true if two given podTemplateSpec are equal, ignoring the diff in value of Labels[pod-template-hash]
|
||||
// We ignore pod-template-hash because:
|
||||
// 1. The hash result would be different upon podTemplateSpec API changes
|
||||
// (e.g. the addition of a new field will cause the hash code to change)
|
||||
// 2. The deployment template won't have hash labels
|
||||
// 1. The hash result would be different upon podTemplateSpec API changes
|
||||
// (e.g. the addition of a new field will cause the hash code to change)
|
||||
// 2. The deployment template won't have hash labels
|
||||
func equalIgnoreHash(template1, template2 *corev1.PodTemplateSpec) bool {
|
||||
t1Copy := template1.DeepCopy()
|
||||
t2Copy := template2.DeepCopy()
|
||||
|
|
|
|||
|
|
@ -168,9 +168,9 @@ func listReplicaSets(deployment *appsv1.Deployment, getRSList rsListFunc, chunkS
|
|||
|
||||
// EqualIgnoreHash returns true if two given podTemplateSpec are equal, ignoring the diff in value of Labels[pod-template-hash]
|
||||
// We ignore pod-template-hash because:
|
||||
// 1. The hash result would be different upon podTemplateSpec API changes
|
||||
// (e.g. the addition of a new field will cause the hash code to change)
|
||||
// 2. The deployment template won't have hash labels
|
||||
// 1. The hash result would be different upon podTemplateSpec API changes
|
||||
// (e.g. the addition of a new field will cause the hash code to change)
|
||||
// 2. The deployment template won't have hash labels
|
||||
func equalIgnoreHash(template1, template2 *corev1.PodTemplateSpec) bool {
|
||||
t1Copy := template1.DeepCopy()
|
||||
t2Copy := template2.DeepCopy()
|
||||
|
|
|
|||
|
|
@ -35,9 +35,11 @@ type wordWrapWriter struct {
|
|||
// NewResponsiveWriter creates a Writer that detects the column width of the
|
||||
// terminal we are in, and adjusts every line width to fit and use recommended
|
||||
// terminal sizes for better readability. Does proper word wrapping automatically.
|
||||
// if terminal width >= 120 columns use 120 columns
|
||||
// if terminal width >= 100 columns use 100 columns
|
||||
// if terminal width >= 80 columns use 80 columns
|
||||
//
|
||||
// if terminal width >= 120 columns use 120 columns
|
||||
// if terminal width >= 100 columns use 100 columns
|
||||
// if terminal width >= 80 columns use 80 columns
|
||||
//
|
||||
// In case we're not in a terminal or if it's smaller than 80 columns width,
|
||||
// doesn't do any wrapping.
|
||||
func NewResponsiveWriter(w io.Writer) io.Writer {
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@ func HashObject(obj runtime.Object, codec runtime.Codec) (string, error) {
|
|||
|
||||
// ParseFileSource parses the source given.
|
||||
//
|
||||
// Acceptable formats include:
|
||||
// 1. source-path: the basename will become the key name
|
||||
// 2. source-name=source-path: the source-name will become the key name and
|
||||
// source-path is the path to the key file.
|
||||
// Acceptable formats include:
|
||||
// 1. source-path: the basename will become the key name
|
||||
// 2. source-name=source-path: the source-name will become the key name and
|
||||
// source-path is the path to the key file.
|
||||
//
|
||||
// Key names cannot include '='.
|
||||
func ParseFileSource(source string) (keyName, filePath string, err error) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue