mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
Remove --export flag from kubectl get command.
This commit is contained in:
parent
454c13d09c
commit
c0562815fa
@ -100,8 +100,6 @@ type Builder struct {
|
|||||||
|
|
||||||
singleItemImplied bool
|
singleItemImplied bool
|
||||||
|
|
||||||
export bool
|
|
||||||
|
|
||||||
schema ContentValidator
|
schema ContentValidator
|
||||||
|
|
||||||
// fakeClientFn is used for testing
|
// fakeClientFn is used for testing
|
||||||
@ -461,12 +459,6 @@ func (b *Builder) FieldSelectorParam(s string) *Builder {
|
|||||||
return b
|
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
|
// NamespaceParam accepts the namespace that these resources should be
|
||||||
// considered under from - used by DefaultNamespace() and RequireNamespace()
|
// considered under from - used by DefaultNamespace() and RequireNamespace()
|
||||||
func (b *Builder) NamespaceParam(namespace string) *Builder {
|
func (b *Builder) NamespaceParam(namespace string) *Builder {
|
||||||
@ -870,7 +862,7 @@ func (b *Builder) visitBySelector() *Result {
|
|||||||
if mapping.Scope.Name() != meta.RESTScopeNameNamespace {
|
if mapping.Scope.Name() != meta.RESTScopeNameNamespace {
|
||||||
selectorNamespace = ""
|
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 {
|
if b.continueOnError {
|
||||||
result.visitor = EagerVisitorList(visitors)
|
result.visitor = EagerVisitorList(visitors)
|
||||||
@ -970,7 +962,6 @@ func (b *Builder) visitByResource() *Result {
|
|||||||
Mapping: mapping,
|
Mapping: mapping,
|
||||||
Namespace: selectorNamespace,
|
Namespace: selectorNamespace,
|
||||||
Name: tuple.Name,
|
Name: tuple.Name,
|
||||||
Export: b.export,
|
|
||||||
}
|
}
|
||||||
items = append(items, info)
|
items = append(items, info)
|
||||||
}
|
}
|
||||||
@ -1035,7 +1026,6 @@ func (b *Builder) visitByName() *Result {
|
|||||||
Mapping: mapping,
|
Mapping: mapping,
|
||||||
Namespace: selectorNamespace,
|
Namespace: selectorNamespace,
|
||||||
Name: name,
|
Name: name,
|
||||||
Export: b.export,
|
|
||||||
}
|
}
|
||||||
visitors = append(visitors, info)
|
visitors = append(visitors, info)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ package resource
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@ -75,27 +74,19 @@ func (m *Helper) WithFieldManager(fieldManager string) *Helper {
|
|||||||
return m
|
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().
|
req := m.RESTClient.Get().
|
||||||
NamespaceIfScoped(namespace, m.NamespaceScoped).
|
NamespaceIfScoped(namespace, m.NamespaceScoped).
|
||||||
Resource(m.Resource).
|
Resource(m.Resource).
|
||||||
Name(name)
|
Name(name)
|
||||||
if export {
|
|
||||||
// TODO: I should be part of GetOptions
|
|
||||||
req.Param("export", strconv.FormatBool(export))
|
|
||||||
}
|
|
||||||
return req.Do(context.TODO()).Get()
|
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().
|
req := m.RESTClient.Get().
|
||||||
NamespaceIfScoped(namespace, m.NamespaceScoped).
|
NamespaceIfScoped(namespace, m.NamespaceScoped).
|
||||||
Resource(m.Resource).
|
Resource(m.Resource).
|
||||||
VersionedParams(options, metav1.ParameterCodec)
|
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()
|
return req.Do(context.TODO()).Get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ func TestHelperGet(t *testing.T) {
|
|||||||
RESTClient: client,
|
RESTClient: client,
|
||||||
NamespaceScoped: true,
|
NamespaceScoped: true,
|
||||||
}
|
}
|
||||||
obj, err := modifier.Get("bar", "foo", false)
|
obj, err := modifier.Get("bar", "foo")
|
||||||
|
|
||||||
if (err != nil) != tt.Err {
|
if (err != nil) != tt.Err {
|
||||||
t.Errorf("unexpected error: %d %t %v", i, tt.Err, err)
|
t.Errorf("unexpected error: %d %t %v", i, tt.Err, err)
|
||||||
@ -393,7 +393,7 @@ func TestHelperList(t *testing.T) {
|
|||||||
RESTClient: client,
|
RESTClient: client,
|
||||||
NamespaceScoped: true,
|
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 {
|
if (err != nil) != tt.Err {
|
||||||
t.Errorf("unexpected error: %t %v", tt.Err, 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) {
|
t.Run(tt.Name, func(t *testing.T) {
|
||||||
_, err := modifier.List("bar",
|
_, err := modifier.List("bar",
|
||||||
corev1GV.String(),
|
corev1GV.String(),
|
||||||
false,
|
|
||||||
&metav1.ListOptions{LabelSelector: tt.LabelSelector, FieldSelector: tt.FieldSelector})
|
&metav1.ListOptions{LabelSelector: tt.LabelSelector, FieldSelector: tt.FieldSelector})
|
||||||
if tt.Err {
|
if tt.Err {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -32,19 +32,17 @@ type Selector struct {
|
|||||||
Namespace string
|
Namespace string
|
||||||
LabelSelector string
|
LabelSelector string
|
||||||
FieldSelector string
|
FieldSelector string
|
||||||
Export bool
|
|
||||||
LimitChunks int64
|
LimitChunks int64
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSelector creates a resource selector which hides details of getting items by their label selector.
|
// 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{
|
return &Selector{
|
||||||
Client: client,
|
Client: client,
|
||||||
Mapping: mapping,
|
Mapping: mapping,
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
LabelSelector: labelSelector,
|
LabelSelector: labelSelector,
|
||||||
FieldSelector: fieldSelector,
|
FieldSelector: fieldSelector,
|
||||||
Export: export,
|
|
||||||
LimitChunks: limitChunks,
|
LimitChunks: limitChunks,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,7 +54,6 @@ func (r *Selector) Visit(fn VisitorFunc) error {
|
|||||||
list, err := NewHelper(r.Client, r.Mapping).List(
|
list, err := NewHelper(r.Client, r.Mapping).List(
|
||||||
r.Namespace,
|
r.Namespace,
|
||||||
r.ResourceMapping().GroupVersionKind.GroupVersion().String(),
|
r.ResourceMapping().GroupVersionKind.GroupVersion().String(),
|
||||||
r.Export,
|
|
||||||
&metav1.ListOptions{
|
&metav1.ListOptions{
|
||||||
LabelSelector: r.LabelSelector,
|
LabelSelector: r.LabelSelector,
|
||||||
FieldSelector: r.FieldSelector,
|
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
|
// but if set it should be equal to or newer than the resource version of the
|
||||||
// object (however the server defines resource version).
|
// object (however the server defines resource version).
|
||||||
ResourceVersion string
|
ResourceVersion string
|
||||||
// Optional, should this resource be exported, stripped of cluster-specific and instance specific fields
|
|
||||||
Export bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Visit implements Visitor
|
// Visit implements Visitor
|
||||||
@ -99,7 +97,7 @@ func (i *Info) Visit(fn VisitorFunc) error {
|
|||||||
|
|
||||||
// Get retrieves the object from the Namespace and Name fields
|
// Get retrieves the object from the Namespace and Name fields
|
||||||
func (i *Info) Get() (err error) {
|
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 err != nil {
|
||||||
if errors.IsNotFound(err) && len(i.Namespace) > 0 && i.Namespace != metav1.NamespaceDefault && i.Namespace != metav1.NamespaceAll {
|
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()
|
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 {
|
if i > triesBeforeBackOff {
|
||||||
p.BackOff.Sleep(backOffPeriod)
|
p.BackOff.Sleep(backOffPeriod)
|
||||||
}
|
}
|
||||||
current, getErr = p.Helper.Get(namespace, name, false)
|
current, getErr = p.Helper.Get(namespace, name)
|
||||||
if getErr != nil {
|
if getErr != nil {
|
||||||
return nil, nil, getErr
|
return nil, nil, getErr
|
||||||
}
|
}
|
||||||
@ -209,7 +209,7 @@ func (p *Patcher) deleteAndCreate(original runtime.Object, modified []byte, name
|
|||||||
}
|
}
|
||||||
// TODO: use wait
|
// TODO: use wait
|
||||||
if err := wait.PollImmediate(1*time.Second, p.Timeout, func() (bool, error) {
|
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 false, err
|
||||||
}
|
}
|
||||||
return true, nil
|
return true, nil
|
||||||
|
@ -80,7 +80,6 @@ type GetOptions struct {
|
|||||||
NoHeaders bool
|
NoHeaders bool
|
||||||
Sort bool
|
Sort bool
|
||||||
IgnoreNotFound bool
|
IgnoreNotFound bool
|
||||||
Export bool
|
|
||||||
|
|
||||||
genericclioptions.IOStreams
|
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.")
|
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)
|
addOpenAPIPrintColumnFlags(cmd, o)
|
||||||
addServerPrintColumnFlags(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.")
|
cmdutil.AddFilenameOptionFlags(cmd, &o.FilenameOptions, "identifying the resource to get from a server.")
|
||||||
return cmd
|
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.
|
// Validate checks the set of flags provided by the user.
|
||||||
func (o *GetOptions) Validate(cmd *cobra.Command) error {
|
func (o *GetOptions) Validate(cmd *cobra.Command) error {
|
||||||
if len(o.Raw) > 0 {
|
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")
|
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 {
|
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).
|
FilenameParam(o.ExplicitNamespace, &o.FilenameOptions).
|
||||||
LabelSelectorParam(o.LabelSelector).
|
LabelSelectorParam(o.LabelSelector).
|
||||||
FieldSelectorParam(o.FieldSelector).
|
FieldSelectorParam(o.FieldSelector).
|
||||||
ExportParam(o.Export).
|
|
||||||
RequestChunksOf(chunkSize).
|
RequestChunksOf(chunkSize).
|
||||||
ResourceTypeOrNameArgs(true, args...).
|
ResourceTypeOrNameArgs(true, args...).
|
||||||
ContinueOnError().
|
ContinueOnError().
|
||||||
@ -632,7 +628,6 @@ func (o *GetOptions) watch(f cmdutil.Factory, cmd *cobra.Command, args []string)
|
|||||||
FilenameParam(o.ExplicitNamespace, &o.FilenameOptions).
|
FilenameParam(o.ExplicitNamespace, &o.FilenameOptions).
|
||||||
LabelSelectorParam(o.LabelSelector).
|
LabelSelectorParam(o.LabelSelector).
|
||||||
FieldSelectorParam(o.FieldSelector).
|
FieldSelectorParam(o.FieldSelector).
|
||||||
ExportParam(o.Export).
|
|
||||||
RequestChunksOf(o.ChunkSize).
|
RequestChunksOf(o.ChunkSize).
|
||||||
ResourceTypeOrNameArgs(true, args...).
|
ResourceTypeOrNameArgs(true, args...).
|
||||||
SingleResourceType().
|
SingleResourceType().
|
||||||
|
@ -105,8 +105,6 @@ run_pod_tests() {
|
|||||||
kube::test::describe_resource_events_assert pods false
|
kube::test::describe_resource_events_assert pods false
|
||||||
# Describe command should print events information when show-events=true
|
# Describe command should print events information when show-events=true
|
||||||
kube::test::describe_resource_events_assert pods 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
|
### Dump current valid-pod POD
|
||||||
output_pod=$(kubectl get pod valid-pod -o yaml "${kube_flags[@]}")
|
output_pod=$(kubectl get pod valid-pod -o yaml "${kube_flags[@]}")
|
||||||
|
Loading…
Reference in New Issue
Block a user