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
66e350ea
Commit
66e350ea
authored
Mar 16, 2022
by
Brad Davidson
Committed by
Brad Davidson
Mar 16, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track upstream changes to kubectl command execution
Signed-off-by:
Brad Davidson
<
brad.davidson@rancher.com
>
parent
de889a00
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
18 deletions
+4
-18
go.mod
go.mod
+0
-1
main.go
pkg/kubectl/main.go
+4
-17
No files found.
go.mod
View file @
66e350ea
...
...
@@ -102,7 +102,6 @@ require (
github.com/robfig/cron/v3 v3.0.1
github.com/rootless-containers/rootlesskit v0.14.5
github.com/sirupsen/logrus v1.8.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.7.0
github.com/tchap/go-patricia v2.3.0+incompatible // indirect
github.com/urfave/cli v1.22.4
...
...
pkg/kubectl/main.go
View file @
66e350ea
package
kubectl
import
(
goflag
"flag"
"fmt"
"math/rand"
"os"
...
...
@@ -10,10 +9,9 @@ import (
"github.com/k3s-io/k3s/pkg/server"
"github.com/sirupsen/logrus"
"github.com/spf13/pflag"
utilflag
"k8s.io/component-base/cli/flag"
"k8s.io/component-base/logs"
"k8s.io/component-base/cli"
"k8s.io/kubectl/pkg/cmd"
"k8s.io/kubectl/pkg/cmd/util"
)
func
Main
()
{
...
...
@@ -42,19 +40,8 @@ func main() {
rand
.
Seed
(
time
.
Now
()
.
UnixNano
())
command
:=
cmd
.
NewDefaultKubectlCommand
()
// TODO: once we switch everything over to Cobra commands, we can go back to calling
// utilflag.InitFlags() (by removing its pflag.Parse() call). For now, we have to set the
// normalize func and add the go flag set by hand.
pflag
.
CommandLine
.
SetNormalizeFunc
(
utilflag
.
WordSepNormalizeFunc
)
pflag
.
CommandLine
.
AddGoFlagSet
(
goflag
.
CommandLine
)
// utilflag.InitFlags()
logs
.
InitLogs
()
defer
logs
.
FlushLogs
()
if
err
:=
command
.
Execute
();
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"%v
\n
"
,
err
)
os
.
Exit
(
1
)
if
err
:=
cli
.
RunNoErrOutput
(
command
);
err
!=
nil
{
util
.
CheckErr
(
err
)
}
}
...
...
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