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
56147c51
Commit
56147c51
authored
Jan 17, 2017
by
Maciej Szulik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow setting copyright header file for generated completions
parent
e1900f70
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
13 deletions
+11
-13
cmd.go
pkg/kubectl/cmd/cmd.go
+1
-1
completion.go
pkg/kubectl/cmd/completion.go
+10
-12
No files found.
pkg/kubectl/cmd/cmd.go
View file @
56147c51
...
...
@@ -301,7 +301,7 @@ func NewKubectlCommand(f cmdutil.Factory, in io.Reader, out, err io.Writer) *cob
Commands
:
[]
*
cobra
.
Command
{
NewCmdLabel
(
f
,
out
),
NewCmdAnnotate
(
f
,
out
),
NewCmdCompletion
(
f
,
out
),
NewCmdCompletion
(
f
,
out
,
""
),
},
},
}
...
...
pkg/kubectl/cmd/completion.go
View file @
56147c51
...
...
@@ -26,7 +26,7 @@ import (
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
)
const
b
oilerPlate
=
`
const
defaultB
oilerPlate
=
`
# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
...
...
@@ -86,7 +86,7 @@ var (
}
)
func
NewCmdCompletion
(
f
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdCompletion
(
f
cmdutil
.
Factory
,
out
io
.
Writer
,
boilerPlate
string
)
*
cobra
.
Command
{
shells
:=
[]
string
{}
for
s
:=
range
completion_shells
{
shells
=
append
(
shells
,
s
)
...
...
@@ -98,7 +98,7 @@ func NewCmdCompletion(f cmdutil.Factory, out io.Writer) *cobra.Command {
Long
:
completion_long
,
Example
:
completion_example
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
err
:=
RunCompletion
(
out
,
cmd
,
args
)
err
:=
RunCompletion
(
out
,
boilerPlate
,
cmd
,
args
)
cmdutil
.
CheckErr
(
err
)
},
ValidArgs
:
shells
,
...
...
@@ -107,7 +107,7 @@ func NewCmdCompletion(f cmdutil.Factory, out io.Writer) *cobra.Command {
return
cmd
}
func
RunCompletion
(
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
RunCompletion
(
out
io
.
Writer
,
boilerPlate
string
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
len
(
args
)
==
0
{
return
cmdutil
.
UsageError
(
cmd
,
"Shell not specified."
)
}
...
...
@@ -119,22 +119,20 @@ func RunCompletion(out io.Writer, cmd *cobra.Command, args []string) error {
return
cmdutil
.
UsageError
(
cmd
,
"Unsupported shell type %q."
,
args
[
0
])
}
if
len
(
boilerPlate
)
==
0
{
boilerPlate
=
defaultBoilerPlate
}
if
_
,
err
:=
out
.
Write
([]
byte
(
boilerPlate
));
err
!=
nil
{
return
err
}
return
run
(
out
,
cmd
.
Parent
())
}
func
runCompletionBash
(
out
io
.
Writer
,
kubectl
*
cobra
.
Command
)
error
{
_
,
err
:=
out
.
Write
([]
byte
(
boilerPlate
))
if
err
!=
nil
{
return
err
}
return
kubectl
.
GenBashCompletion
(
out
)
}
func
runCompletionZsh
(
out
io
.
Writer
,
kubectl
*
cobra
.
Command
)
error
{
_
,
err
:=
out
.
Write
([]
byte
(
boilerPlate
))
if
err
!=
nil
{
return
err
}
zsh_initialization
:=
`
__kubectl_bash_source() {
alias shopt=':'
...
...
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