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
2129bc9f
Unverified
Commit
2129bc9f
authored
Oct 13, 2018
by
k8s-ci-robot
Committed by
GitHub
Oct 13, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #69742 from apelisse/fix-diff-error
Rename KUBERNETES_EXTERNAL_DIFF to KUBECTL_EXTERNAL_DIFF
parents
653b0272
572a0281
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
12 deletions
+8
-12
diff.go
pkg/kubectl/cmd/diff/diff.go
+5
-9
diff_test.go
pkg/kubectl/cmd/diff/diff_test.go
+1
-1
diff.sh
test/cmd/diff.sh
+2
-2
No files found.
pkg/kubectl/cmd/diff/diff.go
View file @
2129bc9f
...
@@ -49,7 +49,7 @@ var (
...
@@ -49,7 +49,7 @@ var (
Output is always YAML.
Output is always YAML.
KUBE
RNETES
_EXTERNAL_DIFF environment variable can be used to select your own
KUBE
CTL
_EXTERNAL_DIFF environment variable can be used to select your own
diff command. By default, the "diff" command available in your path will be
diff command. By default, the "diff" command available in your path will be
run with "-u" (unicode) and "-N" (treat new files as empty) options.`
))
run with "-u" (unicode) and "-N" (treat new files as empty) options.`
))
diffExample
=
templates
.
Examples
(
i18n
.
T
(
`
diffExample
=
templates
.
Examples
(
i18n
.
T
(
`
...
@@ -97,7 +97,7 @@ func NewCmdDiff(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.C
...
@@ -97,7 +97,7 @@ func NewCmdDiff(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.C
}
}
// DiffProgram finds and run the diff program. The value of
// DiffProgram finds and run the diff program. The value of
// KUBE
RNETES
_EXTERNAL_DIFF environment variable will be used a diff
// KUBE
CTL
_EXTERNAL_DIFF environment variable will be used a diff
// program. By default, `diff(1)` will be used.
// program. By default, `diff(1)` will be used.
type
DiffProgram
struct
{
type
DiffProgram
struct
{
Exec
exec
.
Interface
Exec
exec
.
Interface
...
@@ -106,7 +106,7 @@ type DiffProgram struct {
...
@@ -106,7 +106,7 @@ type DiffProgram struct {
func
(
d
*
DiffProgram
)
getCommand
(
args
...
string
)
exec
.
Cmd
{
func
(
d
*
DiffProgram
)
getCommand
(
args
...
string
)
exec
.
Cmd
{
diff
:=
""
diff
:=
""
if
envDiff
:=
os
.
Getenv
(
"KUBE
RNETES
_EXTERNAL_DIFF"
);
envDiff
!=
""
{
if
envDiff
:=
os
.
Getenv
(
"KUBE
CTL
_EXTERNAL_DIFF"
);
envDiff
!=
""
{
diff
=
envDiff
diff
=
envDiff
}
else
{
}
else
{
diff
=
"diff"
diff
=
"diff"
...
@@ -122,8 +122,7 @@ func (d *DiffProgram) getCommand(args ...string) exec.Cmd {
...
@@ -122,8 +122,7 @@ func (d *DiffProgram) getCommand(args ...string) exec.Cmd {
// Run runs the detected diff program. `from` and `to` are the directory to diff.
// Run runs the detected diff program. `from` and `to` are the directory to diff.
func
(
d
*
DiffProgram
)
Run
(
from
,
to
string
)
error
{
func
(
d
*
DiffProgram
)
Run
(
from
,
to
string
)
error
{
d
.
getCommand
(
from
,
to
)
.
Run
()
// Ignore diff return code
return
d
.
getCommand
(
from
,
to
)
.
Run
()
return
nil
}
}
// Printer is used to print an object.
// Printer is used to print an object.
...
@@ -397,8 +396,5 @@ func RunDiff(f cmdutil.Factory, diff *DiffProgram, options *DiffOptions) error {
...
@@ -397,8 +396,5 @@ func RunDiff(f cmdutil.Factory, diff *DiffProgram, options *DiffOptions) error {
return
err
return
err
}
}
// Error ignore on purpose. diff(1) for example, returns an error if there is any diff.
return
differ
.
Run
(
diff
)
_
=
differ
.
Run
(
diff
)
return
nil
}
}
pkg/kubectl/cmd/diff/diff_test.go
View file @
2129bc9f
...
@@ -52,7 +52,7 @@ func (f *FakeObject) Live() runtime.Object {
...
@@ -52,7 +52,7 @@ func (f *FakeObject) Live() runtime.Object {
}
}
func
TestDiffProgram
(
t
*
testing
.
T
)
{
func
TestDiffProgram
(
t
*
testing
.
T
)
{
os
.
Setenv
(
"KUBE
RNETES
_EXTERNAL_DIFF"
,
"echo"
)
os
.
Setenv
(
"KUBE
CTL
_EXTERNAL_DIFF"
,
"echo"
)
streams
,
_
,
stdout
,
_
:=
genericclioptions
.
NewTestIOStreams
()
streams
,
_
,
stdout
,
_
:=
genericclioptions
.
NewTestIOStreams
()
diff
:=
DiffProgram
{
diff
:=
DiffProgram
{
IOStreams
:
streams
,
IOStreams
:
streams
,
...
...
test/cmd/diff.sh
View file @
2129bc9f
...
@@ -27,12 +27,12 @@ run_kubectl_diff_tests() {
...
@@ -27,12 +27,12 @@ run_kubectl_diff_tests() {
kube::log::status
"Testing kubectl diff"
kube::log::status
"Testing kubectl diff"
# Test that it works when the live object doesn't exist
# Test that it works when the live object doesn't exist
output_message
=
$(
kubectl diff
-f
hack/testdata/pod.yaml
)
output_message
=
$(
!
kubectl diff
-f
hack/testdata/pod.yaml
)
kube::test::if_has_string
"
${
output_message
}
"
'test-pod'
kube::test::if_has_string
"
${
output_message
}
"
'test-pod'
kubectl apply
-f
hack/testdata/pod.yaml
kubectl apply
-f
hack/testdata/pod.yaml
output_message
=
$(
kubectl diff
-f
hack/testdata/pod-changed.yaml
)
output_message
=
$(
!
kubectl diff
-f
hack/testdata/pod-changed.yaml
)
kube::test::if_has_string
"
${
output_message
}
"
'k8s.gcr.io/pause:3.0'
kube::test::if_has_string
"
${
output_message
}
"
'k8s.gcr.io/pause:3.0'
kubectl delete
-f
hack/testdata/pod.yaml
kubectl delete
-f
hack/testdata/pod.yaml
...
...
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