Remove dead code related to old plugin method
This commit is contained in:
parent
c89bd79342
commit
34d0ff7e4d
@ -3,8 +3,8 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
|
// "github.com/ian-howell/exampleplugin"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/ian-howell/exampleplugin"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// builtinPlugins are the plugins that are built and maintained by the
|
// builtinPlugins are the plugins that are built and maintained by the
|
||||||
@ -16,5 +16,5 @@ var builtinPlugins = []func(io.Writer, []string) *cobra.Command{
|
|||||||
// externalPlugins are external. The function to create a command should be
|
// externalPlugins are external. The function to create a command should be
|
||||||
// placed here
|
// placed here
|
||||||
var externalPlugins = []func(io.Writer, []string) *cobra.Command{
|
var externalPlugins = []func(io.Writer, []string) *cobra.Command{
|
||||||
exampleplugin.NewExampleCommand, // This is an example and shouldn't be enabled in production builds
|
// exampleplugin.NewExampleCommand, // This is an example and shouldn't be enabled in production builds
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,10 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/ian-howell/airshipctl/pkg/environment"
|
"github.com/ian-howell/airshipctl/pkg/environment"
|
||||||
"github.com/ian-howell/airshipctl/pkg/log"
|
"github.com/ian-howell/airshipctl/pkg/log"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var settings environment.AirshipCTLSettings
|
var settings environment.AirshipCTLSettings
|
||||||
|
@ -4,7 +4,6 @@ Usage:
|
|||||||
airshipctl [command]
|
airshipctl [command]
|
||||||
|
|
||||||
Available Commands:
|
Available Commands:
|
||||||
example an example command
|
|
||||||
help Help about any command
|
help Help about any command
|
||||||
version Show the version number of airshipctl
|
version Show the version number of airshipctl
|
||||||
workflow access to workflows
|
workflow access to workflows
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
var kubeConfigFilePath string
|
var kubeConfigFilePath string
|
||||||
|
|
||||||
|
// NewWorkflowCommand creates a new command for working with argo workflows
|
||||||
func NewWorkflowCommand(out io.Writer, args []string) *cobra.Command {
|
func NewWorkflowCommand(out io.Writer, args []string) *cobra.Command {
|
||||||
workflowRootCmd := &cobra.Command{
|
workflowRootCmd := &cobra.Command{
|
||||||
Use: "workflow",
|
Use: "workflow",
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// NewWorkflowListCommand is a command for listing argo workflows
|
||||||
func NewWorkflowListCommand(out io.Writer, args []string) *cobra.Command {
|
func NewWorkflowListCommand(out io.Writer, args []string) *cobra.Command {
|
||||||
|
|
||||||
// TODO(howell): This is only used to appease the linter. It will be used later
|
// TODO(howell): This is only used to appease the linter. It will be used later
|
||||||
|
@ -21,11 +21,13 @@ const (
|
|||||||
goldenFileSuffix = ".golden"
|
goldenFileSuffix = ".golden"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// CmdTest is a command to be run on the command line as a test
|
||||||
type CmdTest struct {
|
type CmdTest struct {
|
||||||
Name string
|
Name string
|
||||||
Command string
|
Command string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RunCmdTests checks all of the tests actual output against their expected outputs
|
||||||
func RunCmdTests(t *testing.T, tests []CmdTest) {
|
func RunCmdTests(t *testing.T, tests []CmdTest) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
package plugin
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"plugin"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
const badInterfaceFormat = `plugin at %s is missing required function:
|
|
||||||
- NewCommand(func io.writer, []string) *cobra.Command)`
|
|
||||||
|
|
||||||
func CreateCommandFromPlugin(pluginPath string, out io.Writer, args []string) (*cobra.Command, error) {
|
|
||||||
plug, err := plugin.Open(pluginPath)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("plugin at %s could not be opened", pluginPath)
|
|
||||||
}
|
|
||||||
cmdSym, err := plug.Lookup("NewCommand")
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf(badInterfaceFormat, pluginPath)
|
|
||||||
}
|
|
||||||
command, ok := cmdSym.(func(io.Writer, []string) *cobra.Command)
|
|
||||||
if !ok {
|
|
||||||
return nil, fmt.Errorf(badInterfaceFormat, pluginPath)
|
|
||||||
}
|
|
||||||
return command(out, args), nil
|
|
||||||
}
|
|
@ -12,13 +12,3 @@ func IsReadable(path string) error {
|
|||||||
}
|
}
|
||||||
return f.Close()
|
return f.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadDir does the same thing as ioutil.ReadDir, but it doesn't sort the files.
|
|
||||||
func ReadDir(dirname string) ([]os.FileInfo, error) {
|
|
||||||
f, err := os.Open(dirname)
|
|
||||||
if err != nil {
|
|
||||||
return []os.FileInfo{}, err
|
|
||||||
}
|
|
||||||
defer f.Close()
|
|
||||||
return f.Readdir(-1)
|
|
||||||
}
|
|
||||||
|
@ -3,7 +3,6 @@ package util_test
|
|||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/ian-howell/airshipctl/pkg/util"
|
"github.com/ian-howell/airshipctl/pkg/util"
|
||||||
@ -39,51 +38,3 @@ func TestIsReadable(t *testing.T) {
|
|||||||
t.Errorf("Expected '%s' error, got '%s'", expected, err.Error())
|
t.Errorf("Expected '%s' error, got '%s'", expected, err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReadDir(t *testing.T) {
|
|
||||||
dir, err := ioutil.TempDir("", "airshipctl-tests")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Could not create a temporary directory: %s", err.Error())
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
|
|
||||||
testFiles := []string{
|
|
||||||
"test1.txt",
|
|
||||||
"test2.txt",
|
|
||||||
"test3.txt",
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, testFile := range testFiles {
|
|
||||||
if err := ioutil.WriteFile(filepath.Join(dir, testFile), []byte("testdata"), 0666); err != nil {
|
|
||||||
t.Fatalf("Could not create test file '%s': %s", testFile, err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
files, err := util.ReadDir(dir)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Unexpected error while reading directory: %s", err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(files) != len(testFiles) {
|
|
||||||
t.Errorf("Expected %d files, got %d", len(testFiles), len(files))
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, testFile := range testFiles {
|
|
||||||
found := false
|
|
||||||
for _, actualFile := range files {
|
|
||||||
if testFile == actualFile.Name() {
|
|
||||||
found = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
t.Errorf("Could not find test file '%s'", testFile)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
os.RemoveAll(dir)
|
|
||||||
|
|
||||||
if _, err := util.ReadDir(dir); err == nil {
|
|
||||||
t.Error("Expected an error when reading non-existant directory")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
package tools
|
package tools
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
// These imports are all tools used in the building and testing process
|
||||||
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
|
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
|
||||||
_ "github.com/shuLahn/go-bindata/cmd/go-bindata"
|
_ "github.com/shuLahn/go-bindata/cmd/go-bindata"
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user