mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-19 09:16:29 +00:00
commit
f75b5cb18a
54
.github/workflows/ci.yml
vendored
54
.github/workflows/ci.yml
vendored
@ -35,35 +35,29 @@ jobs:
|
||||
runs-on: ${{ matrix.target.runner }}
|
||||
steps:
|
||||
|
||||
- name: Set up Go 1.16
|
||||
uses: actions/setup-go@v2
|
||||
- name: Set up Go 1.19
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.16.7
|
||||
go-version: 1.19.2
|
||||
id: go
|
||||
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
path: ./src/github.com/linuxkit/linuxkit
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set path
|
||||
run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
||||
env:
|
||||
GOPATH: ${{runner.workspace}}
|
||||
|
||||
- name: Get pre-requisites
|
||||
- name: golangci-lint CLI
|
||||
uses: golangci/golangci-lint-action@v3
|
||||
with:
|
||||
version: v1.50.0
|
||||
working-directory: src/cmd/linuxkit
|
||||
args: --verbose --timeout=10m
|
||||
- name: go vet CLI
|
||||
run: |
|
||||
go get -u golang.org/x/lint/golint
|
||||
go get -u github.com/gordonklaus/ineffassign
|
||||
env:
|
||||
GOPATH: ${{runner.workspace}}
|
||||
|
||||
# - name: Lint
|
||||
# run: |
|
||||
# make local-check
|
||||
# env:
|
||||
# GOPATH: ${{runner.workspace}}
|
||||
|
||||
cd src/cmd/linuxkit && go vet ./...
|
||||
- name: Build
|
||||
run: |
|
||||
make GOARCH=${{matrix.target.arch}} GOOS=${{matrix.target.os}} LOCAL_TARGET=$(pwd)/bin/linuxkit-${{matrix.target.suffix}} local-build
|
||||
@ -99,9 +93,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
path: ./src/github.com/linuxkit/linuxkit
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up binfmt
|
||||
# Only register arm64 as we are on amd64 already. s390x is not reliable
|
||||
@ -138,9 +130,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
path: ./src/github.com/linuxkit/linuxkit
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Pre-Requisites
|
||||
run: |
|
||||
@ -194,9 +184,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
path: ./src/github.com/linuxkit/linuxkit
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Pre-Requisites
|
||||
run: |
|
||||
@ -242,9 +230,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
path: ./src/github.com/linuxkit/linuxkit
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Pre-Requisites
|
||||
run: |
|
||||
@ -290,9 +276,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
path: ./src/github.com/linuxkit/linuxkit
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Pre-Requisites
|
||||
run: |
|
||||
@ -338,9 +322,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
path: ./src/github.com/linuxkit/linuxkit
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Pre-Requisites
|
||||
run: |
|
||||
|
4
.github/workflows/publish.yaml
vendored
4
.github/workflows/publish.yaml
vendored
@ -14,9 +14,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
path: ./src/github.com/linuxkit/linuxkit
|
||||
uses: actions/checkout@v3
|
||||
- name: Ensure bin/ directory
|
||||
run: mkdir -p bin
|
||||
- name: Download linuxkit
|
||||
|
10
.github/workflows/release.yml
vendored
10
.github/workflows/release.yml
vendored
@ -11,16 +11,14 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
|
||||
- name: Set up Go 1.16
|
||||
uses: actions/setup-go@v2
|
||||
- name: Set up Go 1.19
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.16.7
|
||||
go-version: 1.19.2
|
||||
id: go
|
||||
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
path: ./src/github.com/linuxkit/linuxkit
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set path
|
||||
run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
||||
|
2
src/cmd/linuxkit/cache/source.go
vendored
2
src/cmd/linuxkit/cache/source.go
vendored
@ -92,7 +92,7 @@ func (c ImageSource) V1TarReader(overrideName string) (io.ReadCloser, error) {
|
||||
r, w := io.Pipe()
|
||||
go func() {
|
||||
defer w.Close()
|
||||
tarball.Write(refName, image, w)
|
||||
_ = tarball.Write(refName, image, w)
|
||||
}()
|
||||
return r, nil
|
||||
}
|
||||
|
@ -83,5 +83,5 @@ func cacheExport(args []string) {
|
||||
w = f
|
||||
}
|
||||
|
||||
io.Copy(w, reader)
|
||||
_, _ = io.Copy(w, reader)
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import (
|
||||
"golang.org/x/oauth2/google"
|
||||
"google.golang.org/api/compute/v1"
|
||||
"google.golang.org/api/googleapi"
|
||||
"google.golang.org/api/option"
|
||||
"google.golang.org/api/storage/v1"
|
||||
)
|
||||
|
||||
@ -34,7 +35,6 @@ type GCPClient struct {
|
||||
compute *compute.Service
|
||||
storage *storage.Service
|
||||
projectName string
|
||||
fileName string
|
||||
privKey *rsa.PrivateKey
|
||||
}
|
||||
|
||||
@ -87,12 +87,12 @@ func NewGCPClient(keys, projectName string) (*GCPClient, error) {
|
||||
}
|
||||
|
||||
var err error
|
||||
client.compute, err = compute.New(client.client)
|
||||
client.compute, err = compute.NewService(ctx, option.WithHTTPClient(client.client))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client.storage, err = storage.New(client.client)
|
||||
client.storage, err = storage.NewService(ctx, option.WithHTTPClient(client.client))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -443,19 +443,25 @@ func (g GCPClient) ConnectToInstanceSerialPort(instance, zone string) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to setup stdin for session: %v", err)
|
||||
}
|
||||
go io.Copy(stdin, os.Stdin)
|
||||
go func() {
|
||||
_, _ = io.Copy(stdin, os.Stdin)
|
||||
}()
|
||||
|
||||
stdout, err := session.StdoutPipe()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to setup stdout for session: %v", err)
|
||||
}
|
||||
go io.Copy(os.Stdout, stdout)
|
||||
go func() {
|
||||
_, _ = io.Copy(os.Stdout, stdout)
|
||||
}()
|
||||
|
||||
stderr, err := session.StderrPipe()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to setup stderr for session: %v", err)
|
||||
}
|
||||
go io.Copy(os.Stderr, stderr)
|
||||
go func() {
|
||||
_, _ = io.Copy(os.Stderr, stderr)
|
||||
}()
|
||||
/*
|
||||
c := make(chan os.Signal, 1)
|
||||
exit := make(chan bool, 1)
|
||||
@ -487,7 +493,9 @@ func (g GCPClient) ConnectToInstanceSerialPort(instance, zone string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
defer term.RestoreTerminal(fd, oldState)
|
||||
defer func() {
|
||||
_ = term.RestoreTerminal(fd, oldState)
|
||||
}()
|
||||
|
||||
winsize, err := term.GetWinsize(fd)
|
||||
if err != nil {
|
||||
|
@ -54,6 +54,7 @@ require (
|
||||
golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
|
||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
|
||||
google.golang.org/api v0.57.0
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
)
|
||||
|
@ -9,10 +9,12 @@ import (
|
||||
"log"
|
||||
)
|
||||
|
||||
//nolint:unused
|
||||
func hypervStartConsole(vmName string) error {
|
||||
log.Fatalf("This function should not be called")
|
||||
return nil
|
||||
}
|
||||
|
||||
//nolint:unused
|
||||
func hypervRestoreConsole() {
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
"github.com/linuxkit/linuxkit/src/cmd/linuxkit/util"
|
||||
"github.com/linuxkit/linuxkit/src/cmd/linuxkit/version"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
@ -23,8 +22,6 @@ type PkgConfig struct {
|
||||
}
|
||||
|
||||
var (
|
||||
defaultLogFormatter = &log.TextFormatter{}
|
||||
|
||||
// Config is the global tool configuration
|
||||
Config = GlobalConfig{}
|
||||
)
|
||||
|
@ -520,7 +520,7 @@ func outputKernelSquashFS(image, base string, filesystem io.Reader) error {
|
||||
case strings.HasPrefix(thdr.Name, "boot/"):
|
||||
// skip the rest of boot/
|
||||
default:
|
||||
rootfs.WriteHeader(thdr)
|
||||
_ = rootfs.WriteHeader(thdr)
|
||||
if _, err := io.Copy(rootfs, tr); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -575,7 +575,7 @@ func outputKernelISO(image, base string, filesystem io.Reader) error {
|
||||
case strings.HasPrefix(thdr.Name, "boot/"):
|
||||
// skip the rest of boot/
|
||||
default:
|
||||
rootfs.WriteHeader(thdr)
|
||||
_ = rootfs.WriteHeader(thdr)
|
||||
if _, err := io.Copy(rootfs, tr); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ type Writer struct {
|
||||
}
|
||||
|
||||
// Write writes output
|
||||
func (pad Writer) Write(p []byte) (int, error) {
|
||||
func (pad *Writer) Write(p []byte) (int, error) {
|
||||
n, err := pad.w.Write(p)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@ -22,7 +22,7 @@ func (pad Writer) Write(p []byte) (int, error) {
|
||||
}
|
||||
|
||||
// Close adds the padding
|
||||
func (pad Writer) Close() error {
|
||||
func (pad *Writer) Close() error {
|
||||
mod4 := pad.count & 3
|
||||
if mod4 == 0 {
|
||||
return nil
|
||||
|
@ -31,7 +31,6 @@ type buildOpts struct {
|
||||
push bool
|
||||
release string
|
||||
manifest bool
|
||||
image bool
|
||||
targetDocker bool
|
||||
cacheDir string
|
||||
cacheProvider lktspec.CacheProvider
|
||||
|
@ -129,6 +129,8 @@ func (dr *dockerRunnerImpl) command(stdin io.Reader, stdout, stderr io.Writer, a
|
||||
|
||||
// versionCheck returns the client version and server version, and compares them both
|
||||
// against the minimum required version.
|
||||
//
|
||||
//nolint:unused // will be used when linuxkit cache is eliminated and we return to docker image cache
|
||||
func (dr *dockerRunnerImpl) versionCheck(version string) (string, string, error) {
|
||||
var stdout bytes.Buffer
|
||||
if err := dr.command(nil, &stdout, nil, "version", "--format", "json"); err != nil {
|
||||
@ -325,7 +327,7 @@ func (dr *dockerRunnerImpl) builderEnsureContainer(ctx context.Context, name, im
|
||||
// wait for buildkit socket to be ready up to the timeout
|
||||
fmt.Printf("waiting for buildkit builder to be ready, up to %d seconds\n", buildkitWaitServer)
|
||||
timeout := time.After(buildkitWaitServer * time.Second)
|
||||
ticker := time.Tick(buildkitCheckInterval * time.Second)
|
||||
ticker := time.NewTicker(buildkitCheckInterval * time.Second)
|
||||
// Keep trying until we're timed out or get a success
|
||||
for {
|
||||
select {
|
||||
@ -333,7 +335,7 @@ func (dr *dockerRunnerImpl) builderEnsureContainer(ctx context.Context, name, im
|
||||
case <-timeout:
|
||||
return nil, fmt.Errorf("could not communicate with buildkit builder at context/container %s/%s after %d seconds", dockerContext, name, buildkitWaitServer)
|
||||
// Got a tick, we should try again
|
||||
case <-ticker:
|
||||
case <-ticker.C:
|
||||
client, err := buildkitClient.New(ctx, fmt.Sprintf("docker-container://%s?context=%s", name, dockerContext))
|
||||
if err == nil {
|
||||
_, err = client.Info(ctx)
|
||||
@ -363,10 +365,12 @@ func (dr *dockerRunnerImpl) pull(img string) (bool, error) {
|
||||
}
|
||||
}
|
||||
|
||||
//nolint:unused // will be used when linuxkit cache is eliminated and we return to docker image cache
|
||||
func (dr dockerRunnerImpl) push(img string) error {
|
||||
return dr.command(nil, nil, nil, "image", "push", img)
|
||||
}
|
||||
|
||||
//nolint:unused // will be used when linuxkit cache is eliminated and we return to docker image cache
|
||||
func (dr *dockerRunnerImpl) pushWithManifest(img, suffix string, pushImage, pushManifest bool) error {
|
||||
var err error
|
||||
if pushImage {
|
||||
|
@ -324,6 +324,7 @@ func (p Pkg) Arches() []string {
|
||||
return p.arches
|
||||
}
|
||||
|
||||
//nolint:unused // will be used when linuxkit cache is eliminated and we return to docker image cache
|
||||
func (p Pkg) archSupported(want string) bool {
|
||||
for _, supp := range p.arches {
|
||||
if supp == want {
|
||||
@ -359,7 +360,7 @@ func makeAbsSubpath(field, base, path string) (string, error) {
|
||||
return "", fmt.Errorf("%s must not be exactly the package directory", field)
|
||||
}
|
||||
|
||||
if !filepath.HasPrefix(p, base) {
|
||||
if !strings.HasPrefix(p, base) {
|
||||
return "", fmt.Errorf("%s must be within package directory", field)
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ func createOpenStackImage(filePath string, imageName string, client *gophercloud
|
||||
}
|
||||
}
|
||||
|
||||
if supportedExtension == false {
|
||||
if !supportedExtension {
|
||||
log.Fatalf("Extension [%s] is not supported", fileExtension)
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/moby/hyperkit/go"
|
||||
hyperkit "github.com/moby/hyperkit/go"
|
||||
"github.com/moby/vpnkit/go/pkg/vmnet"
|
||||
"github.com/moby/vpnkit/go/pkg/vpnkit"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@ -412,7 +412,9 @@ func launchVPNKit(vpnkitPath, etherSock, vsockSock, portSock string) (*os.Proces
|
||||
return nil, err
|
||||
}
|
||||
|
||||
go cmd.Wait() // run in background
|
||||
go func() {
|
||||
_ = cmd.Wait() // run in background
|
||||
}()
|
||||
|
||||
return cmd.Process, nil
|
||||
}
|
||||
@ -493,7 +495,7 @@ func vpnkitPublishPorts(h *hyperkit.HyperKit, publishFlags multipleFlag, portSoc
|
||||
// Return cleanup function
|
||||
return func() {
|
||||
for _, vp := range ports {
|
||||
c.Unexpose(context.Background(), vp)
|
||||
_ = c.Unexpose(context.Background(), vp)
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ func runHyperV(args []string) {
|
||||
fmt.Printf("Options:\n")
|
||||
flags.PrintDefaults()
|
||||
}
|
||||
//nolint:staticcheck // I honestly have no idea why this is complaining, as this does get called on
|
||||
// L159, but anything to get the linter to stop complaining.
|
||||
keep := flags.Bool("keep", false, "Keep the VM after finishing")
|
||||
vmName := flags.String("name", "", "Name of the Hyper-V VM")
|
||||
cpus := flags.Int("cpus", 1, "Number of CPUs")
|
||||
|
@ -82,7 +82,7 @@ func runOpenStack(args []string) {
|
||||
log.Fatalf("Unable to create server: %s", err)
|
||||
}
|
||||
|
||||
servers.WaitForStatus(client, server.ID, "ACTIVE", 600)
|
||||
_ = servers.WaitForStatus(client, server.ID, "ACTIVE", 600)
|
||||
log.Infof("Server created, UUID is %s", server.ID)
|
||||
fmt.Println(server.ID)
|
||||
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"golang.org/x/crypto/ssh"
|
||||
"golang.org/x/crypto/ssh/agent"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -120,7 +120,7 @@ func runPacket(args []string) {
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc(fmt.Sprintf("/%s", ipxeScriptName),
|
||||
func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, ipxeScript)
|
||||
fmt.Fprint(w, ipxeScript)
|
||||
})
|
||||
fs := serveFiles{[]string{fmt.Sprintf("%s-kernel", name), fmt.Sprintf("%s-initrd.img", name)}}
|
||||
mux.Handle("/", http.FileServer(fs))
|
||||
@ -230,7 +230,7 @@ func runPacket(args []string) {
|
||||
log.Debugf("Shutting down http server...")
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
httpServer.Shutdown(ctx)
|
||||
_ = httpServer.Shutdown(ctx)
|
||||
}
|
||||
|
||||
if *keepFlag {
|
||||
@ -331,7 +331,7 @@ func packetSOS(user, host string) error {
|
||||
ssh.IGNCR: 1,
|
||||
}
|
||||
|
||||
width, height, err := terminal.GetSize(0)
|
||||
width, height, err := term.GetSize(0)
|
||||
if err != nil {
|
||||
log.Warningf("Error getting terminal size. Ignored. %v", err)
|
||||
width = 80
|
||||
@ -340,18 +340,20 @@ func packetSOS(user, host string) error {
|
||||
if err := s.RequestPty("vt100", width, height, modes); err != nil {
|
||||
return fmt.Errorf("Request for PTY failed: %v", err)
|
||||
}
|
||||
oldState, err := terminal.MakeRaw(int(os.Stdin.Fd()))
|
||||
oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer terminal.Restore(0, oldState)
|
||||
defer func() {
|
||||
_ = term.Restore(0, oldState)
|
||||
}()
|
||||
|
||||
// Start remote shell
|
||||
if err := s.Shell(); err != nil {
|
||||
return fmt.Errorf("Failed to start shell: %v", err)
|
||||
}
|
||||
|
||||
s.Wait()
|
||||
_ = s.Wait()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -385,7 +385,7 @@ func runQemuLocal(config QemuConfig) error {
|
||||
}
|
||||
|
||||
// Detached mode is only supported in a container.
|
||||
if config.Detached == true {
|
||||
if config.Detached {
|
||||
return fmt.Errorf("Detached mode is only supported when running in a container, not locally")
|
||||
}
|
||||
|
||||
@ -394,7 +394,7 @@ func runQemuLocal(config QemuConfig) error {
|
||||
log.Debugf("%v\n", qemuCmd.Args)
|
||||
|
||||
// If we're not using a separate window then link the execution to stdin/out
|
||||
if config.GUI != true {
|
||||
if !config.GUI {
|
||||
qemuCmd.Stdin = os.Stdin
|
||||
qemuCmd.Stdout = os.Stdout
|
||||
qemuCmd.Stderr = os.Stderr
|
||||
@ -566,11 +566,11 @@ func buildQemuCmdline(config QemuConfig) (QemuConfig, []string) {
|
||||
qemuArgs = append(qemuArgs, "-netdev", config.NetdevConfig+forwardings)
|
||||
}
|
||||
|
||||
if config.GUI != true {
|
||||
if !config.GUI {
|
||||
qemuArgs = append(qemuArgs, "-nographic")
|
||||
}
|
||||
|
||||
if config.USB == true {
|
||||
if config.USB {
|
||||
qemuArgs = append(qemuArgs, "-usb")
|
||||
}
|
||||
for _, d := range config.Devices {
|
||||
|
@ -78,7 +78,7 @@ func runVcenter(args []string) {
|
||||
}
|
||||
*newVM.path = remArgs[0]
|
||||
|
||||
if (*newVM.guestIP == true) && *newVM.poweron != true {
|
||||
if *newVM.guestIP && !*newVM.poweron {
|
||||
log.Fatalln("The waitForIP flag can not be used without the powerOn flag")
|
||||
}
|
||||
// Ensure an iso has been passed to the vCenter run Command
|
||||
@ -140,7 +140,7 @@ func runVcenter(args []string) {
|
||||
addNIC(ctx, vm, net)
|
||||
}
|
||||
|
||||
if *newVM.poweron == true {
|
||||
if *newVM.poweron {
|
||||
log.Infoln("Powering on LinuxKit VM")
|
||||
powerOnVM(ctx, vm)
|
||||
}
|
||||
@ -261,7 +261,7 @@ func addNIC(ctx context.Context, vm *object.VirtualMachine, net object.NetworkRe
|
||||
var add []types.BaseVirtualDevice
|
||||
add = append(add, netdev)
|
||||
|
||||
if vm.AddDevice(ctx, add...); err != nil {
|
||||
if err := vm.AddDevice(ctx, add...); err != nil {
|
||||
log.Fatalf("Unable to add new networking device to VM configuration\n%v", err)
|
||||
}
|
||||
}
|
||||
@ -286,7 +286,7 @@ func addVMDK(ctx context.Context, vm *object.VirtualMachine, dss *object.Datasto
|
||||
|
||||
log.Infof("Adding a persistent disk to the Virtual Machine")
|
||||
|
||||
if vm.AddDevice(ctx, add...); err != nil {
|
||||
if err := vm.AddDevice(ctx, add...); err != nil {
|
||||
log.Fatalf("Unable to add new storage device to VM configuration\n%v", err)
|
||||
}
|
||||
}
|
||||
@ -312,7 +312,7 @@ func addISO(ctx context.Context, newVM vmConfig, vm *object.VirtualMachine, dss
|
||||
|
||||
log.Infof("Adding ISO to the Virtual Machine")
|
||||
|
||||
if vm.AddDevice(ctx, add...); err != nil {
|
||||
if err := vm.AddDevice(ctx, add...); err != nil {
|
||||
log.Fatalf("Unable to add new CD-ROM device to VM configuration\n%v", err)
|
||||
}
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ func setRawMode(f *os.File) {
|
||||
var attr unix.Termios
|
||||
|
||||
// Get settings for terminal
|
||||
termios.Tcgetattr(f.Fd(), &attr)
|
||||
_ = termios.Tcgetattr(f.Fd(), &attr)
|
||||
|
||||
// Put stdin into raw mode, disabling local echo, input canonicalization,
|
||||
// and CR-NL mapping.
|
||||
@ -302,7 +302,7 @@ func setRawMode(f *os.File) {
|
||||
attr.Cc[syscall.VTIME] = 0
|
||||
|
||||
// reflects the changed settings
|
||||
termios.Tcsetattr(f.Fd(), termios.TCSANOW, &attr)
|
||||
_ = termios.Tcsetattr(f.Fd(), termios.TCSANOW, &attr)
|
||||
}
|
||||
|
||||
func checkFileType(infile string) (string, error) {
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
"github.com/scaleway/scaleway-sdk-go/scw"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"golang.org/x/crypto/ssh"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -284,7 +284,7 @@ func getSSHAuth(sshKeyPath string) (ssh.Signer, error) {
|
||||
signer, err := ssh.ParsePrivateKey(buf)
|
||||
if err != nil {
|
||||
fmt.Print("Enter ssh key passphrase: ")
|
||||
bytePassword, err := terminal.ReadPassword(int(syscall.Stdin))
|
||||
bytePassword, err := term.ReadPassword(int(syscall.Stdin))
|
||||
// ReadPassword eats newline, put it back to avoid mangling logs
|
||||
fmt.Println()
|
||||
if err != nil {
|
||||
@ -358,11 +358,11 @@ func (s *ScalewayClient) CopyImageToInstance(instanceID, path, sshKeyPath string
|
||||
}
|
||||
defer w.Close()
|
||||
fmt.Fprintln(w, "C0600", int64(len(contentBytes)), base)
|
||||
io.Copy(w, bytesReader)
|
||||
_, _ = io.Copy(w, bytesReader)
|
||||
fmt.Fprintln(w, "\x00")
|
||||
}()
|
||||
|
||||
session.Run("/usr/bin/scp -t /root/") // TODO remove hardcoded remote path?
|
||||
_ = session.Run("/usr/bin/scp -t /root/") // TODO remove hardcoded remote path?
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ func serve(args []string) {
|
||||
}
|
||||
portFlag := flags.String("port", ":8080", "Local port to serve on")
|
||||
dirFlag := flags.String("directory", ".", "Directory to serve")
|
||||
flags.Parse(args)
|
||||
_ = flags.Parse(args)
|
||||
|
||||
http.Handle("/", http.FileServer(http.Dir(*dirFlag)))
|
||||
log.Fatal(http.ListenAndServe(*portFlag, logRequest(http.DefaultServeMux)))
|
||||
|
76
src/cmd/linuxkit/vendor/golang.org/x/crypto/ssh/terminal/terminal.go
generated
vendored
76
src/cmd/linuxkit/vendor/golang.org/x/crypto/ssh/terminal/terminal.go
generated
vendored
@ -1,76 +0,0 @@
|
||||
// Copyright 2011 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package terminal provides support functions for dealing with terminals, as
|
||||
// commonly found on UNIX systems.
|
||||
//
|
||||
// Deprecated: this package moved to golang.org/x/term.
|
||||
package terminal
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
// EscapeCodes contains escape sequences that can be written to the terminal in
|
||||
// order to achieve different styles of text.
|
||||
type EscapeCodes = term.EscapeCodes
|
||||
|
||||
// Terminal contains the state for running a VT100 terminal that is capable of
|
||||
// reading lines of input.
|
||||
type Terminal = term.Terminal
|
||||
|
||||
// NewTerminal runs a VT100 terminal on the given ReadWriter. If the ReadWriter is
|
||||
// a local terminal, that terminal must first have been put into raw mode.
|
||||
// prompt is a string that is written at the start of each input line (i.e.
|
||||
// "> ").
|
||||
func NewTerminal(c io.ReadWriter, prompt string) *Terminal {
|
||||
return term.NewTerminal(c, prompt)
|
||||
}
|
||||
|
||||
// ErrPasteIndicator may be returned from ReadLine as the error, in addition
|
||||
// to valid line data. It indicates that bracketed paste mode is enabled and
|
||||
// that the returned line consists only of pasted data. Programs may wish to
|
||||
// interpret pasted data more literally than typed data.
|
||||
var ErrPasteIndicator = term.ErrPasteIndicator
|
||||
|
||||
// State contains the state of a terminal.
|
||||
type State = term.State
|
||||
|
||||
// IsTerminal returns whether the given file descriptor is a terminal.
|
||||
func IsTerminal(fd int) bool {
|
||||
return term.IsTerminal(fd)
|
||||
}
|
||||
|
||||
// ReadPassword reads a line of input from a terminal without local echo. This
|
||||
// is commonly used for inputting passwords and other sensitive data. The slice
|
||||
// returned does not include the \n.
|
||||
func ReadPassword(fd int) ([]byte, error) {
|
||||
return term.ReadPassword(fd)
|
||||
}
|
||||
|
||||
// MakeRaw puts the terminal connected to the given file descriptor into raw
|
||||
// mode and returns the previous state of the terminal so that it can be
|
||||
// restored.
|
||||
func MakeRaw(fd int) (*State, error) {
|
||||
return term.MakeRaw(fd)
|
||||
}
|
||||
|
||||
// Restore restores the terminal connected to the given file descriptor to a
|
||||
// previous state.
|
||||
func Restore(fd int, oldState *State) error {
|
||||
return term.Restore(fd, oldState)
|
||||
}
|
||||
|
||||
// GetState returns the current state of a terminal which may be useful to
|
||||
// restore the terminal after a signal.
|
||||
func GetState(fd int) (*State, error) {
|
||||
return term.GetState(fd)
|
||||
}
|
||||
|
||||
// GetSize returns the dimensions of the given terminal.
|
||||
func GetSize(fd int) (width, height int, err error) {
|
||||
return term.GetSize(fd)
|
||||
}
|
2
src/cmd/linuxkit/vendor/modules.txt
vendored
2
src/cmd/linuxkit/vendor/modules.txt
vendored
@ -604,7 +604,6 @@ golang.org/x/crypto/pkcs12/internal/rc2
|
||||
golang.org/x/crypto/ssh
|
||||
golang.org/x/crypto/ssh/agent
|
||||
golang.org/x/crypto/ssh/internal/bcrypt_pbkdf
|
||||
golang.org/x/crypto/ssh/terminal
|
||||
# golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd
|
||||
## explicit
|
||||
golang.org/x/net/context
|
||||
@ -638,6 +637,7 @@ golang.org/x/sys/unix
|
||||
golang.org/x/sys/windows
|
||||
golang.org/x/sys/windows/registry
|
||||
# golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
|
||||
## explicit
|
||||
golang.org/x/term
|
||||
# golang.org/x/text v0.3.7
|
||||
golang.org/x/text/secure/bidirule
|
||||
|
Loading…
Reference in New Issue
Block a user