@@ -3,6 +3,7 @@ package cmd
33import (
44 "fmt"
55 "log"
6+ "time"
67
78 "github.com/spf13/cobra"
89 ybApi "github.com/yottab/proto-api/proto"
1415 minScale uint64
1516 flagVarImage string
1617 flagVarEndpointType string
18+ flagVarExtra map [string ]string
1719)
1820
1921func appList (cmd * cobra.Command , args []string ) {
@@ -65,6 +67,8 @@ func appRun(cmd *cobra.Command, args []string) {
6567 log .Fatal ("no command run" )
6668 }
6769 req .Command = args [1 :]
70+ //TODO: will be replaced by an interactive aproach
71+ clientTimeout = 60 * time .Minute
6872 client := grpcConnect ()
6973 defer client .Close ()
7074 output , err := client .V2 ().AppShell (client .Context (), req )
@@ -112,7 +116,7 @@ func appDestroy(cmd *cobra.Command, args []string) {
112116}
113117
114118// ApplicationCreate create application by link of docker image
115- func ApplicationCreate (appName , image , plan , EndpointType string , port , minScale uint64 ) (* ybApi.AppStatusRes , error ) {
119+ func ApplicationCreate (appName , image , plan , EndpointType string , port , minScale uint64 , otherValues map [ string ] string ) (* ybApi.AppStatusRes , error ) {
116120 if err := endpointTypeValid (EndpointType ); err != nil {
117121 log .Panic (err )
118122 }
@@ -127,6 +131,11 @@ func ApplicationCreate(appName, image, plan, EndpointType string, port, minScale
127131 req .Values ["minimum-scale" ] = fmt .Sprintf ("%d" , minScale )
128132 req .Values ["image" ] = image
129133
134+ //Fill other values
135+ for key , val := range otherValues {
136+ req .Values [key ] = val
137+ }
138+
130139 client := grpcConnect ()
131140 defer client .Close ()
132141 return client .V2 ().AppCreate (client .Context (), req )
@@ -139,7 +148,8 @@ func appCreate(cmd *cobra.Command, args []string) {
139148 cmd .Flag ("plan" ).Value .String (),
140149 flagVarEndpointType ,
141150 flagVarPort ,
142- flagVarMinScale )
151+ flagVarMinScale ,
152+ flagVarExtra )
143153 uiCheckErr ("Could not Create the Application" , err )
144154 uiApplicationStatus (res )
145155}
@@ -173,6 +183,13 @@ func appUpdate(cmd *cobra.Command, args []string) {
173183 client := grpcConnect ()
174184 defer client .Close ()
175185
186+ //Fill other values
187+ for key , val := range flagVarExtra {
188+ if val != "" {
189+ req .Values [key ] = val
190+ }
191+ }
192+
176193 res , err := client .V2 ().AppConfigSet (client .Context (), req )
177194 uiCheckErr ("Could not Set the Config for Application" , err )
178195 uiApplicationStatus (res )
@@ -198,6 +215,15 @@ func appAddEnvironmentVariable(cmd *cobra.Command, args []string) {
198215 uiApplicationStatus (res )
199216}
200217
218+ func appAddEnvironmentFromDotEnv (cmd * cobra.Command , args []string ) {
219+ res , err := ApplicationAddEnvironmentVariable (
220+ getCliRequiredArg (args , 0 ),
221+ parseDotEnvFile (flagFile ))
222+
223+ uiCheckErr ("Could not Add the Environment Variable for Application (Dot env file)" , err )
224+ uiApplicationStatus (res )
225+ }
226+
201227func appRemoveEnvironmentVariable (cmd * cobra.Command , args []string ) {
202228 req := new (ybApi.UnsetReq )
203229 req .Name = getCliRequiredArg (args , 0 )
0 commit comments