Skip to content

Commit eb48a98

Browse files
committed
add support for private reg
1 parent fa40087 commit eb48a98

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

preset/postgres/options.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ func WithVersion(version string) Option {
4444
}
4545
}
4646

47+
// WithImage sets image name
48+
func WithImage(name string) Option {
49+
return func(o *P) {
50+
o.ImageName = name
51+
}
52+
}
53+
4754
// WithTimezone sets the timezone in this container.
4855
func WithTimezone(timezone string) Option {
4956
return func(p *P) {

preset/postgres/preset.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const (
2020
defaultSSLMode = "disable"
2121
defaultPort = 5432
2222
defaultVersion = "16.2"
23+
defaultImage = "docker.io/library/postgres"
2324
)
2425

2526
func init() {
@@ -51,11 +52,12 @@ type P struct {
5152
Password string `json:"password"`
5253
Timezone string `json:"timezone"`
5354
Version string `json:"version"`
55+
ImageName string `json:"image_name"`
5456
}
5557

5658
// Image returns an image that should be pulled to create this container.
5759
func (p *P) Image() string {
58-
return fmt.Sprintf("docker.io/library/postgres:%s", p.Version)
60+
return fmt.Sprintf("%s:%s", p.ImageName, p.Version)
5961
}
6062

6163
// Ports returns ports that should be used to access this container.
@@ -151,6 +153,10 @@ func (p *P) setDefaults() {
151153
if p.Version == "" {
152154
p.Version = defaultVersion
153155
}
156+
157+
if p.ImageName == "" {
158+
p.ImageName = defaultImage
159+
}
154160
}
155161

156162
func (p *P) executeQueries(db *sql.DB) error {

0 commit comments

Comments
 (0)