@@ -1158,6 +1158,21 @@ func (envs *Manager) CreateAutoEnvironment(workflowPath string, userVars map[str
11581158 }
11591159 }
11601160
1161+ lastRequestUser := & evpb.User {}
1162+ lastRequestUserJ , ok := userVars ["last_request_user" ]
1163+ if ok {
1164+ _ = json .Unmarshal ([]byte (lastRequestUserJ ), lastRequestUser )
1165+ }
1166+
1167+ the .EventWriterWithTopic (topic .Environment ).WriteEvent (& evpb.Ev_EnvironmentEvent {
1168+ EnvironmentId : newId .String (),
1169+ State : "PENDING" ,
1170+ Transition : "CREATE" ,
1171+ TransitionStep : "before_CREATE" ,
1172+ Message : "instantiating" ,
1173+ LastRequestUser : lastRequestUser ,
1174+ })
1175+
11611176 env , err := newEnvironment (envUserVars , newId )
11621177 newEnvId := uid .NilID ()
11631178 if err == nil && env != nil {
@@ -1173,6 +1188,15 @@ func (envs *Manager) CreateAutoEnvironment(workflowPath string, userVars map[str
11731188 "partition" : newEnvId .String (),
11741189 }).Info ("creating new automatic environment" )
11751190
1191+ the .EventWriterWithTopic (topic .Environment ).WriteEvent (& evpb.Ev_EnvironmentEvent {
1192+ EnvironmentId : newId .String (),
1193+ State : "PENDING" ,
1194+ Transition : "CREATE" ,
1195+ TransitionStep : "before_CREATE" ,
1196+ Message : "running hooks" ,
1197+ LastRequestUser : lastRequestUser ,
1198+ })
1199+
11761200 env .addSubscription (sub )
11771201 defer env .closeStream ()
11781202
@@ -1193,6 +1217,15 @@ func (envs *Manager) CreateAutoEnvironment(workflowPath string, userVars map[str
11931217 Warn ("parse workflow public info failed." )
11941218 }
11951219
1220+ the .EventWriterWithTopic (topic .Environment ).WriteEvent (& evpb.Ev_EnvironmentEvent {
1221+ EnvironmentId : newId .String (),
1222+ State : "PENDING" ,
1223+ Transition : "CREATE" ,
1224+ TransitionStep : "CREATE" ,
1225+ Message : "loading workflow" ,
1226+ LastRequestUser : lastRequestUser ,
1227+ })
1228+
11961229 env .workflow , err = envs .loadWorkflow (workflowPath , env .wfAdapter , workflowUserVars , env .BaseConfigStack )
11971230 if err != nil {
11981231 err = fmt .Errorf ("cannot load workflow template: %w" , err )
@@ -1202,6 +1235,17 @@ func (envs *Manager) CreateAutoEnvironment(workflowPath string, userVars map[str
12021235
12031236 env .Public , env .Description , _ = parseWorkflowPublicInfo (workflowPath )
12041237
1238+ cvs , _ := env .Workflow ().ConsolidatedVarStack ()
1239+ the .EventWriterWithTopic (topic .Environment ).WriteEvent (& evpb.Ev_EnvironmentEvent {
1240+ EnvironmentId : newId .String (),
1241+ State : env .CurrentState (),
1242+ Transition : "CREATE" ,
1243+ TransitionStep : "after_CREATE" ,
1244+ Message : "workflow loaded" ,
1245+ Vars : cvs , // we push the full var stack of the root role in the workflow loaded event
1246+ LastRequestUser : lastRequestUser ,
1247+ })
1248+
12051249 log .WithField ("method" , "CreateAutoEnvironment" ).
12061250 WithField ("level" , infologger .IL_Devel ).
12071251 Debug ("envman write lock" )
0 commit comments