@@ -13,7 +13,7 @@ import (
1313)
1414
1515// ConfigList lists an app's config.
16- func (d * DryccCmd ) ConfigList (appID string , format string ) error {
16+ func (d * DryccCmd ) ConfigList (appID string , procType string ) error {
1717 s , appID , err := load (d .ConfigFile , appID )
1818 if err != nil {
1919 return err
@@ -23,35 +23,26 @@ func (d *DryccCmd) ConfigList(appID string, format string) error {
2323 return err
2424 }
2525
26- keys := * sortKeys (config .Values )
27- switch format {
28- case "oneline" :
29- var kv []string
30- for _ , key := range keys {
31- kv = append (kv , fmt .Sprintf ("%s=%s" , key , config .Values [key ]))
32- }
33- d .Println (strings .Join (kv , " " ))
34- case "diff" :
35- for _ , key := range keys {
36- d .Println (fmt .Sprintf ("%s=%s" , key , config .Values [key ]))
37- }
38- default :
39- table := d .getDefaultFormatTable ([]string {"UUID" , "OWNER" , "NAME" , "VALUE" })
40- for _ , key := range keys {
41- table .Append ([]string {
42- config .UUID ,
43- config .Owner ,
44- key ,
45- fmt .Sprintf ("%v" , config .Values [key ]),
46- })
47- }
48- table .Render ()
26+ configValues := config .Values
27+ if procType != "" {
28+ configValues = config .TypedValues [procType ]
29+ }
30+
31+ keys := * sortKeys (configValues )
32+ table := d .getDefaultFormatTable ([]string {"NAME" , "VALUE" })
33+
34+ for _ , key := range keys {
35+ table .Append ([]string {
36+ key ,
37+ fmt .Sprintf ("%v" , configValues [key ]),
38+ })
4939 }
40+ table .Render ()
5041 return nil
5142}
5243
5344// ConfigSet sets an app's config variables.
54- func (d * DryccCmd ) ConfigSet (appID string , configVars []string ) error {
45+ func (d * DryccCmd ) ConfigSet (appID string , procType string , configVars []string ) error {
5546 s , appID , err := load (d .ConfigFile , appID )
5647
5748 if err != nil {
@@ -84,8 +75,12 @@ to set up healthchecks. This functionality has been deprecated. In the future, p
8475 d .Print ("Creating config... " )
8576
8677 quit := progress (d .WOut )
87- configObj := api.Config {Values : configMap }
88- configObj , err = config .Set (s .Client , appID , configObj )
78+ configObj , err := config .Set (s .Client , appID , func () api.Config {
79+ if procType != "" {
80+ return api.Config {TypedValues : map [string ]api.ConfigValues {procType : configMap }}
81+ }
82+ return api.Config {Values : configMap }
83+ }())
8984 quit <- true
9085 <- quit
9186 if d .checkAPICompatibility (s .Client , err ) != nil {
@@ -98,11 +93,11 @@ to set up healthchecks. This functionality has been deprecated. In the future, p
9893 d .Print ("done\n \n " )
9994 }
10095
101- return d .ConfigList (appID , "" )
96+ return d .ConfigList (appID , procType )
10297}
10398
10499// ConfigUnset removes a config variable from an app.
105- func (d * DryccCmd ) ConfigUnset (appID string , configVars []string ) error {
100+ func (d * DryccCmd ) ConfigUnset (appID string , procType string , configVars []string ) error {
106101 s , appID , err := load (d .ConfigFile , appID )
107102
108103 if err != nil {
@@ -132,11 +127,11 @@ func (d *DryccCmd) ConfigUnset(appID string, configVars []string) error {
132127
133128 d .Print ("done\n \n " )
134129
135- return d .ConfigList (appID , "" )
130+ return d .ConfigList (appID , procType )
136131}
137132
138133// ConfigPull pulls an app's config to a file.
139- func (d * DryccCmd ) ConfigPull (appID string , interactive bool , overwrite bool ) error {
134+ func (d * DryccCmd ) ConfigPull (appID , procType , fileName string , interactive bool , overwrite bool ) error {
140135 s , appID , err := load (d .ConfigFile , appID )
141136
142137 if err != nil {
@@ -153,36 +148,34 @@ func (d *DryccCmd) ConfigPull(appID string, interactive bool, overwrite bool) er
153148 if err != nil {
154149 return err
155150 }
151+ configValues := configVars .Values
152+ if procType != "" {
153+ configValues = configVars .TypedValues [procType ]
154+ }
156155
157156 if (stat .Mode () & os .ModeCharDevice ) == 0 {
158- d .Print (formatConfig (configVars . Values ))
157+ d .Print (formatConfig (configValues ))
159158 return nil
160159 }
161160
162- filename := ".env"
163-
164161 if ! overwrite {
165- if _ , err := os .Stat (filename ); err == nil {
166- return fmt .Errorf ("%s already exists, pass -o to overwrite" , filename )
162+ if _ , err := os .Stat (fileName ); err == nil {
163+ return fmt .Errorf ("%s already exists, pass -o to overwrite" , fileName )
167164 }
168165 }
169166
170167 if interactive {
171- contents , err := os .ReadFile (filename )
172-
168+ contents , err := os .ReadFile (fileName )
173169 if err != nil {
174170 return err
175171 }
176172 localConfigVars := strings .Split (string (contents ), "\n " )
177-
178173 configMap , err := parseConfig (localConfigVars [:len (localConfigVars )- 1 ])
179174 if err != nil {
180175 return err
181176 }
182-
183- for key , value := range configVars .Values {
177+ for key , value := range configValues {
184178 localValue , ok := configMap [key ]
185-
186179 if ok {
187180 if value != localValue {
188181 var confirm string
@@ -198,15 +191,13 @@ func (d *DryccCmd) ConfigPull(appID string, interactive bool, overwrite bool) er
198191 configMap [key ] = value
199192 }
200193 }
201-
202- return os .WriteFile (filename , []byte (formatConfig (configMap )), 0755 )
194+ return os .WriteFile (fileName , []byte (formatConfig (configMap )), 0755 )
203195 }
204-
205- return os .WriteFile (filename , []byte (formatConfig (configVars .Values )), 0755 )
196+ return os .WriteFile (fileName , []byte (formatConfig (configValues )), 0755 )
206197}
207198
208199// ConfigPush pushes an app's config from a file.
209- func (d * DryccCmd ) ConfigPush (appID , fileName string ) error {
200+ func (d * DryccCmd ) ConfigPush (appID , procType string , fileName string ) error {
210201 stat , err := os .Stdin .Stat ()
211202
212203 if err != nil {
@@ -238,11 +229,11 @@ func (d *DryccCmd) ConfigPush(appID, fileName string) error {
238229 }
239230 }
240231
241- return d .ConfigSet (appID , config )
232+ return d .ConfigSet (appID , procType , config )
242233}
243234
244- func parseConfig (configVars []string ) (map [ string ] interface {} , error ) {
245- configMap := make (map [ string ] interface {} )
235+ func parseConfig (configVars []string ) (api. ConfigValues , error ) {
236+ configMap := make (api. ConfigValues )
246237
247238 regex := regexp .MustCompile (`^([A-z_]+[A-z0-9_]*)=([\s\S]*)$` )
248239 for _ , config := range configVars {
0 commit comments