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
2345831b
Commit
2345831b
authored
Mar 20, 2019
by
Sean Sullivan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubectl: Removes dependency on util/interrupt by copying this code into kubectl
parent
795c96aa
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
137 additions
and
10 deletions
+137
-10
BUILD
pkg/kubectl/cmd/exec/BUILD
+1
-1
exec.go
pkg/kubectl/cmd/exec/exec.go
+1
-1
BUILD
pkg/kubectl/cmd/get/BUILD
+1
-1
get.go
pkg/kubectl/cmd/get/get.go
+1
-1
BUILD
pkg/kubectl/cmd/rollout/BUILD
+1
-1
rollout_status.go
pkg/kubectl/cmd/rollout/rollout_status.go
+1
-1
BUILD
pkg/kubectl/cmd/run/BUILD
+1
-1
run.go
pkg/kubectl/cmd/run/run.go
+1
-1
BUILD
pkg/kubectl/util/BUILD
+1
-0
BUILD
pkg/kubectl/util/interrupt/BUILD
+22
-0
interrupt.go
pkg/kubectl/util/interrupt/interrupt.go
+104
-0
BUILD
pkg/kubectl/util/term/BUILD
+1
-1
term.go
pkg/kubectl/util/term/term.go
+1
-1
No files found.
pkg/kubectl/cmd/exec/BUILD
View file @
2345831b
...
...
@@ -9,9 +9,9 @@ go_library(
"//pkg/kubectl/cmd/util:go_default_library",
"//pkg/kubectl/scheme:go_default_library",
"//pkg/kubectl/util/i18n:go_default_library",
"//pkg/kubectl/util/interrupt:go_default_library",
"//pkg/kubectl/util/templates:go_default_library",
"//pkg/kubectl/util/term:go_default_library",
"//pkg/util/interrupt:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/cli-runtime/pkg/genericclioptions:go_default_library",
...
...
pkg/kubectl/cmd/exec/exec.go
View file @
2345831b
...
...
@@ -33,9 +33,9 @@ import (
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/scheme"
"k8s.io/kubernetes/pkg/kubectl/util/i18n"
"k8s.io/kubernetes/pkg/kubectl/util/interrupt"
"k8s.io/kubernetes/pkg/kubectl/util/templates"
"k8s.io/kubernetes/pkg/kubectl/util/term"
"k8s.io/kubernetes/pkg/util/interrupt"
)
var
(
...
...
pkg/kubectl/cmd/get/BUILD
View file @
2345831b
...
...
@@ -32,11 +32,11 @@ go_library(
"//pkg/kubectl/cmd/util/openapi:go_default_library",
"//pkg/kubectl/scheme:go_default_library",
"//pkg/kubectl/util/i18n:go_default_library",
"//pkg/kubectl/util/interrupt:go_default_library",
"//pkg/kubectl/util/printers:go_default_library",
"//pkg/kubectl/util/templates:go_default_library",
"//pkg/printers:go_default_library",
"//pkg/printers/internalversion:go_default_library",
"//pkg/util/interrupt:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/meta:go_default_library",
...
...
pkg/kubectl/cmd/get/get.go
View file @
2345831b
...
...
@@ -45,9 +45,9 @@ import (
"k8s.io/kubernetes/pkg/api/legacyscheme"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/util/i18n"
"k8s.io/kubernetes/pkg/kubectl/util/interrupt"
utilprinters
"k8s.io/kubernetes/pkg/kubectl/util/printers"
"k8s.io/kubernetes/pkg/kubectl/util/templates"
"k8s.io/kubernetes/pkg/util/interrupt"
)
// GetOptions contains the input to the get command.
...
...
pkg/kubectl/cmd/rollout/BUILD
View file @
2345831b
...
...
@@ -25,8 +25,8 @@ go_library(
"//pkg/kubectl/polymorphichelpers:go_default_library",
"//pkg/kubectl/scheme:go_default_library",
"//pkg/kubectl/util/i18n:go_default_library",
"//pkg/kubectl/util/interrupt:go_default_library",
"//pkg/kubectl/util/templates:go_default_library",
"//pkg/util/interrupt:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/meta:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
...
...
pkg/kubectl/cmd/rollout/rollout_status.go
View file @
2345831b
...
...
@@ -40,8 +40,8 @@ import (
"k8s.io/kubernetes/pkg/kubectl/polymorphichelpers"
"k8s.io/kubernetes/pkg/kubectl/scheme"
"k8s.io/kubernetes/pkg/kubectl/util/i18n"
"k8s.io/kubernetes/pkg/kubectl/util/interrupt"
"k8s.io/kubernetes/pkg/kubectl/util/templates"
"k8s.io/kubernetes/pkg/util/interrupt"
)
var
(
...
...
pkg/kubectl/cmd/run/BUILD
View file @
2345831b
...
...
@@ -17,8 +17,8 @@ go_library(
"//pkg/kubectl/polymorphichelpers:go_default_library",
"//pkg/kubectl/scheme:go_default_library",
"//pkg/kubectl/util/i18n:go_default_library",
"//pkg/kubectl/util/interrupt:go_default_library",
"//pkg/kubectl/util/templates:go_default_library",
"//pkg/util/interrupt:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/meta:go_default_library",
...
...
pkg/kubectl/cmd/run/run.go
View file @
2345831b
...
...
@@ -51,8 +51,8 @@ import (
"k8s.io/kubernetes/pkg/kubectl/polymorphichelpers"
"k8s.io/kubernetes/pkg/kubectl/scheme"
"k8s.io/kubernetes/pkg/kubectl/util/i18n"
"k8s.io/kubernetes/pkg/kubectl/util/interrupt"
"k8s.io/kubernetes/pkg/kubectl/util/templates"
"k8s.io/kubernetes/pkg/util/interrupt"
uexec
"k8s.io/utils/exec"
)
...
...
pkg/kubectl/util/BUILD
View file @
2345831b
...
...
@@ -72,6 +72,7 @@ filegroup(
"//pkg/kubectl/util/fieldpath:all-srcs",
"//pkg/kubectl/util/hash:all-srcs",
"//pkg/kubectl/util/i18n:all-srcs",
"//pkg/kubectl/util/interrupt:all-srcs",
"//pkg/kubectl/util/logs:all-srcs",
"//pkg/kubectl/util/podutils:all-srcs",
"//pkg/kubectl/util/printers:all-srcs",
...
...
pkg/kubectl/util/interrupt/BUILD
0 → 100644
View file @
2345831b
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["interrupt.go"],
importpath = "k8s.io/kubernetes/pkg/kubectl/util/interrupt",
visibility = ["//visibility:public"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
pkg/kubectl/util/interrupt/interrupt.go
0 → 100644
View file @
2345831b
/*
Copyright 2016 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
interrupt
import
(
"os"
"os/signal"
"sync"
"syscall"
)
// terminationSignals are signals that cause the program to exit in the
// supported platforms (linux, darwin, windows).
var
terminationSignals
=
[]
os
.
Signal
{
syscall
.
SIGHUP
,
syscall
.
SIGINT
,
syscall
.
SIGTERM
,
syscall
.
SIGQUIT
}
// Handler guarantees execution of notifications after a critical section (the function passed
// to a Run method), even in the presence of process termination. It guarantees exactly once
// invocation of the provided notify functions.
type
Handler
struct
{
notify
[]
func
()
final
func
(
os
.
Signal
)
once
sync
.
Once
}
// Chain creates a new handler that invokes all notify functions when the critical section exits
// and then invokes the optional handler's notifications. This allows critical sections to be
// nested without losing exactly once invocations. Notify functions can invoke any cleanup needed
// but should not exit (which is the responsibility of the parent handler).
func
Chain
(
handler
*
Handler
,
notify
...
func
())
*
Handler
{
if
handler
==
nil
{
return
New
(
nil
,
notify
...
)
}
return
New
(
handler
.
Signal
,
append
(
notify
,
handler
.
Close
)
...
)
}
// New creates a new handler that guarantees all notify functions are run after the critical
// section exits (or is interrupted by the OS), then invokes the final handler. If no final
// handler is specified, the default final is `os.Exit(1)`. A handler can only be used for
// one critical section.
func
New
(
final
func
(
os
.
Signal
),
notify
...
func
())
*
Handler
{
return
&
Handler
{
final
:
final
,
notify
:
notify
,
}
}
// Close executes all the notification handlers if they have not yet been executed.
func
(
h
*
Handler
)
Close
()
{
h
.
once
.
Do
(
func
()
{
for
_
,
fn
:=
range
h
.
notify
{
fn
()
}
})
}
// Signal is called when an os.Signal is received, and guarantees that all notifications
// are executed, then the final handler is executed. This function should only be called once
// per Handler instance.
func
(
h
*
Handler
)
Signal
(
s
os
.
Signal
)
{
h
.
once
.
Do
(
func
()
{
for
_
,
fn
:=
range
h
.
notify
{
fn
()
}
if
h
.
final
==
nil
{
os
.
Exit
(
1
)
}
h
.
final
(
s
)
})
}
// Run ensures that any notifications are invoked after the provided fn exits (even if the
// process is interrupted by an OS termination signal). Notifications are only invoked once
// per Handler instance, so calling Run more than once will not behave as the user expects.
func
(
h
*
Handler
)
Run
(
fn
func
()
error
)
error
{
ch
:=
make
(
chan
os
.
Signal
,
1
)
signal
.
Notify
(
ch
,
terminationSignals
...
)
defer
func
()
{
signal
.
Stop
(
ch
)
close
(
ch
)
}()
go
func
()
{
sig
,
ok
:=
<-
ch
if
!
ok
{
return
}
h
.
Signal
(
sig
)
}()
defer
h
.
Close
()
return
fn
()
}
pkg/kubectl/util/term/BUILD
View file @
2345831b
...
...
@@ -17,7 +17,7 @@ go_library(
],
importpath = "k8s.io/kubernetes/pkg/kubectl/util/term",
deps = [
"//pkg/util/interrupt:go_default_library",
"//pkg/
kubectl/
util/interrupt:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
"//staging/src/k8s.io/client-go/tools/remotecommand:go_default_library",
"//vendor/github.com/docker/docker/pkg/term:go_default_library",
...
...
pkg/kubectl/util/term/term.go
View file @
2345831b
...
...
@@ -22,7 +22,7 @@ import (
"github.com/docker/docker/pkg/term"
"k8s.io/kubernetes/pkg/util/interrupt"
"k8s.io/kubernetes/pkg/
kubectl/
util/interrupt"
)
// SafeFunc is a function to be invoked by TTY.
...
...
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