From d77c4cde476fa51f7a4871666cc1045799d239d7 Mon Sep 17 00:00:00 2001 From: Joachim Hill-Grannec Date: Thu, 2 Aug 2018 14:51:10 +0200 Subject: [PATCH] changing to a plugin package to allow reuse --- .drone.yml | 2 +- main.go | 10 +++++----- plugin.go => plugin/plugin.go | 2 +- plugin_test.go => plugin/plugin_test.go | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) rename plugin.go => plugin/plugin.go (99%) rename plugin_test.go => plugin/plugin_test.go (99%) diff --git a/.drone.yml b/.drone.yml index 38cdfc0..2d371e3 100644 --- a/.drone.yml +++ b/.drone.yml @@ -13,7 +13,7 @@ pipeline: image: golang:1.10 commands: - go vet - - go test -cover -coverprofile=coverage.out + - go test ./... -cover -coverprofile=coverage.out build_linux_amd64: image: golang:1.10 diff --git a/main.go b/main.go index 2c0b7be..96f8cf5 100644 --- a/main.go +++ b/main.go @@ -2,11 +2,11 @@ package main import ( "fmt" - "os" - "github.com/Sirupsen/logrus" "github.com/joho/godotenv" + "github.com/josmo/drone-helm/plugin" "github.com/urfave/cli" + "os" ) var build = "0" // build number set at compile-time @@ -149,8 +149,8 @@ func run(c *cli.Context) error { if c.String("env-file") != "" { _ = godotenv.Load(c.String("env-file")) } - plugin := Plugin{ - Config: Config{ + p := plugin.Plugin{ + Config: plugin.Config{ APIServer: c.String("api_server"), Token: c.String("token"), Certificate: c.String("certificate"), @@ -181,5 +181,5 @@ func run(c *cli.Context) error { UpdateDependencies: c.Bool("update-dependencies"), }, } - return plugin.Exec() + return p.Exec() } diff --git a/plugin.go b/plugin/plugin.go similarity index 99% rename from plugin.go rename to plugin/plugin.go index c76c26a..6dcb243 100644 --- a/plugin.go +++ b/plugin/plugin.go @@ -1,4 +1,4 @@ -package main +package plugin import ( "fmt" diff --git a/plugin_test.go b/plugin/plugin_test.go similarity index 99% rename from plugin_test.go rename to plugin/plugin_test.go index 4a45cb2..8ba8aa9 100644 --- a/plugin_test.go +++ b/plugin/plugin_test.go @@ -1,4 +1,4 @@ -package main +package plugin import ( "fmt" @@ -23,7 +23,7 @@ func TestInitialiseKubeconfig(t *testing.T) { } configfile := "config3.test" - initialiseKubeconfig(&plugin.Config, "kubeconfig", configfile) + initialiseKubeconfig(&plugin.Config, "../kubeconfig", configfile) data, err := ioutil.ReadFile(configfile) if err != nil { t.Errorf("Error reading file %v", err)