chore: tidy up pkgs (#636)

for readability and towards potentially making helmfile usable as a go library
This commit is contained in:
KUOKA Yusuke 2019-06-01 13:36:05 +09:00 committed by GitHub
parent 68b95f14d4
commit c68fc5bc50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
46 changed files with 62 additions and 60 deletions

View File

@ -2,9 +2,9 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/roboll/helmfile/helmexec"
"github.com/roboll/helmfile/pkg/app" "github.com/roboll/helmfile/pkg/app"
"github.com/roboll/helmfile/state" "github.com/roboll/helmfile/pkg/helmexec"
"github.com/roboll/helmfile/pkg/state"
"github.com/urfave/cli" "github.com/urfave/cli"
"go.uber.org/zap" "go.uber.org/zap"
"strings" "strings"

View File

@ -1,10 +1,10 @@
package cmd package cmd
import ( import (
"github.com/roboll/helmfile/args"
"github.com/roboll/helmfile/helmexec"
"github.com/roboll/helmfile/pkg/app" "github.com/roboll/helmfile/pkg/app"
"github.com/roboll/helmfile/state" "github.com/roboll/helmfile/pkg/argparser"
"github.com/roboll/helmfile/pkg/helmexec"
"github.com/roboll/helmfile/pkg/state"
"github.com/urfave/cli" "github.com/urfave/cli"
) )
@ -21,7 +21,7 @@ func Deps() cli.Command {
}, },
Action: func(c *cli.Context) error { Action: func(c *cli.Context) error {
return VisitAllDesiredStates(c, func(state *state.HelmState, helm helmexec.Interface, ctx app.Context) (bool, []error) { return VisitAllDesiredStates(c, func(state *state.HelmState, helm helmexec.Interface, ctx app.Context) (bool, []error) {
args := args.GetArgs(c.String("args"), state) args := argparser.GetArgs(c.String("args"), state)
if len(args) > 0 { if len(args) > 0 {
helm.SetExtraArgs(args...) helm.SetExtraArgs(args...)
} }

24
main.go
View File

@ -2,11 +2,11 @@ package main
import ( import (
"fmt" "fmt"
"github.com/roboll/helmfile/args"
"github.com/roboll/helmfile/cmd" "github.com/roboll/helmfile/cmd"
"github.com/roboll/helmfile/helmexec"
"github.com/roboll/helmfile/pkg/app" "github.com/roboll/helmfile/pkg/app"
"github.com/roboll/helmfile/state" "github.com/roboll/helmfile/pkg/argparser"
"github.com/roboll/helmfile/pkg/helmexec"
"github.com/roboll/helmfile/pkg/state"
"github.com/urfave/cli" "github.com/urfave/cli"
"go.uber.org/zap" "go.uber.org/zap"
"go.uber.org/zap/zapcore" "go.uber.org/zap/zapcore"
@ -107,7 +107,7 @@ func main() {
}, },
Action: func(c *cli.Context) error { Action: func(c *cli.Context) error {
return cmd.VisitAllDesiredStates(c, func(state *state.HelmState, helm helmexec.Interface, ctx app.Context) (bool, []error) { return cmd.VisitAllDesiredStates(c, func(state *state.HelmState, helm helmexec.Interface, ctx app.Context) (bool, []error) {
args := args.GetArgs(c.String("args"), state) args := argparser.GetArgs(c.String("args"), state)
if len(args) > 0 { if len(args) > 0 {
helm.SetExtraArgs(args...) helm.SetExtraArgs(args...)
} }
@ -264,7 +264,7 @@ func main() {
Action: func(c *cli.Context) error { Action: func(c *cli.Context) error {
return findAndIterateOverDesiredStatesUsingFlags(c, func(state *state.HelmState, helm helmexec.Interface, ctx app.Context) []error { return findAndIterateOverDesiredStatesUsingFlags(c, func(state *state.HelmState, helm helmexec.Interface, ctx app.Context) []error {
values := c.StringSlice("values") values := c.StringSlice("values")
args := args.GetArgs(c.String("args"), state) args := argparser.GetArgs(c.String("args"), state)
workers := c.Int("concurrency") workers := c.Int("concurrency")
if !c.Bool("skip-deps") { if !c.Bool("skip-deps") {
if errs := ctx.SyncReposOnce(state, helm); errs != nil && len(errs) > 0 { if errs := ctx.SyncReposOnce(state, helm); errs != nil && len(errs) > 0 {
@ -453,7 +453,7 @@ Do you really want to apply?
return findAndIterateOverDesiredStatesUsingFlags(c, func(state *state.HelmState, helm helmexec.Interface, _ app.Context) []error { return findAndIterateOverDesiredStatesUsingFlags(c, func(state *state.HelmState, helm helmexec.Interface, _ app.Context) []error {
workers := c.Int("concurrency") workers := c.Int("concurrency")
args := args.GetArgs(c.String("args"), state) args := argparser.GetArgs(c.String("args"), state)
if len(args) > 0 { if len(args) > 0 {
helm.SetExtraArgs(args...) helm.SetExtraArgs(args...)
} }
@ -481,7 +481,7 @@ Do you really want to apply?
errs := cmd.FindAndIterateOverDesiredStatesUsingFlagsWithReverse(c, true, func(state *state.HelmState, helm helmexec.Interface, _ app.Context) []error { errs := cmd.FindAndIterateOverDesiredStatesUsingFlagsWithReverse(c, true, func(state *state.HelmState, helm helmexec.Interface, _ app.Context) []error {
purge := c.Bool("purge") purge := c.Bool("purge")
args := args.GetArgs(c.String("args"), state) args := argparser.GetArgs(c.String("args"), state)
if len(args) > 0 { if len(args) > 0 {
helm.SetExtraArgs(args...) helm.SetExtraArgs(args...)
} }
@ -521,7 +521,7 @@ Do you really want to delete?
Action: func(c *cli.Context) error { Action: func(c *cli.Context) error {
affectedReleases := state.AffectedReleases{} affectedReleases := state.AffectedReleases{}
errs := cmd.FindAndIterateOverDesiredStatesUsingFlagsWithReverse(c, true, func(state *state.HelmState, helm helmexec.Interface, _ app.Context) []error { errs := cmd.FindAndIterateOverDesiredStatesUsingFlagsWithReverse(c, true, func(state *state.HelmState, helm helmexec.Interface, _ app.Context) []error {
args := args.GetArgs(c.String("args"), state) args := argparser.GetArgs(c.String("args"), state)
if len(args) > 0 { if len(args) > 0 {
helm.SetExtraArgs(args...) helm.SetExtraArgs(args...)
} }
@ -578,7 +578,7 @@ Do you really want to delete?
timeout := c.Int("timeout") timeout := c.Int("timeout")
concurrency := c.Int("concurrency") concurrency := c.Int("concurrency")
args := args.GetArgs(c.String("args"), state) args := argparser.GetArgs(c.String("args"), state)
if len(args) > 0 { if len(args) > 0 {
helm.SetExtraArgs(args...) helm.SetExtraArgs(args...)
} }
@ -597,7 +597,7 @@ Do you really want to delete?
} }
func executeSyncCommand(c *cli.Context, affectedReleases *state.AffectedReleases, state *state.HelmState, helm helmexec.Interface) []error { func executeSyncCommand(c *cli.Context, affectedReleases *state.AffectedReleases, state *state.HelmState, helm helmexec.Interface) []error {
args := args.GetArgs(c.String("args"), state) args := argparser.GetArgs(c.String("args"), state)
if len(args) > 0 { if len(args) > 0 {
helm.SetExtraArgs(args...) helm.SetExtraArgs(args...)
} }
@ -609,7 +609,7 @@ func executeSyncCommand(c *cli.Context, affectedReleases *state.AffectedReleases
} }
func executeTemplateCommand(c *cli.Context, state *state.HelmState, helm helmexec.Interface) []error { func executeTemplateCommand(c *cli.Context, state *state.HelmState, helm helmexec.Interface) []error {
args := args.GetArgs(c.String("args"), state) args := argparser.GetArgs(c.String("args"), state)
values := c.StringSlice("values") values := c.StringSlice("values")
workers := c.Int("concurrency") workers := c.Int("concurrency")
@ -617,7 +617,7 @@ func executeTemplateCommand(c *cli.Context, state *state.HelmState, helm helmexe
} }
func executeDiffCommand(c *cli.Context, st *state.HelmState, helm helmexec.Interface, detailedExitCode, suppressSecrets bool) ([]*state.ReleaseSpec, []error) { func executeDiffCommand(c *cli.Context, st *state.HelmState, helm helmexec.Interface, detailedExitCode, suppressSecrets bool) ([]*state.ReleaseSpec, []error) {
args := args.GetArgs(c.String("args"), st) args := argparser.GetArgs(c.String("args"), st)
if len(args) > 0 { if len(args) > 0 {
helm.SetExtraArgs(args...) helm.SetExtraArgs(args...)
} }

View File

@ -2,6 +2,8 @@ package app
import ( import (
"fmt" "fmt"
"github.com/roboll/helmfile/pkg/helmexec"
"github.com/roboll/helmfile/pkg/state"
"io/ioutil" "io/ioutil"
"log" "log"
"os" "os"
@ -9,8 +11,6 @@ import (
"strings" "strings"
"syscall" "syscall"
"github.com/roboll/helmfile/helmexec"
"github.com/roboll/helmfile/state"
"go.uber.org/zap" "go.uber.org/zap"
"path/filepath" "path/filepath"

View File

@ -2,13 +2,13 @@ package app
import ( import (
"fmt" "fmt"
"github.com/roboll/helmfile/pkg/helmexec"
"github.com/roboll/helmfile/pkg/state"
"os" "os"
"path/filepath" "path/filepath"
"reflect" "reflect"
"testing" "testing"
"github.com/roboll/helmfile/helmexec"
"github.com/roboll/helmfile/state"
"gotest.tools/env" "gotest.tools/env"
) )

View File

@ -1,6 +1,8 @@
package app package app
import "github.com/roboll/helmfile/state" import (
"github.com/roboll/helmfile/pkg/state"
)
type Context struct { type Context struct {
updatedRepos map[string]struct{} updatedRepos map[string]struct{}

View File

@ -5,8 +5,8 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/imdario/mergo" "github.com/imdario/mergo"
"github.com/roboll/helmfile/environment" "github.com/roboll/helmfile/pkg/environment"
"github.com/roboll/helmfile/state" "github.com/roboll/helmfile/pkg/state"
"go.uber.org/zap" "go.uber.org/zap"
"path/filepath" "path/filepath"
"sort" "sort"

View File

@ -3,9 +3,9 @@ package app
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/roboll/helmfile/environment" "github.com/roboll/helmfile/pkg/environment"
"github.com/roboll/helmfile/state" "github.com/roboll/helmfile/pkg/state"
"github.com/roboll/helmfile/tmpl" "github.com/roboll/helmfile/pkg/tmpl"
"strings" "strings"
) )

View File

@ -1,12 +1,12 @@
package app package app
import ( import (
"github.com/roboll/helmfile/pkg/helmexec"
"github.com/roboll/helmfile/pkg/state"
"os" "os"
"strings" "strings"
"testing" "testing"
"github.com/roboll/helmfile/helmexec"
"github.com/roboll/helmfile/state"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
) )

View File

@ -1,10 +1,9 @@
package args package argparser
import ( import (
"fmt" "fmt"
"github.com/roboll/helmfile/pkg/state"
"strings" "strings"
"github.com/roboll/helmfile/state"
) )
type keyVal struct { type keyVal struct {

View File

@ -1,10 +1,9 @@
package args package argparser
import ( import (
"github.com/roboll/helmfile/pkg/state"
"strings" "strings"
"testing" "testing"
"github.com/roboll/helmfile/state"
) )
func TestGetArgs(t *testing.T) { func TestGetArgs(t *testing.T) {

View File

@ -2,9 +2,9 @@ package event
import ( import (
"fmt" "fmt"
"github.com/roboll/helmfile/environment" "github.com/roboll/helmfile/pkg/environment"
"github.com/roboll/helmfile/helmexec" "github.com/roboll/helmfile/pkg/helmexec"
"github.com/roboll/helmfile/tmpl" "github.com/roboll/helmfile/pkg/tmpl"
"go.uber.org/zap" "go.uber.org/zap"
"os" "os"
) )

View File

@ -2,8 +2,8 @@ package event
import ( import (
"fmt" "fmt"
"github.com/roboll/helmfile/environment" "github.com/roboll/helmfile/pkg/environment"
"github.com/roboll/helmfile/helmexec" "github.com/roboll/helmfile/pkg/helmexec"
"os" "os"
"testing" "testing"
) )

View File

@ -3,7 +3,7 @@ package state
import ( import (
"fmt" "fmt"
"github.com/Masterminds/semver" "github.com/Masterminds/semver"
"github.com/roboll/helmfile/helmexec" "github.com/roboll/helmfile/pkg/helmexec"
"go.uber.org/zap" "go.uber.org/zap"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"io/ioutil" "io/ioutil"

View File

@ -5,8 +5,8 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/imdario/mergo" "github.com/imdario/mergo"
"github.com/roboll/helmfile/environment" "github.com/roboll/helmfile/pkg/environment"
"github.com/roboll/helmfile/helmexec" "github.com/roboll/helmfile/pkg/helmexec"
"go.uber.org/zap" "go.uber.org/zap"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"io" "io"

View File

@ -3,9 +3,9 @@ package state
import ( import (
"fmt" "fmt"
"github.com/imdario/mergo" "github.com/imdario/mergo"
"github.com/roboll/helmfile/environment" "github.com/roboll/helmfile/pkg/environment"
"github.com/roboll/helmfile/pkg/maputil" "github.com/roboll/helmfile/pkg/maputil"
"github.com/roboll/helmfile/tmpl" "github.com/roboll/helmfile/pkg/tmpl"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"path/filepath" "path/filepath"
) )

View File

@ -2,7 +2,7 @@ package state
import ( import (
"fmt" "fmt"
"github.com/roboll/helmfile/tmpl" "github.com/roboll/helmfile/pkg/tmpl"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
) )

View File

@ -1,6 +1,8 @@
package state package state
import "fmt" import (
"fmt"
)
const ReleaseErrorCodeFailure = 1 const ReleaseErrorCodeFailure = 1

View File

@ -3,6 +3,10 @@ package state
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/roboll/helmfile/pkg/environment"
"github.com/roboll/helmfile/pkg/event"
"github.com/roboll/helmfile/pkg/helmexec"
"github.com/roboll/helmfile/pkg/tmpl"
"io/ioutil" "io/ioutil"
"os" "os"
"path" "path"
@ -11,13 +15,8 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/roboll/helmfile/helmexec"
"regexp" "regexp"
"github.com/roboll/helmfile/environment"
"github.com/roboll/helmfile/event"
"github.com/roboll/helmfile/tmpl"
"github.com/tatsushid/go-prettytable" "github.com/tatsushid/go-prettytable"
"go.uber.org/zap" "go.uber.org/zap"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"

View File

@ -2,7 +2,7 @@ package state
import ( import (
"fmt" "fmt"
"github.com/roboll/helmfile/tmpl" "github.com/roboll/helmfile/pkg/tmpl"
) )
func (st *HelmState) envTemplateData() EnvironmentTemplateData { func (st *HelmState) envTemplateData() EnvironmentTemplateData {

View File

@ -1,10 +1,9 @@
package state package state
import ( import (
"github.com/roboll/helmfile/pkg/environment"
"reflect" "reflect"
"testing" "testing"
"github.com/roboll/helmfile/environment"
) )
func TestHelmState_executeTemplates(t *testing.T) { func TestHelmState_executeTemplates(t *testing.T) {

View File

@ -2,7 +2,7 @@ package state
import ( import (
"fmt" "fmt"
"github.com/roboll/helmfile/helmexec" "github.com/roboll/helmfile/pkg/helmexec"
"sync" "sync"
) )

View File

@ -1,6 +1,7 @@
package state package state
import ( import (
"github.com/roboll/helmfile/pkg/helmexec"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
@ -11,7 +12,6 @@ import (
"strings" "strings"
"fmt" "fmt"
"github.com/roboll/helmfile/helmexec"
) )
var logger = helmexec.NewLogger(os.Stdout, "warn") var logger = helmexec.NewLogger(os.Stdout, "warn")

View File

@ -1,6 +1,8 @@
package state package state
import "github.com/roboll/helmfile/environment" import (
"github.com/roboll/helmfile/pkg/environment"
)
// TemplateSpec defines the structure of a reusable and composable template for helm releases. // TemplateSpec defines the structure of a reusable and composable template for helm releases.
type TemplateSpec struct { type TemplateSpec struct {

View File

@ -2,7 +2,7 @@ package tmpl
import ( import (
"fmt" "fmt"
"github.com/roboll/helmfile/environment" "github.com/roboll/helmfile/pkg/environment"
"reflect" "reflect"
"testing" "testing"
) )