remove a bunch of dead code.

https://github.com/dominikh/go-tools/tree/master/cmd/unused
This commit is contained in:
Matthew Hooker 2017-03-28 18:02:51 -07:00
parent 230079f73a
commit d1b20b3d9c
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
19 changed files with 25 additions and 309 deletions

View File

@ -1,14 +1,14 @@
package chroot package chroot
import ( import (
"log"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"log"
) )
// StepChrootProvision provisions the instance within a chroot. // StepChrootProvision provisions the instance within a chroot.
type StepChrootProvision struct { type StepChrootProvision struct {
mounts []string
} }
func (s *StepChrootProvision) Run(state multistep.StateBag) multistep.StepAction { func (s *StepChrootProvision) Run(state multistep.StateBag) multistep.StepAction {

View File

@ -2,15 +2,15 @@ package chroot
import ( import (
"fmt" "fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"log" "log"
"os" "os"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
// StepPrepareDevice finds an available device and sets it. // StepPrepareDevice finds an available device and sets it.
type StepPrepareDevice struct { type StepPrepareDevice struct {
mounts []string
} }
func (s *StepPrepareDevice) Run(state multistep.StateBag) multistep.StepAction { func (s *StepPrepareDevice) Run(state multistep.StateBag) multistep.StepAction {

View File

@ -13,12 +13,11 @@ import (
) )
type StepGetCertificate struct { type StepGetCertificate struct {
client *AzureClient client *AzureClient
template string get func(keyVaultName string, secretName string) (string, error)
get func(keyVaultName string, secretName string) (string, error) say func(message string)
say func(message string) error func(e error)
error func(e error) pause func()
pause func()
} }
func NewStepGetCertificate(client *AzureClient, ui packer.Ui) *StepGetCertificate { func NewStepGetCertificate(client *AzureClient, ui packer.Ui) *StepGetCertificate {

View File

@ -30,23 +30,6 @@ type contentInfo struct {
Content asn1.RawValue `asn1:"tag:0,explicit,optional"` Content asn1.RawValue `asn1:"tag:0,explicit,optional"`
} }
type encryptedData struct {
Version int
EncryptedContentInfo encryptedContentInfo
}
type encryptedContentInfo struct {
ContentType asn1.ObjectIdentifier
ContentEncryptionAlgorithm pkix.AlgorithmIdentifier
EncryptedContent []byte `asn1:"tag:0,optional"`
}
func (i encryptedContentInfo) GetAlgorithm() pkix.AlgorithmIdentifier {
return i.ContentEncryptionAlgorithm
}
func (i encryptedContentInfo) GetData() []byte { return i.EncryptedContent }
type safeBag struct { type safeBag struct {
Id asn1.ObjectIdentifier Id asn1.ObjectIdentifier
Value asn1.RawValue `asn1:"tag:0,explicit"` Value asn1.RawValue `asn1:"tag:0,explicit"`

View File

@ -54,7 +54,6 @@ type Config struct {
Zone string `mapstructure:"zone"` Zone string `mapstructure:"zone"`
Account AccountFile Account AccountFile
privateKeyBytes []byte
stateTimeout time.Duration stateTimeout time.Duration
imageAlreadyExists bool imageAlreadyExists bool
ctx interpolate.Context ctx interpolate.Context

View File

@ -12,8 +12,6 @@ import (
// stepInstanceInfo represents a Packer build step that gathers GCE instance info. // stepInstanceInfo represents a Packer build step that gathers GCE instance info.
type StepInstanceInfo struct { type StepInstanceInfo struct {
Debug bool Debug bool
info int
} }
// Run executes the Packer build step that gathers GCE instance info. // Run executes the Packer build step that gathers GCE instance info.

View File

@ -3,18 +3,18 @@ package common
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"log" "log"
"os/exec" "os/exec"
"strings" "strings"
"time" "time"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
const port string = "13000" const port string = "13000"
type StepPollingInstalation struct { type StepPollingInstalation struct {
step int
} }
func (s *StepPollingInstalation) Run(state multistep.StateBag) multistep.StepAction { func (s *StepPollingInstalation) Run(state multistep.StateBag) multistep.StepAction {

View File

@ -2,8 +2,6 @@ package profitbricks
import ( import (
"encoding/json" "encoding/json"
"errors"
"fmt"
"time" "time"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
@ -48,13 +46,6 @@ func (s *stepTakeSnapshot) Run(state multistep.StateBag) multistep.StepAction {
func (s *stepTakeSnapshot) Cleanup(state multistep.StateBag) { func (s *stepTakeSnapshot) Cleanup(state multistep.StateBag) {
} }
func (d *stepTakeSnapshot) checkForErrors(instance profitbricks.Resp) error {
if instance.StatusCode > 299 {
return errors.New(fmt.Sprintf("Error occurred %s", string(instance.Body)))
}
return nil
}
func (d *stepTakeSnapshot) waitTillProvisioned(path string, config Config) { func (d *stepTakeSnapshot) waitTillProvisioned(path string, config Config) {
d.setPB(config.PBUsername, config.PBPassword, config.PBUrl) d.setPB(config.PBUsername, config.PBPassword, config.PBUrl)
waitCount := 50 waitCount := 50

View File

@ -1,43 +0,0 @@
package qemu
import (
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"time"
)
// stepWaitForShutdown waits for the shutdown of the currently running
// qemu VM.
type stepWaitForShutdown struct {
Message string
}
func (s *stepWaitForShutdown) Run(state multistep.StateBag) multistep.StepAction {
driver := state.Get("driver").(Driver)
ui := state.Get("ui").(packer.Ui)
stopCh := make(chan struct{})
defer close(stopCh)
cancelCh := make(chan struct{})
go func() {
for {
if _, ok := state.GetOk(multistep.StateCancelled); ok {
close(cancelCh)
return
}
select {
case <-stopCh:
return
case <-time.After(100 * time.Millisecond):
}
}
}()
ui.Say(s.Message)
driver.WaitForShutdown(cancelCh)
return multistep.ActionContinue
}
func (s *stepWaitForShutdown) Cleanup(state multistep.StateBag) {}

View File

@ -1,10 +1,5 @@
package iso package iso
import (
"os"
"path/filepath"
)
// OutputDir is an interface type that abstracts the creation and handling // OutputDir is an interface type that abstracts the creation and handling
// of the output directory for VMware-based products. The abstraction is made // of the output directory for VMware-based products. The abstraction is made
// so that the output directory can be properly made on remote (ESXi) based // so that the output directory can be properly made on remote (ESXi) based
@ -17,50 +12,3 @@ type OutputDir interface {
RemoveAll() error RemoveAll() error
SetOutputDir(string) SetOutputDir(string)
} }
// localOutputDir is an OutputDir implementation where the directory
// is on the local machine.
type localOutputDir struct {
dir string
}
func (d *localOutputDir) DirExists() (bool, error) {
_, err := os.Stat(d.dir)
return err == nil, nil
}
func (d *localOutputDir) ListFiles() ([]string, error) {
files := make([]string, 0, 10)
visit := func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if !info.IsDir() {
files = append(files, path)
}
return nil
}
return files, filepath.Walk(d.dir, visit)
}
func (d *localOutputDir) MkdirAll() error {
return os.MkdirAll(d.dir, 0755)
}
func (d *localOutputDir) Remove(path string) error {
return os.Remove(path)
}
func (d *localOutputDir) RemoveAll() error {
return os.RemoveAll(d.dir)
}
func (d *localOutputDir) SetOutputDir(path string) {
d.dir = path
}
func (d *localOutputDir) String() string {
return d.dir
}

View File

@ -1,9 +1,6 @@
package main package main
import ( import (
"os"
"os/signal"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
"github.com/mitchellh/packer/command" "github.com/mitchellh/packer/command"
"github.com/mitchellh/packer/version" "github.com/mitchellh/packer/version"
@ -68,20 +65,3 @@ func init() {
}, },
} }
} }
// makeShutdownCh creates an interrupt listener and returns a channel.
// A message will be sent on the channel for every interrupt received.
func makeShutdownCh() <-chan struct{} {
resultCh := make(chan struct{})
signalCh := make(chan os.Signal, 4)
signal.Notify(signalCh, os.Interrupt)
go func() {
for {
<-signalCh
resultCh <- struct{}{}
}
}()
return resultCh
}

View File

@ -187,8 +187,6 @@ func wrappedMain() int {
Ui: ui, Ui: ui,
} }
//setupSignalHandlers(env)
cli := &cli.CLI{ cli := &cli.CLI{
Args: args, Args: args,
Commands: Commands, Commands: Commands,

View File

@ -1,33 +0,0 @@
package rpc
import (
"net"
"net/rpc"
)
// rpcDial makes a TCP connection to a remote RPC server and returns
// the client. This will set the connection up properly so that keep-alives
// are set and so on and should be used to make all RPC connections within
// this package.
func rpcDial(address string) (*rpc.Client, error) {
tcpConn, err := tcpDial(address)
if err != nil {
return nil, err
}
// Create an RPC client around our connection
return rpc.NewClient(tcpConn), nil
}
// tcpDial connects via TCP to the designated address.
func tcpDial(address string) (*net.TCPConn, error) {
conn, err := net.Dial("tcp", address)
if err != nil {
return nil, err
}
// Set a keep-alive so that the connection stays alive even when idle
tcpConn := conn.(*net.TCPConn)
tcpConn.SetKeepAlive(true)
return tcpConn, nil
}

View File

@ -1,8 +1,9 @@
package rpc package rpc
import ( import (
"github.com/mitchellh/packer/packer"
"net/rpc" "net/rpc"
"github.com/mitchellh/packer/packer"
) )
// An implementation of packer.PostProcessor where the PostProcessor is actually // An implementation of packer.PostProcessor where the PostProcessor is actually
@ -15,9 +16,8 @@ type postProcessor struct {
// PostProcessorServer wraps a packer.PostProcessor implementation and makes it // PostProcessorServer wraps a packer.PostProcessor implementation and makes it
// exportable as part of a Golang RPC server. // exportable as part of a Golang RPC server.
type PostProcessorServer struct { type PostProcessorServer struct {
client *rpc.Client mux *muxBroker
mux *muxBroker p packer.PostProcessor
p packer.PostProcessor
} }
type PostProcessorConfigureArgs struct { type PostProcessorConfigureArgs struct {

View File

@ -4,14 +4,11 @@ import (
"io" "io"
"log" "log"
"net/rpc" "net/rpc"
"sync/atomic"
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"github.com/ugorji/go/codec" "github.com/ugorji/go/codec"
) )
var endpointId uint64
const ( const (
DefaultArtifactEndpoint string = "Artifact" DefaultArtifactEndpoint string = "Artifact"
DefaultBuildEndpoint = "Build" DefaultBuildEndpoint = "Build"
@ -140,18 +137,3 @@ func (s *Server) Serve() {
rpcCodec := codec.GoRpc.ServerCodec(stream, h) rpcCodec := codec.GoRpc.ServerCodec(stream, h)
s.server.ServeCodec(rpcCodec) s.server.ServeCodec(rpcCodec)
} }
// registerComponent registers a single Packer RPC component onto
// the RPC server. If id is true, then a unique ID number will be appended
// onto the end of the endpoint.
//
// The endpoint name is returned.
func registerComponent(server *rpc.Server, name string, rcvr interface{}, id bool) string {
endpoint := name
if id {
log.Printf("%s.%d", endpoint, atomic.AddUint64(&endpointId, 1))
}
server.RegisterName(endpoint, rcvr)
return endpoint
}

View File

@ -8,8 +8,7 @@ import (
const BuilderId = "packer.post-processor.compress" const BuilderId = "packer.post-processor.compress"
type Artifact struct { type Artifact struct {
Path string Path string
files []string
} }
func (a *Artifact) BuilderId() string { func (a *Artifact) BuilderId() string {

View File

@ -319,20 +319,6 @@ func (p *Provisioner) Cancel() {
os.Exit(0) os.Exit(0)
} }
func (p *Provisioner) uploadDirectory(ui packer.Ui, comm packer.Communicator, dst string, src string) error {
if err := p.createDir(ui, comm, dst); err != nil {
return err
}
// Make sure there is a trailing "/" so that the directory isn't
// created on the other side.
if src[len(src)-1] != '/' {
src = src + "/"
}
return comm.UploadDir(dst, src, nil)
}
func (p *Provisioner) uploadFile(ui packer.Ui, comm packer.Communicator, remotePath string, localPath string) error { func (p *Provisioner) uploadFile(ui packer.Ui, comm packer.Communicator, remotePath string, localPath string) error {
ui.Message(fmt.Sprintf("Uploading %s...", localPath)) ui.Message(fmt.Sprintf("Uploading %s...", localPath))

View File

@ -1,39 +0,0 @@
package main
import (
"log"
"os"
"os/signal"
"syscall"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/packer/plugin"
)
// Prepares the signal handlers so that we handle interrupts properly.
// The signal handler exists in a goroutine.
func setupSignalHandlers(ui packer.Ui) {
ch := make(chan os.Signal, 1)
signal.Notify(ch, os.Interrupt)
signal.Notify(ch, syscall.SIGTERM)
go func() {
// First interrupt. We mostly ignore this because it allows the
// plugins time to cleanup.
<-ch
log.Println("First interrupt. Ignoring to allow plugins to clean up.")
ui.Error("Interrupt signal received. Cleaning up...")
// Second interrupt. Go down hard.
<-ch
log.Println("Second interrupt. Exiting now.")
ui.Error("Interrupt signal received twice. Forcefully exiting now.")
// Force kill all the plugins, but mark that we're killing them
// first so that we don't get panics everywhere.
plugin.CleanupClients()
os.Exit(1)
}()
}

View File

@ -147,14 +147,13 @@ type renderWalker struct {
// If it is nil, it means the top wasn't replaced. // If it is nil, it means the top wasn't replaced.
Top interface{} Top interface{}
key []string key []string
lastValue reflect.Value lastValue reflect.Value
loc reflectwalk.Location loc reflectwalk.Location
cs []reflect.Value cs []reflect.Value
csKey []reflect.Value csKey []reflect.Value
csData interface{} csData interface{}
sliceIndex int sliceIndex int
unknownKeys []string
} }
// renderWalkerFunc is the callback called by interpolationWalk. // renderWalkerFunc is the callback called by interpolationWalk.
@ -281,34 +280,3 @@ func (w *renderWalker) Primitive(v reflect.Value) error {
return nil return nil
} }
func (w *renderWalker) removeCurrent() {
// Append the key to the unknown keys
w.unknownKeys = append(w.unknownKeys, strings.Join(w.key, "."))
for i := 1; i <= len(w.cs); i++ {
c := w.cs[len(w.cs)-i]
switch c.Kind() {
case reflect.Map:
// Zero value so that we delete the map key
var val reflect.Value
// Get the key and delete it
k := w.csData.(reflect.Value)
c.SetMapIndex(k, val)
return
}
}
panic("No container found for removeCurrent")
}
func (w *renderWalker) replaceCurrent(v reflect.Value) {
c := w.cs[len(w.cs)-2]
switch c.Kind() {
case reflect.Map:
// Get the key and delete it
k := w.csKey[len(w.csKey)-1]
c.SetMapIndex(k, v)
}
}