Skip to content

Commit 1faf097

Browse files
authored
Merge pull request kubernetes#88649 from oke-py/remove-deprecated-export
Remove --export flag from kubectl get command.
2 parents aa348b1 + c056281 commit 1faf097

File tree

8 files changed

+10
-42
lines changed

8 files changed

+10
-42
lines changed

staging/src/k8s.io/cli-runtime/pkg/resource/builder.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ type Builder struct {
100100

101101
singleItemImplied bool
102102

103-
export bool
104-
105103
schema ContentValidator
106104

107105
// fakeClientFn is used for testing
@@ -461,12 +459,6 @@ func (b *Builder) FieldSelectorParam(s string) *Builder {
461459
return b
462460
}
463461

464-
// ExportParam accepts the export boolean for these resources
465-
func (b *Builder) ExportParam(export bool) *Builder {
466-
b.export = export
467-
return b
468-
}
469-
470462
// NamespaceParam accepts the namespace that these resources should be
471463
// considered under from - used by DefaultNamespace() and RequireNamespace()
472464
func (b *Builder) NamespaceParam(namespace string) *Builder {
@@ -870,7 +862,7 @@ func (b *Builder) visitBySelector() *Result {
870862
if mapping.Scope.Name() != meta.RESTScopeNameNamespace {
871863
selectorNamespace = ""
872864
}
873-
visitors = append(visitors, NewSelector(client, mapping, selectorNamespace, labelSelector, fieldSelector, b.export, b.limitChunks))
865+
visitors = append(visitors, NewSelector(client, mapping, selectorNamespace, labelSelector, fieldSelector, b.limitChunks))
874866
}
875867
if b.continueOnError {
876868
result.visitor = EagerVisitorList(visitors)
@@ -970,7 +962,6 @@ func (b *Builder) visitByResource() *Result {
970962
Mapping: mapping,
971963
Namespace: selectorNamespace,
972964
Name: tuple.Name,
973-
Export: b.export,
974965
}
975966
items = append(items, info)
976967
}
@@ -1035,7 +1026,6 @@ func (b *Builder) visitByName() *Result {
10351026
Mapping: mapping,
10361027
Namespace: selectorNamespace,
10371028
Name: name,
1038-
Export: b.export,
10391029
}
10401030
visitors = append(visitors, info)
10411031
}

staging/src/k8s.io/cli-runtime/pkg/resource/helper.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package resource
1818

1919
import (
2020
"context"
21-
"strconv"
2221

2322
"k8s.io/apimachinery/pkg/api/meta"
2423
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -75,27 +74,19 @@ func (m *Helper) WithFieldManager(fieldManager string) *Helper {
7574
return m
7675
}
7776

78-
func (m *Helper) Get(namespace, name string, export bool) (runtime.Object, error) {
77+
func (m *Helper) Get(namespace, name string) (runtime.Object, error) {
7978
req := m.RESTClient.Get().
8079
NamespaceIfScoped(namespace, m.NamespaceScoped).
8180
Resource(m.Resource).
8281
Name(name)
83-
if export {
84-
// TODO: I should be part of GetOptions
85-
req.Param("export", strconv.FormatBool(export))
86-
}
8782
return req.Do(context.TODO()).Get()
8883
}
8984

90-
func (m *Helper) List(namespace, apiVersion string, export bool, options *metav1.ListOptions) (runtime.Object, error) {
85+
func (m *Helper) List(namespace, apiVersion string, options *metav1.ListOptions) (runtime.Object, error) {
9186
req := m.RESTClient.Get().
9287
NamespaceIfScoped(namespace, m.NamespaceScoped).
9388
Resource(m.Resource).
9489
VersionedParams(options, metav1.ParameterCodec)
95-
if export {
96-
// TODO: I should be part of ListOptions
97-
req.Param("export", strconv.FormatBool(export))
98-
}
9990
return req.Do(context.TODO()).Get()
10091
}
10192

staging/src/k8s.io/cli-runtime/pkg/resource/helper_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ func TestHelperGet(t *testing.T) {
312312
RESTClient: client,
313313
NamespaceScoped: true,
314314
}
315-
obj, err := modifier.Get("bar", "foo", false)
315+
obj, err := modifier.Get("bar", "foo")
316316

317317
if (err != nil) != tt.Err {
318318
t.Errorf("unexpected error: %d %t %v", i, tt.Err, err)
@@ -393,7 +393,7 @@ func TestHelperList(t *testing.T) {
393393
RESTClient: client,
394394
NamespaceScoped: true,
395395
}
396-
obj, err := modifier.List("bar", corev1GV.String(), false, &metav1.ListOptions{LabelSelector: "foo=baz"})
396+
obj, err := modifier.List("bar", corev1GV.String(), &metav1.ListOptions{LabelSelector: "foo=baz"})
397397
if (err != nil) != tt.Err {
398398
t.Errorf("unexpected error: %t %v", tt.Err, err)
399399
}
@@ -464,7 +464,6 @@ func TestHelperListSelectorCombination(t *testing.T) {
464464
t.Run(tt.Name, func(t *testing.T) {
465465
_, err := modifier.List("bar",
466466
corev1GV.String(),
467-
false,
468467
&metav1.ListOptions{LabelSelector: tt.LabelSelector, FieldSelector: tt.FieldSelector})
469468
if tt.Err {
470469
if err == nil {

staging/src/k8s.io/cli-runtime/pkg/resource/selector.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,17 @@ type Selector struct {
3232
Namespace string
3333
LabelSelector string
3434
FieldSelector string
35-
Export bool
3635
LimitChunks int64
3736
}
3837

3938
// NewSelector creates a resource selector which hides details of getting items by their label selector.
40-
func NewSelector(client RESTClient, mapping *meta.RESTMapping, namespace, labelSelector, fieldSelector string, export bool, limitChunks int64) *Selector {
39+
func NewSelector(client RESTClient, mapping *meta.RESTMapping, namespace, labelSelector, fieldSelector string, limitChunks int64) *Selector {
4140
return &Selector{
4241
Client: client,
4342
Mapping: mapping,
4443
Namespace: namespace,
4544
LabelSelector: labelSelector,
4645
FieldSelector: fieldSelector,
47-
Export: export,
4846
LimitChunks: limitChunks,
4947
}
5048
}
@@ -56,7 +54,6 @@ func (r *Selector) Visit(fn VisitorFunc) error {
5654
list, err := NewHelper(r.Client, r.Mapping).List(
5755
r.Namespace,
5856
r.ResourceMapping().GroupVersionKind.GroupVersion().String(),
59-
r.Export,
6057
&metav1.ListOptions{
6158
LabelSelector: r.LabelSelector,
6259
FieldSelector: r.FieldSelector,

staging/src/k8s.io/cli-runtime/pkg/resource/visitor.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ type Info struct {
8888
// but if set it should be equal to or newer than the resource version of the
8989
// object (however the server defines resource version).
9090
ResourceVersion string
91-
// Optional, should this resource be exported, stripped of cluster-specific and instance specific fields
92-
Export bool
9391
}
9492

9593
// Visit implements Visitor
@@ -99,7 +97,7 @@ func (i *Info) Visit(fn VisitorFunc) error {
9997

10098
// Get retrieves the object from the Namespace and Name fields
10199
func (i *Info) Get() (err error) {
102-
obj, err := NewHelper(i.Client, i.Mapping).Get(i.Namespace, i.Name, i.Export)
100+
obj, err := NewHelper(i.Client, i.Mapping).Get(i.Namespace, i.Name)
103101
if err != nil {
104102
if errors.IsNotFound(err) && len(i.Namespace) > 0 && i.Namespace != metav1.NamespaceDefault && i.Namespace != metav1.NamespaceAll {
105103
err2 := i.Client.Get().AbsPath("api", "v1", "namespaces", i.Namespace).Do(context.TODO()).Error()

staging/src/k8s.io/kubectl/pkg/cmd/apply/patcher.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func (p *Patcher) Patch(current runtime.Object, modified []byte, source, namespa
191191
if i > triesBeforeBackOff {
192192
p.BackOff.Sleep(backOffPeriod)
193193
}
194-
current, getErr = p.Helper.Get(namespace, name, false)
194+
current, getErr = p.Helper.Get(namespace, name)
195195
if getErr != nil {
196196
return nil, nil, getErr
197197
}
@@ -209,7 +209,7 @@ func (p *Patcher) deleteAndCreate(original runtime.Object, modified []byte, name
209209
}
210210
// TODO: use wait
211211
if err := wait.PollImmediate(1*time.Second, p.Timeout, func() (bool, error) {
212-
if _, err := p.Helper.Get(namespace, name, false); !errors.IsNotFound(err) {
212+
if _, err := p.Helper.Get(namespace, name); !errors.IsNotFound(err) {
213213
return false, err
214214
}
215215
return true, nil

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ type GetOptions struct {
8080
NoHeaders bool
8181
Sort bool
8282
IgnoreNotFound bool
83-
Export bool
8483

8584
genericclioptions.IOStreams
8685
}
@@ -183,8 +182,6 @@ func NewCmdGet(parent string, f cmdutil.Factory, streams genericclioptions.IOStr
183182
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.")
184183
addOpenAPIPrintColumnFlags(cmd, o)
185184
addServerPrintColumnFlags(cmd, o)
186-
cmd.Flags().BoolVar(&o.Export, "export", o.Export, "If true, use 'export' for the resources. Exported resources are stripped of cluster-specific information.")
187-
cmd.Flags().MarkDeprecated("export", "This flag is deprecated and will be removed in future.")
188185
cmdutil.AddFilenameOptionFlags(cmd, &o.FilenameOptions, "identifying the resource to get from a server.")
189186
return cmd
190187
}
@@ -301,7 +298,7 @@ func (o *GetOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []stri
301298
// Validate checks the set of flags provided by the user.
302299
func (o *GetOptions) Validate(cmd *cobra.Command) error {
303300
if len(o.Raw) > 0 {
304-
if o.Watch || o.WatchOnly || len(o.LabelSelector) > 0 || o.Export {
301+
if o.Watch || o.WatchOnly || len(o.LabelSelector) > 0 {
305302
return fmt.Errorf("--raw may not be specified with other flags that filter the server request or alter the output")
306303
}
307304
if len(cmdutil.GetFlagString(cmd, "output")) > 0 {
@@ -473,7 +470,6 @@ func (o *GetOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []string) e
473470
FilenameParam(o.ExplicitNamespace, &o.FilenameOptions).
474471
LabelSelectorParam(o.LabelSelector).
475472
FieldSelectorParam(o.FieldSelector).
476-
ExportParam(o.Export).
477473
RequestChunksOf(chunkSize).
478474
ResourceTypeOrNameArgs(true, args...).
479475
ContinueOnError().
@@ -632,7 +628,6 @@ func (o *GetOptions) watch(f cmdutil.Factory, cmd *cobra.Command, args []string)
632628
FilenameParam(o.ExplicitNamespace, &o.FilenameOptions).
633629
LabelSelectorParam(o.LabelSelector).
634630
FieldSelectorParam(o.FieldSelector).
635-
ExportParam(o.Export).
636631
RequestChunksOf(o.ChunkSize).
637632
ResourceTypeOrNameArgs(true, args...).
638633
SingleResourceType().

test/cmd/core.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ run_pod_tests() {
105105
kube::test::describe_resource_events_assert pods false
106106
# Describe command should print events information when show-events=true
107107
kube::test::describe_resource_events_assert pods true
108-
### Validate Export ###
109-
kube::test::get_object_assert 'pods/valid-pod' "{{.metadata.namespace}} {{.metadata.name}}" '<no value> valid-pod' "--export=true"
110108

111109
### Dump current valid-pod POD
112110
output_pod=$(kubectl get pod valid-pod -o yaml "${kube_flags[@]}")

0 commit comments

Comments
 (0)