Skip to content

Commit

Permalink
[core] add public "bookkept" flag to enable bookkeeping of an environ…
Browse files Browse the repository at this point in the history
…ment
  • Loading branch information
knopers8 committed Sep 18, 2024
1 parent db5dbde commit 38127e5
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 18 deletions.
42 changes: 26 additions & 16 deletions common/protos/common.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions common/protos/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ message WorkflowTemplateInfo {
string description = 2;
string path = 3;
bool public = 4; // whether the environment is public or not
bool bookkept = 5; // whether the runs should be logged in bookkeeping
}
2 changes: 1 addition & 1 deletion common/protos/events.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions core/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ type Environment struct {
Public bool // From workflow or user
Description string // From workflow
WorkflowPath string // From workflow load
Bookkept bool // From workflow or user

callsPendingAwait map[string] /*await expression, trigger only*/ callable.CallsMap
currentTransition string
Expand Down Expand Up @@ -1409,6 +1410,7 @@ func (env *Environment) GetWorkflowInfo() *pb.WorkflowTemplateInfo {
Description: env.Description,
Path: env.WorkflowPath,
Public: env.Public,
Bookkept: env.Bookkept,
}
return out
}
Expand Down
4 changes: 4 additions & 0 deletions core/environment/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ func (envs *Manager) CreateEnvironment(workflowPath string, userVars map[string]
Public: workflowPublicInfo.IsPublic,
Name: workflowPublicInfo.Name,
Description: workflowPublicInfo.Description,
Bookkept: workflowPublicInfo.IsBookkept,
},
})

Expand Down Expand Up @@ -332,6 +333,7 @@ func (envs *Manager) CreateEnvironment(workflowPath string, userVars map[string]
env.name = workflowPublicInfo.Name
env.Description = workflowPublicInfo.Description
env.WorkflowPath = workflowPath
env.Bookkept = workflowPublicInfo.IsBookkept

the.EventWriterWithTopic(topic.Environment).WriteEvent(&evpb.Ev_EnvironmentEvent{
EnvironmentId: newId.String(),
Expand Down Expand Up @@ -1210,6 +1212,7 @@ func (envs *Manager) CreateAutoEnvironment(workflowPath string, userVars map[str
Public: workflowPublicInfo.IsPublic,
Name: workflowPublicInfo.Name,
Description: workflowPublicInfo.Description,
Bookkept: workflowPublicInfo.IsBookkept,
},
})

Expand All @@ -1232,6 +1235,7 @@ func (envs *Manager) CreateAutoEnvironment(workflowPath string, userVars map[str
env.name = workflowPublicInfo.Name
env.Description = workflowPublicInfo.Description
env.WorkflowPath = workflowPath
env.Bookkept = workflowPublicInfo.IsBookkept

the.EventWriterWithTopic(topic.Environment).WriteEvent(&evpb.Ev_EnvironmentEvent{
EnvironmentId: newId.String(),
Expand Down
7 changes: 6 additions & 1 deletion core/environment/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type WorkflowPublicInfo struct {
IsPublic bool
Name string
Description string
IsBookkept bool
}

func parseWorkflowPublicInfo(workflowExpr string) (WorkflowPublicInfo, error) {
Expand Down Expand Up @@ -67,8 +68,12 @@ func parseWorkflowPublicInfo(workflowExpr string) (WorkflowPublicInfo, error) {
if nodes["description"].Tag == "!public" {
description = nodes["description"].Value
}
bookkept := false
if nodes["bookkept"].Tag == "!public" {
bookkept = nodes["bookkept"].Value == "true"
}

return WorkflowPublicInfo{IsPublic: isPublic, Name: name, Description: description}, nil
return WorkflowPublicInfo{IsPublic: isPublic, Name: name, Description: description, IsBookkept: bookkept}, nil
}

func JSONSliceToSlice(payload string) (slice []string, err error) {
Expand Down

0 comments on commit 38127e5

Please sign in to comment.