mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 09:52:49 +00:00
Merge pull request #88649 from oke-py/remove-deprecated-export
Remove --export flag from kubectl get command.
This commit is contained in:
commit
1faf097f3f
@ -100,8 +100,6 @@ type Builder struct {
|
||||
|
||||
singleItemImplied bool
|
||||
|
||||
export bool
|
||||
|
||||
schema ContentValidator
|
||||
|
||||
// fakeClientFn is used for testing
|
||||
@ -461,12 +459,6 @@ func (b *Builder) FieldSelectorParam(s string) *Builder {
|
||||
return b
|
||||
}
|
||||
|
||||
// ExportParam accepts the export boolean for these resources
|
||||
func (b *Builder) ExportParam(export bool) *Builder {
|
||||
b.export = export
|
||||
return b
|
||||
}
|
||||
|
||||
// NamespaceParam accepts the namespace that these resources should be
|
||||
// considered under from - used by DefaultNamespace() and RequireNamespace()
|
||||
func (b *Builder) NamespaceParam(namespace string) *Builder {
|
||||
@ -870,7 +862,7 @@ func (b *Builder) visitBySelector() *Result {
|
||||
if mapping.Scope.Name() != meta.RESTScopeNameNamespace {
|
||||
selectorNamespace = ""
|
||||
}
|
||||
visitors = append(visitors, NewSelector(client, mapping, selectorNamespace, labelSelector, fieldSelector, b.export, b.limitChunks))
|
||||
visitors = append(visitors, NewSelector(client, mapping, selectorNamespace, labelSelector, fieldSelector, b.limitChunks))
|
||||
}
|
||||
if b.continueOnError {
|
||||
result.visitor = EagerVisitorList(visitors)
|
||||
@ -970,7 +962,6 @@ func (b *Builder) visitByResource() *Result {
|
||||
Mapping: mapping,
|
||||
Namespace: selectorNamespace,
|
||||
Name: tuple.Name,
|
||||
Export: b.export,
|
||||
}
|
||||
items = append(items, info)
|
||||
}
|
||||
@ -1035,7 +1026,6 @@ func (b *Builder) visitByName() *Result {
|
||||
Mapping: mapping,
|
||||
Namespace: selectorNamespace,
|
||||
Name: name,
|
||||
Export: b.export,
|
||||
}
|
||||
visitors = append(visitors, info)
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ package resource
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@ -75,27 +74,19 @@ func (m *Helper) WithFieldManager(fieldManager string) *Helper {
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *Helper) Get(namespace, name string, export bool) (runtime.Object, error) {
|
||||
func (m *Helper) Get(namespace, name string) (runtime.Object, error) {
|
||||
req := m.RESTClient.Get().
|
||||
NamespaceIfScoped(namespace, m.NamespaceScoped).
|
||||
Resource(m.Resource).
|
||||
Name(name)
|
||||
if export {
|
||||
// TODO: I should be part of GetOptions
|
||||
req.Param("export", strconv.FormatBool(export))
|
||||
}
|
||||
return req.Do(context.TODO()).Get()
|
||||
}
|
||||
|
||||
func (m *Helper) List(namespace, apiVersion string, export bool, options *metav1.ListOptions) (runtime.Object, error) {
|
||||
func (m *Helper) List(namespace, apiVersion string, options *metav1.ListOptions) (runtime.Object, error) {
|
||||
req := m.RESTClient.Get().
|
||||
NamespaceIfScoped(namespace, m.NamespaceScoped).
|
||||
Resource(m.Resource).
|
||||
VersionedParams(options, metav1.ParameterCodec)
|
||||
if export {
|
||||
// TODO: I should be part of ListOptions
|
||||
req.Param("export", strconv.FormatBool(export))
|
||||
}
|
||||
return req.Do(context.TODO()).Get()
|
||||
}
|
||||
|
||||
|
@ -312,7 +312,7 @@ func TestHelperGet(t *testing.T) {
|
||||
RESTClient: client,
|
||||
NamespaceScoped: true,
|
||||
}
|
||||
obj, err := modifier.Get("bar", "foo", false)
|
||||
obj, err := modifier.Get("bar", "foo")
|
||||
|
||||
if (err != nil) != tt.Err {
|
||||
t.Errorf("unexpected error: %d %t %v", i, tt.Err, err)
|
||||
@ -393,7 +393,7 @@ func TestHelperList(t *testing.T) {
|
||||
RESTClient: client,
|
||||
NamespaceScoped: true,
|
||||
}
|
||||
obj, err := modifier.List("bar", corev1GV.String(), false, &metav1.ListOptions{LabelSelector: "foo=baz"})
|
||||
obj, err := modifier.List("bar", corev1GV.String(), &metav1.ListOptions{LabelSelector: "foo=baz"})
|
||||
if (err != nil) != tt.Err {
|
||||
t.Errorf("unexpected error: %t %v", tt.Err, err)
|
||||
}
|
||||
@ -464,7 +464,6 @@ func TestHelperListSelectorCombination(t *testing.T) {
|
||||
t.Run(tt.Name, func(t *testing.T) {
|
||||
_, err := modifier.List("bar",
|
||||
corev1GV.String(),
|
||||
false,
|
||||
&metav1.ListOptions{LabelSelector: tt.LabelSelector, FieldSelector: tt.FieldSelector})
|
||||
if tt.Err {
|
||||
if err == nil {
|
||||
|
@ -32,19 +32,17 @@ type Selector struct {
|
||||
Namespace string
|
||||
LabelSelector string
|
||||
FieldSelector string
|
||||
Export bool
|
||||
LimitChunks int64
|
||||
}
|
||||
|
||||
// NewSelector creates a resource selector which hides details of getting items by their label selector.
|
||||
func NewSelector(client RESTClient, mapping *meta.RESTMapping, namespace, labelSelector, fieldSelector string, export bool, limitChunks int64) *Selector {
|
||||
func NewSelector(client RESTClient, mapping *meta.RESTMapping, namespace, labelSelector, fieldSelector string, limitChunks int64) *Selector {
|
||||
return &Selector{
|
||||
Client: client,
|
||||
Mapping: mapping,
|
||||
Namespace: namespace,
|
||||
LabelSelector: labelSelector,
|
||||
FieldSelector: fieldSelector,
|
||||
Export: export,
|
||||
LimitChunks: limitChunks,
|
||||
}
|
||||
}
|
||||
@ -56,7 +54,6 @@ func (r *Selector) Visit(fn VisitorFunc) error {
|
||||
list, err := NewHelper(r.Client, r.Mapping).List(
|
||||
r.Namespace,
|
||||
r.ResourceMapping().GroupVersionKind.GroupVersion().String(),
|
||||
r.Export,
|
||||
&metav1.ListOptions{
|
||||
LabelSelector: r.LabelSelector,
|
||||
FieldSelector: r.FieldSelector,
|
||||
|
@ -88,8 +88,6 @@ type Info struct {
|
||||
// but if set it should be equal to or newer than the resource version of the
|
||||
// object (however the server defines resource version).
|
||||
ResourceVersion string
|
||||
// Optional, should this resource be exported, stripped of cluster-specific and instance specific fields
|
||||
Export bool
|
||||
}
|
||||
|
||||
// Visit implements Visitor
|
||||
@ -99,7 +97,7 @@ func (i *Info) Visit(fn VisitorFunc) error {
|
||||
|
||||
// Get retrieves the object from the Namespace and Name fields
|
||||
func (i *Info) Get() (err error) {
|
||||
obj, err := NewHelper(i.Client, i.Mapping).Get(i.Namespace, i.Name, i.Export)
|
||||
obj, err := NewHelper(i.Client, i.Mapping).Get(i.Namespace, i.Name)
|
||||
if err != nil {
|
||||
if errors.IsNotFound(err) && len(i.Namespace) > 0 && i.Namespace != metav1.NamespaceDefault && i.Namespace != metav1.NamespaceAll {
|
||||
err2 := i.Client.Get().AbsPath("api", "v1", "namespaces", i.Namespace).Do(context.TODO()).Error()
|
||||
|
@ -191,7 +191,7 @@ func (p *Patcher) Patch(current runtime.Object, modified []byte, source, namespa
|
||||
if i > triesBeforeBackOff {
|
||||
p.BackOff.Sleep(backOffPeriod)
|
||||
}
|
||||
current, getErr = p.Helper.Get(namespace, name, false)
|
||||
current, getErr = p.Helper.Get(namespace, name)
|
||||
if getErr != nil {
|
||||
return nil, nil, getErr
|
||||
}
|
||||
@ -209,7 +209,7 @@ func (p *Patcher) deleteAndCreate(original runtime.Object, modified []byte, name
|
||||
}
|
||||
// TODO: use wait
|
||||
if err := wait.PollImmediate(1*time.Second, p.Timeout, func() (bool, error) {
|
||||
if _, err := p.Helper.Get(namespace, name, false); !errors.IsNotFound(err) {
|
||||
if _, err := p.Helper.Get(namespace, name); !errors.IsNotFound(err) {
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
|
@ -80,7 +80,6 @@ type GetOptions struct {
|
||||
NoHeaders bool
|
||||
Sort bool
|
||||
IgnoreNotFound bool
|
||||
Export bool
|
||||
|
||||
genericclioptions.IOStreams
|
||||
}
|
||||
@ -183,8 +182,6 @@ func NewCmdGet(parent string, f cmdutil.Factory, streams genericclioptions.IOStr
|
||||
cmd.Flags().BoolVarP(&o.AllNamespaces, "all-namespaces", "A", o.AllNamespaces, "If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace.")
|
||||
addOpenAPIPrintColumnFlags(cmd, o)
|
||||
addServerPrintColumnFlags(cmd, o)
|
||||
cmd.Flags().BoolVar(&o.Export, "export", o.Export, "If true, use 'export' for the resources. Exported resources are stripped of cluster-specific information.")
|
||||
cmd.Flags().MarkDeprecated("export", "This flag is deprecated and will be removed in future.")
|
||||
cmdutil.AddFilenameOptionFlags(cmd, &o.FilenameOptions, "identifying the resource to get from a server.")
|
||||
return cmd
|
||||
}
|
||||
@ -301,7 +298,7 @@ func (o *GetOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []stri
|
||||
// Validate checks the set of flags provided by the user.
|
||||
func (o *GetOptions) Validate(cmd *cobra.Command) error {
|
||||
if len(o.Raw) > 0 {
|
||||
if o.Watch || o.WatchOnly || len(o.LabelSelector) > 0 || o.Export {
|
||||
if o.Watch || o.WatchOnly || len(o.LabelSelector) > 0 {
|
||||
return fmt.Errorf("--raw may not be specified with other flags that filter the server request or alter the output")
|
||||
}
|
||||
if len(cmdutil.GetFlagString(cmd, "output")) > 0 {
|
||||
@ -473,7 +470,6 @@ func (o *GetOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []string) e
|
||||
FilenameParam(o.ExplicitNamespace, &o.FilenameOptions).
|
||||
LabelSelectorParam(o.LabelSelector).
|
||||
FieldSelectorParam(o.FieldSelector).
|
||||
ExportParam(o.Export).
|
||||
RequestChunksOf(chunkSize).
|
||||
ResourceTypeOrNameArgs(true, args...).
|
||||
ContinueOnError().
|
||||
@ -632,7 +628,6 @@ func (o *GetOptions) watch(f cmdutil.Factory, cmd *cobra.Command, args []string)
|
||||
FilenameParam(o.ExplicitNamespace, &o.FilenameOptions).
|
||||
LabelSelectorParam(o.LabelSelector).
|
||||
FieldSelectorParam(o.FieldSelector).
|
||||
ExportParam(o.Export).
|
||||
RequestChunksOf(o.ChunkSize).
|
||||
ResourceTypeOrNameArgs(true, args...).
|
||||
SingleResourceType().
|
||||
|
@ -105,8 +105,6 @@ run_pod_tests() {
|
||||
kube::test::describe_resource_events_assert pods false
|
||||
# Describe command should print events information when show-events=true
|
||||
kube::test::describe_resource_events_assert pods true
|
||||
### Validate Export ###
|
||||
kube::test::get_object_assert 'pods/valid-pod' "{{.metadata.namespace}} {{.metadata.name}}" '<no value> valid-pod' "--export=true"
|
||||
|
||||
### Dump current valid-pod POD
|
||||
output_pod=$(kubectl get pod valid-pod -o yaml "${kube_flags[@]}")
|
||||
|
Loading…
Reference in New Issue
Block a user