Skip to content

Commit 5e8663b

Browse files
committed
chore: export DockerCompose type in the compose package
1 parent bbe83ac commit 5e8663b

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

modules/compose/compose.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ func WithProfiles(profiles ...string) ComposeStackOption {
122122
return ComposeProfiles(profiles)
123123
}
124124

125-
func NewDockerCompose(filePaths ...string) (*dockerCompose, error) {
125+
func NewDockerCompose(filePaths ...string) (*DockerCompose, error) {
126126
return NewDockerComposeWith(WithStackFiles(filePaths...))
127127
}
128128

129-
func NewDockerComposeWith(opts ...ComposeStackOption) (*dockerCompose, error) {
129+
func NewDockerComposeWith(opts ...ComposeStackOption) (*DockerCompose, error) {
130130
composeOptions := composeStackOptions{
131131
Identifier: uuid.New().String(),
132132
temporaryPaths: make(map[string]bool),
@@ -161,7 +161,7 @@ func NewDockerComposeWith(opts ...ComposeStackOption) (*dockerCompose, error) {
161161
dockerClient := dockerCli.Client()
162162
provider.SetClient(dockerClient)
163163

164-
composeAPI := &dockerCompose{
164+
composeAPI := &DockerCompose{
165165
name: composeOptions.Identifier,
166166
configs: composeOptions.Paths,
167167
temporaryConfigs: composeOptions.temporaryPaths,

modules/compose/compose_api.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ const (
179179
RemoveImagesLocal
180180
)
181181

182-
type dockerCompose struct {
182+
type DockerCompose struct {
183183
// used to synchronize operations
184184
lock sync.RWMutex
185185

@@ -234,21 +234,21 @@ type dockerCompose struct {
234234
provider *testcontainers.DockerProvider
235235
}
236236

237-
func (d *dockerCompose) ServiceContainer(ctx context.Context, svcName string) (*testcontainers.DockerContainer, error) {
237+
func (d *DockerCompose) ServiceContainer(ctx context.Context, svcName string) (*testcontainers.DockerContainer, error) {
238238
d.lock.Lock()
239239
defer d.lock.Unlock()
240240

241241
return d.lookupContainer(ctx, svcName)
242242
}
243243

244-
func (d *dockerCompose) Services() []string {
244+
func (d *DockerCompose) Services() []string {
245245
d.lock.Lock()
246246
defer d.lock.Unlock()
247247

248248
return d.project.ServiceNames()
249249
}
250250

251-
func (d *dockerCompose) Down(ctx context.Context, opts ...StackDownOption) error {
251+
func (d *DockerCompose) Down(ctx context.Context, opts ...StackDownOption) error {
252252
d.lock.Lock()
253253
defer d.lock.Unlock()
254254

@@ -270,7 +270,7 @@ func (d *dockerCompose) Down(ctx context.Context, opts ...StackDownOption) error
270270
return d.composeService.Down(ctx, d.name, options.DownOptions)
271271
}
272272

273-
func (d *dockerCompose) Up(ctx context.Context, opts ...StackUpOption) (err error) {
273+
func (d *DockerCompose) Up(ctx context.Context, opts ...StackUpOption) (err error) {
274274
d.lock.Lock()
275275
defer d.lock.Unlock()
276276

@@ -435,23 +435,23 @@ func (d *dockerCompose) Up(ctx context.Context, opts ...StackUpOption) (err erro
435435
return nil
436436
}
437437

438-
func (d *dockerCompose) WaitForService(s string, strategy wait.Strategy) ComposeStack {
438+
func (d *DockerCompose) WaitForService(s string, strategy wait.Strategy) ComposeStack {
439439
d.lock.Lock()
440440
defer d.lock.Unlock()
441441

442442
d.waitStrategies[s] = strategy
443443
return d
444444
}
445445

446-
func (d *dockerCompose) WithEnv(m map[string]string) ComposeStack {
446+
func (d *DockerCompose) WithEnv(m map[string]string) ComposeStack {
447447
d.lock.Lock()
448448
defer d.lock.Unlock()
449449

450450
d.projectOptions = append(d.projectOptions, withEnv(m))
451451
return d
452452
}
453453

454-
func (d *dockerCompose) WithOsEnv() ComposeStack {
454+
func (d *DockerCompose) WithOsEnv() ComposeStack {
455455
d.lock.Lock()
456456
defer d.lock.Unlock()
457457

@@ -460,7 +460,7 @@ func (d *dockerCompose) WithOsEnv() ComposeStack {
460460
}
461461

462462
// cachedContainer returns the cached container for svcName or nil if it doesn't exist.
463-
func (d *dockerCompose) cachedContainer(svcName string) *testcontainers.DockerContainer {
463+
func (d *DockerCompose) cachedContainer(svcName string) *testcontainers.DockerContainer {
464464
d.containersLock.Lock()
465465
defer d.containersLock.Unlock()
466466

@@ -470,7 +470,7 @@ func (d *dockerCompose) cachedContainer(svcName string) *testcontainers.DockerCo
470470
// lookupContainer is used to retrieve the container instance from the cache or the Docker API.
471471
//
472472
// Safe for concurrent calls.
473-
func (d *dockerCompose) lookupContainer(ctx context.Context, svcName string) (*testcontainers.DockerContainer, error) {
473+
func (d *DockerCompose) lookupContainer(ctx context.Context, svcName string) (*testcontainers.DockerContainer, error) {
474474
if c := d.cachedContainer(svcName); c != nil {
475475
return c, nil
476476
}
@@ -505,7 +505,7 @@ func (d *dockerCompose) lookupContainer(ctx context.Context, svcName string) (*t
505505
// lookupNetworks is used to retrieve the networks that are part of the compose stack.
506506
//
507507
// Safe for concurrent calls.
508-
func (d *dockerCompose) lookupNetworks(ctx context.Context) error {
508+
func (d *DockerCompose) lookupNetworks(ctx context.Context) error {
509509
networks, err := d.dockerClient.NetworkList(ctx, dockernetwork.ListOptions{
510510
Filters: filters.NewArgs(
511511
filters.Arg("label", fmt.Sprintf("%s=%s", api.ProjectLabel, d.name)),
@@ -528,7 +528,7 @@ func (d *dockerCompose) lookupNetworks(ctx context.Context) error {
528528
return nil
529529
}
530530

531-
func (d *dockerCompose) compileProject(ctx context.Context) (*types.Project, error) {
531+
func (d *DockerCompose) compileProject(ctx context.Context) (*types.Project, error) {
532532
const nameAndDefaultConfigPath = 2
533533
projectOptions := make([]cli.ProjectOptionsFn, len(d.projectOptions), len(d.projectOptions)+nameAndDefaultConfigPath)
534534

modules/compose/compose_api_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func TestDockerComposeAPIWithProfiles(t *testing.T) {
148148
t.Cleanup(cancel)
149149

150150
for _, service := range test.wantServices {
151-
compose = compose.WaitForService(service, wait.NewHTTPStrategy("/").WithPort("80/tcp").WithStartupTimeout(10*time.Second)).(*dockerCompose)
151+
compose = compose.WaitForService(service, wait.NewHTTPStrategy("/").WithPort("80/tcp").WithStartupTimeout(10*time.Second)).(*DockerCompose)
152152
}
153153
err = compose.Up(ctx, Wait(true))
154154
cleanup(t, compose)
@@ -694,7 +694,7 @@ func testNameHash(name string) StackIdentifier {
694694
}
695695

696696
// cleanup is a helper function that schedules the compose stack to be stopped when the test ends.
697-
func cleanup(t *testing.T, compose *dockerCompose) {
697+
func cleanup(t *testing.T, compose *DockerCompose) {
698698
t.Helper()
699699
t.Cleanup(func() {
700700
require.NoError(t, compose.Down(

0 commit comments

Comments
 (0)