@@ -46,8 +46,11 @@ type listEnvElementOutput struct {
46
46
Name string `json:"name"`
47
47
Type string `json:"type"`
48
48
Value * string `json:"value"`
49
+
49
50
// Context specifies the name of the context.
50
- Context * string `json:"context"`
51
+ Context * string `json:"context"`
52
+ IsAutoattached * bool `json:"isAutoattached"`
53
+
51
54
// Runtime is not printed, it's just used to determine output formatting.
52
55
Runtime bool `json:"runtime"`
53
56
// WriteOnly is not printed, it's just used to determine output formatting.
@@ -64,7 +67,14 @@ type runtimeConfig struct {
64
67
65
68
type listEnvQuery struct {
66
69
Stack struct {
67
- RuntimeConfig []runtimeConfig `graphql:"runtimeConfig" json:"runtimeConfig"`
70
+ RuntimeConfig []runtimeConfig `graphql:"runtimeConfig" json:"runtimeConfig"`
71
+ AttachedContexts []struct {
72
+ ContextID string `graphql:"contextId" json:"contextId,omitempty"`
73
+ Name string `graphql:"contextName" json:"name,omitempty"`
74
+ Priority int `graphql:"priority" json:"priority,omitempty"`
75
+ IsAutoattached bool `graphql:"isAutoattached" json:"isAutoattached"`
76
+ Config []configElement `graphql:"config" json:"config,omitempty"`
77
+ } `graphql:"attachedContexts"`
68
78
} `graphql:"stack(id: $stack)" json:"stack"`
69
79
}
70
80
@@ -140,16 +150,37 @@ func (e *listEnvCommand) listEnv(cliCtx *cli.Context) error {
140
150
for _ , config := range query .Stack .RuntimeConfig {
141
151
config := config
142
152
var contextName * string
153
+ var isAutoAttached * bool
143
154
if config .Context != nil {
144
155
contextName = & config .Context .ContextName
156
+
157
+ f := false
158
+ isAutoAttached = & f
145
159
}
146
- if element , err := config .Element .toConfigElementOutput (contextName ); err == nil {
160
+
161
+ if element , err := config .Element .toConfigElementOutput (contextName , isAutoAttached ); err == nil {
147
162
elements = append (elements , element )
148
163
} else {
149
164
return err
150
165
}
151
166
}
152
167
168
+ for _ , spcCtx := range query .Stack .AttachedContexts {
169
+ // If the context is not autoattached, we will get it with the whole config.
170
+ // If it's autoattached, we have to specifically list and attach it.
171
+ if ! spcCtx .IsAutoattached {
172
+ continue
173
+ }
174
+
175
+ for _ , config := range spcCtx .Config {
176
+ if element , err := config .toConfigElementOutput (& spcCtx .Name , & spcCtx .IsAutoattached ); err == nil {
177
+ elements = append (elements , element )
178
+ } else {
179
+ return err
180
+ }
181
+ }
182
+ }
183
+
153
184
switch outputFormat {
154
185
case cmd .OutputFormatTable :
155
186
return e .showOutputsTable (elements )
@@ -161,7 +192,7 @@ func (e *listEnvCommand) listEnv(cliCtx *cli.Context) error {
161
192
}
162
193
163
194
func (e * listEnvCommand ) showOutputsTable (outputs []listEnvElementOutput ) error {
164
- tableData := [][]string {{"Name" , "Type" , "Value" , "Context" }}
195
+ tableData := [][]string {{"Name" , "Type" , "Value" , "Context" , "IsAutoattached" }}
165
196
for _ , output := range outputs {
166
197
var row []string
167
198
@@ -189,6 +220,12 @@ func (e *listEnvCommand) showOutputsTable(outputs []listEnvElementOutput) error
189
220
row = append (row , "" )
190
221
}
191
222
223
+ if output .IsAutoattached != nil {
224
+ row = append (row , fmt .Sprintf ("%v" , * output .IsAutoattached ))
225
+ } else {
226
+ row = append (row , "" )
227
+ }
228
+
192
229
tableData = append (tableData , row )
193
230
}
194
231
return cmd .OutputTable (tableData , true )
@@ -198,7 +235,7 @@ func (e *listEnvCommand) showOutputsJSON(outputs []listEnvElementOutput) error {
198
235
return cmd .OutputJSON (outputs )
199
236
}
200
237
201
- func (e * configElement ) toConfigElementOutput (contextName * string ) (listEnvElementOutput , error ) {
238
+ func (e * configElement ) toConfigElementOutput (contextName * string , isAutoAttached * bool ) (listEnvElementOutput , error ) {
202
239
var value = e .Value
203
240
204
241
if e .Type == fileTypeConfig && e .Value != nil {
@@ -214,12 +251,13 @@ func (e *configElement) toConfigElementOutput(contextName *string) (listEnvEleme
214
251
}
215
252
216
253
return listEnvElementOutput {
217
- Name : e .ID ,
218
- Type : string (e .Type ),
219
- Value : value ,
220
- Context : contextName ,
221
- Runtime : e .Runtime ,
222
- WriteOnly : e .WriteOnly ,
254
+ Name : e .ID ,
255
+ Type : string (e .Type ),
256
+ Value : value ,
257
+ Context : contextName ,
258
+ IsAutoattached : isAutoAttached ,
259
+ Runtime : e .Runtime ,
260
+ WriteOnly : e .WriteOnly ,
223
261
}, nil
224
262
}
225
263
0 commit comments