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 the lint issues #39

Closed
wants to merge 4 commits into from
Closed
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
1 change: 1 addition & 0 deletions cmd/migrate/config.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:unused
package main

import "github.com/spf13/pflag"
Expand Down
5 changes: 4 additions & 1 deletion cmd/migrate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import (

func init() {
pflag.Parse()
viper.BindPFlags(pflag.CommandLine)
err := viper.BindPFlags(pflag.CommandLine)
if err != nil {
log.Fatalf("failed to bind full flag set to config: %v", err)
}
viper.AutomaticEnv()
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.AddConfigPath(viper.GetString("config.source"))
Expand Down
19 changes: 14 additions & 5 deletions database/redshift/redshift_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,19 @@ import (
_ "github.com/golang-migrate/migrate/v4/source/file"
)

const (
pgPassword = "redshift"
)

var (
opts = dktest.Options{PortRequired: true, ReadyFunc: isReady}
opts = dktest.Options{
Env: map[string]string{"POSTGRES_PASSWORD": pgPassword},
PortRequired: true,
ReadyFunc: isReady,
}

specs = []dktesting.ContainerSpec{
{ImageName: "postgres:8", Options: opts},
{ImageName: "migrate/postgres8:8", Options: opts},
}
)

Expand All @@ -44,7 +53,7 @@ func pgConnectionString(host, port string) string {
}

func connectionString(schema, host, port string) string {
return fmt.Sprintf("%s://postgres@%s:%s/postgres?sslmode=disable", schema, host, port)
return fmt.Sprintf("%s://postgres:%s@%s:%s/postgres?sslmode=disable", schema, pgPassword, host, port)
}

func isReady(ctx context.Context, c dktest.ContainerInfo) bool {
Expand Down Expand Up @@ -192,7 +201,7 @@ func TestFilterCustomQuery(t *testing.T) {
t.Fatal(err)
}

addr := fmt.Sprintf("postgres://postgres@%v:%v/postgres?sslmode=disable&x-custom=foobar", ip, port)
addr := fmt.Sprintf("postgres://postgres:%s@%v:%v/postgres?sslmode=disable&x-custom=foobar", pgPassword, ip, port)
p := &Redshift{}
d, err := p.Open(addr)
if err != nil {
Expand Down Expand Up @@ -234,7 +243,7 @@ func TestWithSchema(t *testing.T) {
}

// re-connect using that schema
d2, err := p.Open(fmt.Sprintf("postgres://postgres@%v:%v/postgres?sslmode=disable&search_path=foobar", ip, port))
d2, err := p.Open(fmt.Sprintf("postgres://postgres:%s@%v:%v/postgres?sslmode=disable&search_path=foobar", pgPassword, ip, port))
if err != nil {
t.Fatal(err)
}
Expand Down
9 changes: 2 additions & 7 deletions testing/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ import (
dockerclient "github.com/docker/docker/client"
"github.com/hashicorp/go-multierror"
"io"
"math/rand"
"math/rand/v2"
"strconv"
"strings"
"testing"
"time"
)

func NewDockerContainer(t testing.TB, image string, env []string, cmd []string) (*DockerContainer, error) {
Expand Down Expand Up @@ -286,15 +285,11 @@ type dockerImagePullOutput struct {
Progress string `json:"progress"`
}

func init() {
rand.Seed(time.Now().UnixNano())
}

func pseudoRandStr(n int) string {
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyz0123456789")
b := make([]rune, n)
for i := range b {
b[i] = letterRunes[rand.Intn(len(letterRunes))]
b[i] = letterRunes[rand.IntN(len(letterRunes))]
}
return string(b)
}