mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 08:02:15 +03:00
cli: fix inconsistent metadata object list rendering
closes https://github.com/hasura/graphql-engine/issues/7202 https://github.com/hasura/graphql-engine-mono/pull/1781 Co-authored-by: Aravind K P <8335904+scriptonist@users.noreply.github.com> GitOrigin-RevId: bcbdf74773aa8f653ebe62c5bf00bcbda1aa51ee
This commit is contained in:
parent
6e89653814
commit
4ed8ba8bb3
@ -3,6 +3,7 @@
|
||||
## Next release
|
||||
(Add entries below in the order of server, console, cli, docs, others)
|
||||
|
||||
- cli: add `-o`/`--output` flag for `hasura metadata inconsistency list` command
|
||||
|
||||
## v2.0.2
|
||||
|
||||
|
@ -52,7 +52,7 @@ Compose](https://github.com/hasura/graphql-engine/tree/stable/install-manifests)
|
||||
Once the server is running, you can run the tests by executing the make command:
|
||||
|
||||
```bash
|
||||
HASURA_GRAPHQL_TEST_ENDPOINT=http://localhost:8080 VERSION=dev make test
|
||||
HASURA_TEST_CLI_HGE_DOCKER_IMAGE="hasura/graphql-engine:v2.0.1" HASURA_GRAPHQL_TEST_ENDPOINT=http://localhost:8080 VERSION=dev make test
|
||||
```
|
||||
|
||||
## Builds
|
||||
|
@ -2,7 +2,6 @@ package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/hasura/graphql-engine/cli/v2"
|
||||
@ -73,7 +72,7 @@ func (o *helpOptions) run() {
|
||||
if cmd.Name() == "hasura" {
|
||||
// root command
|
||||
fmt.Println(cmd.Long)
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', 0)
|
||||
w := tabwriter.NewWriter(o.EC.Stdout, 0, 0, 3, ' ', 0)
|
||||
for _, g := range topLevelCommands {
|
||||
fmt.Println(g.Title + ":")
|
||||
for _, gc := range g.Commands {
|
||||
|
@ -2,7 +2,6 @@ package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/hasura/graphql-engine/cli/v2"
|
||||
"github.com/hasura/graphql-engine/cli/v2/internal/metadataobject"
|
||||
@ -105,7 +104,7 @@ func (o *MetadataApplyOptions) Run() error {
|
||||
o.EC.Logger.Warn("the old behaviour can be achieved using `hasura metadata diff` command")
|
||||
}
|
||||
|
||||
if err := writeByOutputFormat(os.Stdout, projectMetadataJSON, rawOutputFormat(o.rawOutput)); err != nil {
|
||||
if err := writeByOutputFormat(o.EC.Stdout, projectMetadataJSON, rawOutputFormat(o.rawOutput)); err != nil {
|
||||
return fmt.Errorf("displaying metadata failed: %w", err)
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ type MetadataDiffOptions struct {
|
||||
func newMetadataDiffCmd(ec *cli.ExecutionContext) *cobra.Command {
|
||||
opts := &MetadataDiffOptions{
|
||||
EC: ec,
|
||||
Output: os.Stdout,
|
||||
Output: ec.Stdout,
|
||||
}
|
||||
|
||||
metadataDiffCmd := &cobra.Command{
|
||||
|
@ -2,7 +2,6 @@ package commands
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/hasura/graphql-engine/cli/v2"
|
||||
"github.com/hasura/graphql-engine/cli/v2/internal/metadataobject"
|
||||
@ -84,5 +83,5 @@ func getMetadataFromServerAndWriteToStdoutByFormat(ec *cli.ExecutionContext, for
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "reading metadata failed")
|
||||
}
|
||||
return writeByOutputFormat(os.Stdout, jsonMetadata, format)
|
||||
return writeByOutputFormat(ec.Stdout, jsonMetadata, format)
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/hasura/graphql-engine/cli/v2/internal/metadataobject"
|
||||
|
||||
@ -36,6 +35,8 @@ func newMetadataInconsistencyListCmd(ec *cli.ExecutionContext) *cobra.Command {
|
||||
return nil
|
||||
},
|
||||
}
|
||||
f := metadataInconsistencyListCmd.Flags()
|
||||
f.StringVarP(&opts.outputFormat, "output", "o", "", "select output format for inconsistent metadata objects(Allowed values: json)")
|
||||
|
||||
return metadataInconsistencyListCmd
|
||||
}
|
||||
@ -43,6 +44,7 @@ func newMetadataInconsistencyListCmd(ec *cli.ExecutionContext) *cobra.Command {
|
||||
type metadataInconsistencyListOptions struct {
|
||||
EC *cli.ExecutionContext
|
||||
|
||||
outputFormat string
|
||||
isConsistent bool
|
||||
inconsistentObjects []metadataobject.InconsistentMetadataObject
|
||||
}
|
||||
@ -66,21 +68,26 @@ func (o *metadataInconsistencyListOptions) run() error {
|
||||
if o.isConsistent {
|
||||
return nil
|
||||
}
|
||||
out := new(tabwriter.Writer)
|
||||
buf := &bytes.Buffer{}
|
||||
out.Init(buf, 0, 8, 2, ' ', 0)
|
||||
w := util.NewPrefixWriter(out)
|
||||
w.Write(util.LEVEL_0, "NAME\tTYPE\tDESCRIPTION\tREASON\n")
|
||||
if o.outputFormat == "json" {
|
||||
jsonBytes, err := json.MarshalIndent(o.inconsistentObjects, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.EC.Spinner.Stop()
|
||||
fmt.Fprintln(o.EC.Stdout, string(jsonBytes))
|
||||
return nil
|
||||
}
|
||||
table := util.NewTableWriter(o.EC.Stdout)
|
||||
table.SetHeader([]string{"NAME", "TYPE", "DESCRIPTION", "REASON"})
|
||||
for _, obj := range o.inconsistentObjects {
|
||||
w.Write(util.LEVEL_0, "%s\t%s\t%s\t%s\n",
|
||||
table.Append([]string{
|
||||
obj.GetName(),
|
||||
obj.GetType(),
|
||||
obj.GetDescription(),
|
||||
obj.GetReason(),
|
||||
)
|
||||
})
|
||||
}
|
||||
out.Flush()
|
||||
o.EC.Spinner.Stop()
|
||||
fmt.Println(buf.String())
|
||||
table.Render()
|
||||
return nil
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Pallinder/go-randomdata"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@ -12,35 +13,58 @@ import (
|
||||
)
|
||||
|
||||
var _ = Describe("hasura metadata inconsistency list", func() {
|
||||
|
||||
var dirName string
|
||||
var projectDirectory string
|
||||
var teardown func()
|
||||
BeforeEach(func() {
|
||||
dirName = testutil.RandDirName()
|
||||
projectDirectory = testutil.RandDirName()
|
||||
hgeEndPort, teardownHGE := testutil.StartHasura(GinkgoT(), testutil.HasuraDockerImage)
|
||||
hgeEndpoint := fmt.Sprintf("http://0.0.0.0:%s", hgeEndPort)
|
||||
|
||||
sourceName := randomdata.SillyName()
|
||||
connectionString, teardownPG := testutil.StartPGContainer(GinkgoT())
|
||||
testutil.AddPGSourceToHasura(GinkgoT(), hgeEndpoint, connectionString, sourceName)
|
||||
copyTestConfigV3Project(projectDirectory)
|
||||
editEndpointInConfig(filepath.Join(projectDirectory, defaultConfigFilename), hgeEndpoint)
|
||||
editSourceNameInConfigV3ProjectTemplate(projectDirectory, sourceName, connectionString)
|
||||
|
||||
testutil.RunCommandAndSucceed(testutil.CmdOpts{
|
||||
Args: []string{"init", dirName},
|
||||
Args: []string{"metadata", "apply"},
|
||||
WorkingDirectory: projectDirectory,
|
||||
})
|
||||
editEndpointInConfig(filepath.Join(dirName, defaultConfigFilename), hgeEndpoint)
|
||||
|
||||
teardown = func() {
|
||||
os.RemoveAll(dirName)
|
||||
os.RemoveAll(projectDirectory)
|
||||
teardownHGE()
|
||||
teardownPG()
|
||||
}
|
||||
})
|
||||
|
||||
AfterEach(func() { teardown() })
|
||||
var matcher = func(out []byte) {
|
||||
want := []string{"genres", "albums", "media_types", "playlists", "artists", "tracks", "playlist_track"}
|
||||
for _, v := range want {
|
||||
Expect(out).To(ContainSubstring(v))
|
||||
}
|
||||
}
|
||||
|
||||
Context("metadata inconsistency list test", func() {
|
||||
It("Lists all inconsistent objects from the metadata", func() {
|
||||
It("should list inconsistent metadata objects", func() {
|
||||
Context("Lists all inconsistent objects in table format", func() {
|
||||
session := testutil.Hasura(testutil.CmdOpts{
|
||||
Args: []string{"metadata", "inconsistency", "list"},
|
||||
WorkingDirectory: dirName,
|
||||
WorkingDirectory: projectDirectory,
|
||||
})
|
||||
want := `metadata is consistent`
|
||||
Eventually(session, 60*40).Should(Exit(0))
|
||||
Eventually(session.Wait().Err.Contents()).Should(ContainSubstring(want))
|
||||
matcher(session.Wait().Out.Contents())
|
||||
})
|
||||
Context("Lists all inconsistent objects in json format", func() {
|
||||
session := testutil.Hasura(testutil.CmdOpts{
|
||||
Args: []string{"metadata", "inconsistency", "list", "-o", "json"},
|
||||
WorkingDirectory: projectDirectory,
|
||||
})
|
||||
Eventually(session, 60*40).Should(Exit(0))
|
||||
stdout := session.Wait().Out.Contents()
|
||||
Eventually(isJSON(stdout)).Should(BeTrue())
|
||||
matcher(stdout)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -3,7 +3,6 @@ package commands
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/hasura/graphql-engine/cli/v2/internal/hasura"
|
||||
@ -41,7 +40,7 @@ func newMigrateStatusCmd(ec *cli.ExecutionContext) *cobra.Command {
|
||||
return err
|
||||
}
|
||||
buf := printStatus(status)
|
||||
fmt.Fprintf(os.Stdout, "%s", buf)
|
||||
fmt.Fprintf(ec.Stdout, "%s", buf)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ source: https://github.com/kubernetes-sigs/krew/blob/master/cmd/krew/cmd/list.go
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
@ -112,9 +111,10 @@ func (p *pluginListOptions) run() error {
|
||||
}
|
||||
rows = sortByFirstColumn(rows)
|
||||
ec.Spinner.Stop()
|
||||
return printTable(os.Stdout, cols, rows)
|
||||
return printTable(p.EC.Stdout, cols, rows)
|
||||
}
|
||||
|
||||
|
||||
func printTable(out io.Writer, columns []string, rows [][]string) error {
|
||||
w := tabwriter.NewWriter(out, 0, 0, 2, ' ', 0)
|
||||
fmt.Fprint(w, strings.Join(columns, "\t"))
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"os"
|
||||
)
|
||||
|
||||
// NewVersionCmd returns the version command
|
||||
@ -20,7 +19,7 @@ func NewVersionCmd(ec *cli.ExecutionContext) *cobra.Command {
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
logger := logrus.New()
|
||||
logger.SetOutput(os.Stdout)
|
||||
logger.SetOutput(ec.Stdout)
|
||||
logger.SetFormatter(&logrus.TextFormatter{DisableTimestamp: true, DisableColors: ec.NoColor})
|
||||
if !ec.IsTerminal {
|
||||
logger.SetFormatter(&logrus.JSONFormatter{PrettyPrint: false})
|
||||
|
@ -40,8 +40,9 @@ require (
|
||||
github.com/microcosm-cc/bluemonday v1.0.2 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0
|
||||
github.com/mitchellh/mapstructure v1.1.2
|
||||
github.com/onsi/ginkgo v1.15.2
|
||||
github.com/onsi/gomega v1.11.0
|
||||
github.com/olekukonko/tablewriter v0.0.5
|
||||
github.com/onsi/ginkgo v1.16.4
|
||||
github.com/onsi/gomega v1.14.0
|
||||
github.com/opencontainers/runc v1.0.0-rc93 // indirect
|
||||
github.com/ory/dockertest/v3 v3.6.3
|
||||
github.com/parnurzeal/gorequest v0.2.16
|
||||
@ -72,8 +73,6 @@ require (
|
||||
github.com/theplant/testingutils v0.0.0-20190603093022-26d8b4d95c61 // indirect
|
||||
github.com/yosssi/gohtml v0.0.0-20190915184251-7ff6f235ecaf // indirect
|
||||
golang.org/x/crypto v0.0.0-20210317152858-513c2a44f670
|
||||
golang.org/x/text v0.3.4 // indirect
|
||||
google.golang.org/protobuf v1.25.0 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
|
||||
gopkg.in/src-d/go-git.v4 v4.13.1
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
|
39
cli/go.sum
39
cli/go.sum
@ -176,6 +176,7 @@ github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG
|
||||
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||
github.com/goccy/go-yaml v1.8.8 h1:MGfRB1GeSn/hWXYWS2Pt67iC2GJNnebdIro01ddyucA=
|
||||
github.com/goccy/go-yaml v1.8.8/go.mod h1:U/jl18uSupI5rdI2jmuCswEA2htH9eXfferR3KfscvA=
|
||||
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
@ -206,10 +207,11 @@ github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:x
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
@ -217,7 +219,6 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5a
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
@ -347,6 +348,8 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
|
||||
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
|
||||
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/mattn/go-sqlite3 v1.11.0 h1:LDdKkqtYlom37fkvqs8rMPFKAMe8+SgjbwZ6ex1/A/Q=
|
||||
github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
@ -380,16 +383,18 @@ github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI
|
||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.15.2 h1:l77YT15o814C2qVL47NOyjV/6RbaP7kKdrvZnxQ3Org=
|
||||
github.com/onsi/ginkgo v1.15.2/go.mod h1:Dd6YFfwBW84ETqqtL0CPyPXillHgY6XhQH3uuCCTr/o=
|
||||
github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
|
||||
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
|
||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.11.0 h1:+CqWgvj0OZycCaqclBD1pxKHAU+tOkHmQIWvDHq2aug=
|
||||
github.com/onsi/gomega v1.11.0/go.mod h1:azGKhqFUon9Vuj0YmTfLSmx0FUwqXYSTl5re8lQLTUg=
|
||||
github.com/onsi/gomega v1.14.0 h1:ep6kpPVwmr/nTbklSx2nrLNSIO62DoYAhnPNIMhK8gI=
|
||||
github.com/onsi/gomega v1.14.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0=
|
||||
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
||||
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
|
||||
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
|
||||
@ -511,6 +516,7 @@ github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoH
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
|
||||
@ -619,10 +625,10 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 h1:DzZ89McO9/gWPsQXS/FVKAlG02ZjaQ6AlZRBimEYOd0=
|
||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@ -680,8 +686,9 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
@ -689,8 +696,8 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc=
|
||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
@ -771,7 +778,6 @@ google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4
|
||||
google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
@ -785,11 +791,10 @@ google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
@ -236,7 +236,7 @@ func (obj InconsistentMetadataObject) GetName() string {
|
||||
func (obj InconsistentMetadataObject) GetDescription() string {
|
||||
b, err := json.Marshal(obj.Definition)
|
||||
if err == nil {
|
||||
return fmt.Sprintf("%s", string(b))
|
||||
return fmt.Sprintf("%.50s...", string(b))
|
||||
}
|
||||
return "N/A"
|
||||
}
|
||||
@ -247,7 +247,7 @@ func (obj InconsistentMetadataObject) GetReason() string {
|
||||
}
|
||||
b, err := json.Marshal(obj.Reason)
|
||||
if err == nil {
|
||||
return fmt.Sprintf("%s", string(b))
|
||||
return fmt.Sprintf("%.80s...", string(b))
|
||||
}
|
||||
return "N/A"
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ func Test_inconsistentObject_GetDescription(t *testing.T) {
|
||||
}
|
||||
return field
|
||||
}(),
|
||||
`{"comment":null,"name":"author","table":"article","using":{"foreign_key_constraint_on":"author_id"}}`,
|
||||
`{"comment":null,"name":"author","table":"article",...`,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
21
cli/util/tablewriter.go
Normal file
21
cli/util/tablewriter.go
Normal file
@ -0,0 +1,21 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/olekukonko/tablewriter"
|
||||
|
||||
)
|
||||
|
||||
func NewTableWriter(w io.Writer) *tablewriter.Table {
|
||||
table := tablewriter.NewWriter(w)
|
||||
|
||||
table.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
|
||||
table.SetAlignment(tablewriter.ALIGN_LEFT)
|
||||
table.SetBorder(false)
|
||||
table.SetRowSeparator("")
|
||||
table.SetColumnSeparator("")
|
||||
table.SetCenterSeparator("")
|
||||
|
||||
return table
|
||||
}
|
Loading…
Reference in New Issue
Block a user