Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
5f8743ea
Commit
5f8743ea
authored
Nov 26, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #17108 from kargakis/fix-editor-env
Auto commit by PR queue bot
parents
39cabe35
523b6ec7
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
11 deletions
+26
-11
kubectl-edit.1
docs/man/man1/kubectl-edit.1
+2
-2
kubectl_edit.md
docs/user-guide/kubectl/kubectl_edit.md
+2
-2
edit.go
pkg/kubectl/cmd/edit.go
+3
-3
editor.go
pkg/kubectl/cmd/util/editor/editor.go
+12
-4
factory.go
pkg/kubectl/cmd/util/factory.go
+7
-0
No files found.
docs/man/man1/kubectl-edit.1
View file @
5f8743ea
...
...
@@ -17,8 +17,8 @@ Edit a resource from the default editor.
.PP
The edit command allows you to directly edit any API resource you can retrieve via the
command line tools. It will open the editor defined by your KUBE\_EDITOR,
GIT\_EDITOR,
or EDITOR
environment variables, or fall back to 'vi' for Linux or 'notepad' for Windows.
command line tools. It will open the editor defined by your KUBE\_EDITOR,
or EDITOR
environment variables, or fall back to 'vi' for Linux or 'notepad' for Windows.
You can edit multiple objects, although changes are applied one at a time. The command
accepts filenames as well as command line arguments, although the files you point to must
be previously saved versions of resources.
...
...
docs/user-guide/kubectl/kubectl_edit.md
View file @
5f8743ea
...
...
@@ -41,8 +41,8 @@ Edit a resource on the server
Edit a resource from the default editor.
The edit command allows you to directly edit any API resource you can retrieve via the
command line tools. It will open the editor defined by your KUBE_EDITOR,
GIT_EDITOR,
or EDITOR
environment variables, or fall back to 'vi' for Linux or 'notepad' for Windows.
command line tools. It will open the editor defined by your KUBE_EDITOR,
or EDITOR
environment variables, or fall back to 'vi' for Linux or 'notepad' for Windows.
You can edit multiple objects, although changes are applied one at a time. The command
accepts filenames as well as command line arguments, although the files you point to must
be previously saved versions of resources.
...
...
pkg/kubectl/cmd/edit.go
View file @
5f8743ea
...
...
@@ -46,8 +46,8 @@ const (
editLong
=
`Edit a resource from the default editor.
The edit command allows you to directly edit any API resource you can retrieve via the
command line tools. It will open the editor defined by your KUBE_EDITOR,
GIT_EDITOR,
or EDITOR
environment variables, or fall back to 'vi' for Linux or 'notepad' for Windows.
command line tools. It will open the editor defined by your KUBE_EDITOR,
or EDITOR
environment variables, or fall back to 'vi' for Linux or 'notepad' for Windows.
You can edit multiple objects, although changes are applied one at a time. The command
accepts filenames as well as command line arguments, although the files you point to must
be previously saved versions of resources.
...
...
@@ -148,7 +148,7 @@ func RunEdit(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []strin
}
windowsLineEndings
:=
cmdutil
.
GetFlagBool
(
cmd
,
"windows-line-endings"
)
edit
:=
editor
.
NewDefaultEditor
()
edit
:=
editor
.
NewDefaultEditor
(
f
.
EditorEnvs
()
)
defaultVersion
:=
cmdutil
.
OutputVersionFromGroupVersion
(
cmd
,
clientConfig
.
GroupVersion
)
results
:=
editResults
{}
for
{
...
...
pkg/kubectl/cmd/util/editor/editor.go
View file @
5f8743ea
...
...
@@ -53,8 +53,8 @@ type Editor struct {
// the proper command line. If the provided editor has no spaces, or no quotes,
// it is treated as a bare command to be loaded. Otherwise, the string will
// be passed to the user's shell for execution.
func
NewDefaultEditor
()
Editor
{
args
,
shell
:=
defaultEnvEditor
()
func
NewDefaultEditor
(
envs
[]
string
)
Editor
{
args
,
shell
:=
defaultEnvEditor
(
envs
)
return
Editor
{
Args
:
args
,
Shell
:
shell
,
...
...
@@ -73,8 +73,16 @@ func defaultEnvShell() []string {
return
[]
string
{
shell
,
flag
}
}
func
defaultEnvEditor
()
([]
string
,
bool
)
{
editor
:=
os
.
Getenv
(
"EDITOR"
)
func
defaultEnvEditor
(
envs
[]
string
)
([]
string
,
bool
)
{
var
editor
string
for
_
,
env
:=
range
envs
{
if
len
(
env
)
>
0
{
editor
=
os
.
Getenv
(
env
)
}
if
len
(
editor
)
>
0
{
break
}
}
if
len
(
editor
)
==
0
{
editor
=
platformize
(
defaultEditor
,
windowsEditor
)
}
...
...
pkg/kubectl/cmd/util/factory.go
View file @
5f8743ea
...
...
@@ -101,6 +101,10 @@ type Factory struct {
CanBeAutoscaled
func
(
kind
string
)
error
// AttachablePodForObject returns the pod to which to attach given an object.
AttachablePodForObject
func
(
object
runtime
.
Object
)
(
*
api
.
Pod
,
error
)
// EditorEnvs returns a group of environment variables that the edit command
// can range over in order to determine if the user has specified an editor
// of their choice.
EditorEnvs
func
()
[]
string
}
// NewFactory creates a factory with the default Kubernetes resources defined
...
...
@@ -331,6 +335,9 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
return
nil
,
fmt
.
Errorf
(
"cannot attach to %s: not implemented"
,
kind
)
}
},
EditorEnvs
:
func
()
[]
string
{
return
[]
string
{
"KUBE_EDITOR"
,
"EDITOR"
}
},
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment