Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dsn url (tbls diff output) #284

Merged
merged 2 commits into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,10 @@ func TestMaskedDSN(t *testing.T) {
"pg://localhost:5432/testdb?sslmode=disable",
"pg://localhost:5432/testdb?sslmode=disable",
},
{
"bq://project-id/dataset-id?creds=/path/to/google_application_credentials.json",
"bq://project-id/dataset-id?creds=/path/to/google_application_credentials.json",
},
}

for _, tt := range tests {
Expand Down
25 changes: 12 additions & 13 deletions output/md/md.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
"strings"
"text/template"
Expand Down Expand Up @@ -217,7 +216,7 @@ func DiffSchemas(s, s2 *schema.Schema, c, c2 *config.Config) (string, error) {

text, _ := difflib.GetUnifiedDiffString(d)
if text != "" {
diff += fmt.Sprintf("diff %s '%s'\n", from, to)
diff += fmt.Sprintf("diff '%s' '%s'\n", from, to)
diff += text
}

Expand All @@ -232,7 +231,7 @@ func DiffSchemas(s, s2 *schema.Schema, c, c2 *config.Config) (string, error) {
if err := md.OutputTable(a, t); err != nil {
return "", errors.WithStack(err)
}
from := path.Join(mdsnA, tName)
from := fmt.Sprintf("%s %s", mdsnA, tName)

b := new(bytes.Buffer)
t2, err := s2.FindTableByName(tName)
Expand All @@ -241,7 +240,7 @@ func DiffSchemas(s, s2 *schema.Schema, c, c2 *config.Config) (string, error) {
return "", errors.WithStack(err)
}
}
to := path.Join(mdsnB, tName)
to := fmt.Sprintf("%s %s", mdsnB, tName)

d := difflib.UnifiedDiff{
A: difflib.SplitLines(a.String()),
Expand All @@ -253,7 +252,7 @@ func DiffSchemas(s, s2 *schema.Schema, c, c2 *config.Config) (string, error) {

text, _ := difflib.GetUnifiedDiffString(d)
if text != "" {
diff += fmt.Sprintf("diff %s '%s'\n", from, to)
diff += fmt.Sprintf("diff '%s' '%s'\n", from, to)
diff += text
}
}
Expand All @@ -263,13 +262,13 @@ func DiffSchemas(s, s2 *schema.Schema, c, c2 *config.Config) (string, error) {
continue
}
a := ""
from := path.Join(mdsnA, tName)
from := fmt.Sprintf("%s %s", mdsnA, tName)

b := new(bytes.Buffer)
if err := md.OutputTable(b, t); err != nil {
return "", errors.WithStack(err)
}
to := path.Join(mdsnB, tName)
to := fmt.Sprintf("%s %s", mdsnB, tName)

d := difflib.UnifiedDiff{
A: difflib.SplitLines(a),
Expand All @@ -281,7 +280,7 @@ func DiffSchemas(s, s2 *schema.Schema, c, c2 *config.Config) (string, error) {

text, _ := difflib.GetUnifiedDiffString(d)
if text != "" {
diff += fmt.Sprintf("diff %s '%s'\n", from, to)
diff += fmt.Sprintf("diff '%s' '%s'\n", from, to)
diff += text
}
}
Expand Down Expand Up @@ -339,7 +338,7 @@ func DiffSchemaAndDocs(docPath string, s *schema.Schema, c *config.Config) (stri

text, _ := difflib.GetUnifiedDiffString(d)
if text != "" {
diff += fmt.Sprintf("diff %s '%s'\n", from, to)
diff += fmt.Sprintf("diff '%s' '%s'\n", from, to)
diff += text
}

Expand All @@ -353,7 +352,7 @@ func DiffSchemaAndDocs(docPath string, s *schema.Schema, c *config.Config) (stri
if _, err := os.Lstat(filepath.Join(fullPath, fmt.Sprintf("%s.%s", t.Name, c.ER.Format))); err == nil {
er = true
}
to := path.Join(mdsn, t.Name)
to := fmt.Sprintf("%s %s", mdsn, t.Name)

md := New(c, er)

Expand All @@ -379,7 +378,7 @@ func DiffSchemaAndDocs(docPath string, s *schema.Schema, c *config.Config) (stri

text, _ := difflib.GetUnifiedDiffString(d)
if text != "" {
diff += fmt.Sprintf("diff %s '%s'\n", from, to)
diff += fmt.Sprintf("diff '%s' '%s'\n", from, to)
diff += text
}
}
Expand All @@ -404,7 +403,7 @@ func DiffSchemaAndDocs(docPath string, s *schema.Schema, c *config.Config) (stri
from := filepath.Join(docPath, f.Name())

b := ""
to := path.Join(mdsn, filepath.Base(fname[:len(fname)-len(filepath.Ext(fname))]))
to := fmt.Sprintf("%s %s", mdsn, filepath.Base(fname[:len(fname)-len(filepath.Ext(fname))]))

d := difflib.UnifiedDiff{
A: difflib.SplitLines(string(a)),
Expand All @@ -416,7 +415,7 @@ func DiffSchemaAndDocs(docPath string, s *schema.Schema, c *config.Config) (stri

text, _ := difflib.GetUnifiedDiffString(d)
if text != "" {
diff += fmt.Sprintf("diff %s '%s'\n", from, to)
diff += fmt.Sprintf("diff '%s' '%s'\n", from, to)
diff += text
}
}
Expand Down