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
49258593
Commit
49258593
authored
May 22, 2018
by
David Eads
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a discarding printer for testing and delegation
parent
0d0863ea
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
42 additions
and
12 deletions
+42
-12
delete.go
pkg/kubectl/cmd/delete.go
+2
-1
BUILD
pkg/kubectl/cmd/wait/BUILD
+1
-0
wait.go
pkg/kubectl/cmd/wait/wait.go
+0
-9
wait_test.go
pkg/kubectl/cmd/wait/wait_test.go
+3
-2
BUILD
pkg/kubectl/genericclioptions/printers/BUILD
+1
-0
discard.go
pkg/kubectl/genericclioptions/printers/discard.go
+30
-0
interface.go
pkg/kubectl/genericclioptions/printers/interface.go
+5
-0
No files found.
pkg/kubectl/cmd/delete.go
View file @
49258593
...
@@ -34,6 +34,7 @@ import (
...
@@ -34,6 +34,7 @@ import (
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
kubectlwait
"k8s.io/kubernetes/pkg/kubectl/cmd/wait"
kubectlwait
"k8s.io/kubernetes/pkg/kubectl/cmd/wait"
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers"
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/resource"
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/resource"
"k8s.io/kubernetes/pkg/kubectl/util/i18n"
"k8s.io/kubernetes/pkg/kubectl/util/i18n"
)
)
...
@@ -335,7 +336,7 @@ func (o *DeleteOptions) DeleteResult(r *resource.Result) error {
...
@@ -335,7 +336,7 @@ func (o *DeleteOptions) DeleteResult(r *resource.Result) error {
DynamicClient
:
o
.
DynamicClient
,
DynamicClient
:
o
.
DynamicClient
,
Timeout
:
effectiveTimeout
,
Timeout
:
effectiveTimeout
,
Printer
:
kubectlwait
.
NewDiscardingPrinter
(),
Printer
:
printers
.
NewDiscardingPrinter
(),
ConditionFn
:
kubectlwait
.
IsDeleted
,
ConditionFn
:
kubectlwait
.
IsDeleted
,
IOStreams
:
o
.
IOStreams
,
IOStreams
:
o
.
IOStreams
,
}
}
...
...
pkg/kubectl/cmd/wait/BUILD
View file @
49258593
...
@@ -46,6 +46,7 @@ go_test(
...
@@ -46,6 +46,7 @@ go_test(
embed = [":go_default_library"],
embed = [":go_default_library"],
deps = [
deps = [
"//pkg/kubectl/genericclioptions:go_default_library",
"//pkg/kubectl/genericclioptions:go_default_library",
"//pkg/kubectl/genericclioptions/printers:go_default_library",
"//pkg/kubectl/genericclioptions/resource:go_default_library",
"//pkg/kubectl/genericclioptions/resource:go_default_library",
"//vendor/github.com/davecgh/go-spew/spew:go_default_library",
"//vendor/github.com/davecgh/go-spew/spew:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
...
...
pkg/kubectl/cmd/wait/wait.go
View file @
49258593
...
@@ -18,7 +18,6 @@ package wait
...
@@ -18,7 +18,6 @@ package wait
import
(
import
(
"fmt"
"fmt"
"io"
"strings"
"strings"
"time"
"time"
...
@@ -320,11 +319,3 @@ func (w ConditionalWait) isConditionMet(event watch.Event) (bool, error) {
...
@@ -320,11 +319,3 @@ func (w ConditionalWait) isConditionMet(event watch.Event) (bool, error) {
obj
:=
event
.
Object
.
(
*
unstructured
.
Unstructured
)
obj
:=
event
.
Object
.
(
*
unstructured
.
Unstructured
)
return
w
.
checkCondition
(
obj
)
return
w
.
checkCondition
(
obj
)
}
}
// NewDiscardingPrinter is a printer that discards all objects
// TODO use the real discarding printer from a different pull I just opened.
func
NewDiscardingPrinter
()
printers
.
ResourcePrinterFunc
{
return
printers
.
ResourcePrinterFunc
(
func
(
runtime
.
Object
,
io
.
Writer
)
error
{
return
nil
})
}
pkg/kubectl/cmd/wait/wait_test.go
View file @
49258593
...
@@ -34,6 +34,7 @@ import (
...
@@ -34,6 +34,7 @@ import (
dynamicfakeclient
"k8s.io/client-go/dynamic/fake"
dynamicfakeclient
"k8s.io/client-go/dynamic/fake"
clienttesting
"k8s.io/client-go/testing"
clienttesting
"k8s.io/client-go/testing"
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers"
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/resource"
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/resource"
)
)
...
@@ -222,7 +223,7 @@ func TestWaitForDeletion(t *testing.T) {
...
@@ -222,7 +223,7 @@ func TestWaitForDeletion(t *testing.T) {
DynamicClient
:
fakeClient
,
DynamicClient
:
fakeClient
,
Timeout
:
test
.
timeout
,
Timeout
:
test
.
timeout
,
Printer
:
NewDiscardingPrinter
(),
Printer
:
printers
.
NewDiscardingPrinter
(),
ConditionFn
:
IsDeleted
,
ConditionFn
:
IsDeleted
,
IOStreams
:
genericclioptions
.
NewTestIOStreamsDiscard
(),
IOStreams
:
genericclioptions
.
NewTestIOStreamsDiscard
(),
}
}
...
@@ -454,7 +455,7 @@ func TestWaitForCondition(t *testing.T) {
...
@@ -454,7 +455,7 @@ func TestWaitForCondition(t *testing.T) {
DynamicClient
:
fakeClient
,
DynamicClient
:
fakeClient
,
Timeout
:
test
.
timeout
,
Timeout
:
test
.
timeout
,
Printer
:
NewDiscardingPrinter
(),
Printer
:
printers
.
NewDiscardingPrinter
(),
ConditionFn
:
ConditionalWait
{
conditionName
:
"the-condition"
,
conditionStatus
:
"status-value"
}
.
IsConditionMet
,
ConditionFn
:
ConditionalWait
{
conditionName
:
"the-condition"
,
conditionStatus
:
"status-value"
}
.
IsConditionMet
,
IOStreams
:
genericclioptions
.
NewTestIOStreamsDiscard
(),
IOStreams
:
genericclioptions
.
NewTestIOStreamsDiscard
(),
}
}
...
...
pkg/kubectl/genericclioptions/printers/BUILD
View file @
49258593
...
@@ -3,6 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
...
@@ -3,6 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
go_library(
name = "go_default_library",
name = "go_default_library",
srcs = [
srcs = [
"discard.go",
"interface.go",
"interface.go",
"json.go",
"json.go",
"name.go",
"name.go",
...
...
pkg/kubectl/genericclioptions/printers/discard.go
0 → 100644
View file @
49258593
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
printers
import
(
"io"
"k8s.io/apimachinery/pkg/runtime"
)
// NewDiscardingPrinter is a printer that discards all objects
func
NewDiscardingPrinter
()
ResourcePrinterFunc
{
return
ResourcePrinterFunc
(
func
(
runtime
.
Object
,
io
.
Writer
)
error
{
return
nil
})
}
pkg/kubectl/genericclioptions/printers/interface.go
View file @
49258593
...
@@ -25,6 +25,11 @@ import (
...
@@ -25,6 +25,11 @@ import (
// ResourcePrinterFunc is a function that can print objects
// ResourcePrinterFunc is a function that can print objects
type
ResourcePrinterFunc
func
(
runtime
.
Object
,
io
.
Writer
)
error
type
ResourcePrinterFunc
func
(
runtime
.
Object
,
io
.
Writer
)
error
// PrintObj implements ResourcePrinter
func
(
fn
ResourcePrinterFunc
)
PrintObj
(
obj
runtime
.
Object
,
w
io
.
Writer
)
error
{
return
fn
(
obj
,
w
)
}
// ResourcePrinter is an interface that knows how to print runtime objects.
// ResourcePrinter is an interface that knows how to print runtime objects.
type
ResourcePrinter
interface
{
type
ResourcePrinter
interface
{
// Print receives a runtime object, formats it and prints it to a writer.
// Print receives a runtime object, formats it and prints it to a writer.
...
...
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