@@ -32,7 +32,7 @@ import (
32
32
"github.com/docker/compose/v2/pkg/compose"
33
33
)
34
34
35
- type convertOptions struct {
35
+ type configOptions struct {
36
36
* ProjectOptions
37
37
Format string
38
38
Output string
@@ -48,8 +48,17 @@ type convertOptions struct {
48
48
noConsistency bool
49
49
}
50
50
51
+ func (o * configOptions ) ToProject (services []string ) (* types.Project , error ) {
52
+ return o .ProjectOptions .ToProject (services ,
53
+ cli .WithInterpolation (! o .noInterpolate ),
54
+ cli .WithResolvedPaths (true ),
55
+ cli .WithNormalization (! o .noNormalize ),
56
+ cli .WithConsistency (! o .noConsistency ),
57
+ cli .WithDiscardEnvFile )
58
+ }
59
+
51
60
func convertCommand (p * ProjectOptions , streams api.Streams , backend api.Service ) * cobra.Command {
52
- opts := convertOptions {
61
+ opts := configOptions {
53
62
ProjectOptions : p ,
54
63
}
55
64
cmd := & cobra.Command {
@@ -108,14 +117,9 @@ func convertCommand(p *ProjectOptions, streams api.Streams, backend api.Service)
108
117
return cmd
109
118
}
110
119
111
- func runConfig (ctx context.Context , streams api.Streams , backend api.Service , opts convertOptions , services []string ) error {
120
+ func runConfig (ctx context.Context , streams api.Streams , backend api.Service , opts configOptions , services []string ) error {
112
121
var content []byte
113
- project , err := opts .ToProject (services ,
114
- cli .WithInterpolation (! opts .noInterpolate ),
115
- cli .WithResolvedPaths (true ),
116
- cli .WithNormalization (! opts .noNormalize ),
117
- cli .WithConsistency (! opts .noConsistency ),
118
- cli .WithDiscardEnvFile )
122
+ project , err := opts .ToProject (services )
119
123
if err != nil {
120
124
return err
121
125
}
@@ -144,7 +148,7 @@ func runConfig(ctx context.Context, streams api.Streams, backend api.Service, op
144
148
return err
145
149
}
146
150
147
- func runServices (streams api.Streams , opts convertOptions ) error {
151
+ func runServices (streams api.Streams , opts configOptions ) error {
148
152
project , err := opts .ToProject (nil )
149
153
if err != nil {
150
154
return err
@@ -155,7 +159,7 @@ func runServices(streams api.Streams, opts convertOptions) error {
155
159
})
156
160
}
157
161
158
- func runVolumes (streams api.Streams , opts convertOptions ) error {
162
+ func runVolumes (streams api.Streams , opts configOptions ) error {
159
163
project , err := opts .ToProject (nil )
160
164
if err != nil {
161
165
return err
@@ -166,7 +170,7 @@ func runVolumes(streams api.Streams, opts convertOptions) error {
166
170
return nil
167
171
}
168
172
169
- func runHash (streams api.Streams , opts convertOptions ) error {
173
+ func runHash (streams api.Streams , opts configOptions ) error {
170
174
var services []string
171
175
if opts .hash != "*" {
172
176
services = append (services , strings .Split (opts .hash , "," )... )
@@ -198,7 +202,7 @@ func runHash(streams api.Streams, opts convertOptions) error {
198
202
return nil
199
203
}
200
204
201
- func runProfiles (streams api.Streams , opts convertOptions , services []string ) error {
205
+ func runProfiles (streams api.Streams , opts configOptions , services []string ) error {
202
206
set := map [string ]struct {}{}
203
207
project , err := opts .ToProject (services )
204
208
if err != nil {
@@ -220,7 +224,7 @@ func runProfiles(streams api.Streams, opts convertOptions, services []string) er
220
224
return nil
221
225
}
222
226
223
- func runConfigImages (streams api.Streams , opts convertOptions , services []string ) error {
227
+ func runConfigImages (streams api.Streams , opts configOptions , services []string ) error {
224
228
project , err := opts .ToProject (services )
225
229
if err != nil {
226
230
return err
0 commit comments