14
14
* limitations under the License.
15
15
*/
16
16
17
- import Debug from 'debug'
18
17
import {
19
18
Arguments ,
20
19
Registrar ,
@@ -35,8 +34,6 @@ import { doGet, doGetAsMMR, getFlags as flags } from './get'
35
34
import { isKubeResource } from '../../lib/model/resource'
36
35
import { KubeOptions , isTableRequest , isWatchRequest } from './options'
37
36
38
- const debug = Debug ( 'plugin-kubectl/controller/kubectl/get/namespace' )
39
-
40
37
/**
41
38
* Summarize the resources in the namespace indicated by the last
42
39
* positional argument into a table, where resources are histogrammed
@@ -89,33 +86,6 @@ function doSummarizeNamespace(args: Arguments<KubeOptions>): Promise<Table> {
89
86
return doSummarizeNamedNamespace ( args . tab , ns )
90
87
}
91
88
92
- /**
93
- * Switch to the namespace indicated by the last positional argument,
94
- * then summarize the resources in that namespace in a table.
95
- *
96
- */
97
- async function doSwitchNamespace ( args : Arguments < KubeOptions > ) : Promise < true | Table > {
98
- // switch to this namespace
99
- const ns = args . argvNoOptions [ args . argvNoOptions . length - 1 ]
100
-
101
- // this does the actual switch
102
- await args . REPL . qexec ( `kubectl config set-context --current --namespace=${ ns } ` )
103
-
104
- let summarizeNamespaceOnSwitch = false
105
- try {
106
- summarizeNamespaceOnSwitch = require ( '@kui-shell/client/config.d/kubectl.json' ) . summarizeNamespaceOnSwitch
107
- } catch ( err ) {
108
- debug ( 'using default value for summarizeNamespaceOnSwitch' , err )
109
- }
110
-
111
- if ( ! summarizeNamespaceOnSwitch ) {
112
- // client config told us not to summarize namespace on switch
113
- return true
114
- }
115
-
116
- return doSummarizeNamespace ( args )
117
- }
118
-
119
89
/**
120
90
* @return the currently active namespace in the currently selected context
121
91
*
@@ -178,7 +148,7 @@ async function asRadioTable(args: Arguments<KubeOptions>, { header, body }: Tabl
178
148
Object . assign ( rtRow , {
179
149
onSelect : ( ) => {
180
150
const ns = radioTableCellToString ( rtRow . cells [ rtRow . nameIdx ] )
181
- args . REPL . pexec ( `namespace switch ns ${ ns } ` )
151
+ args . REPL . pexec ( `kubectl config set-context --current --namespace= ${ ns } ` )
182
152
}
183
153
} )
184
154
)
@@ -232,6 +202,4 @@ export default (commandTree: Registrar) => {
232
202
233
203
commandTree . listen ( `/${ commandPrefix } /namespace/current` , doGetCurrentNamespace , flags )
234
204
commandTree . listen ( `/${ commandPrefix } /namespace/summarize` , doSummarizeNamespace , flags )
235
- commandTree . listen ( `/${ commandPrefix } /namespace/switch` , doSwitchNamespace , flags )
236
- commandTree . listen ( `/${ commandPrefix } /ns/switch` , doSwitchNamespace , flags )
237
205
}
0 commit comments