MCPcopy Create free account
hub / github.com/github/gh-aw / parseDispatchRepositoryConfig

Method parseDispatchRepositoryConfig

pkg/workflow/dispatch_repository.go:30–124  ·  view source on GitHub ↗

parseDispatchRepositoryConfig parses dispatch-repository configuration from the safe-outputs map.

(outputMap map[string]any)

Source from the content-addressed store, hash-verified

28
29// parseDispatchRepositoryConfig parses dispatch-repository configuration from the safe-outputs map.
30func (c *Compiler) parseDispatchRepositoryConfig(outputMap map[string]any) *DispatchRepositoryConfig {
31 dispatchRepositoryLog.Print("Parsing dispatch-repository configuration")
32
33 var configData any
34 var exists bool
35
36 // dispatch-repository is canonical; keep underscore form as a backward-compatible alias.
37 if configData, exists = outputMap["dispatch-repository"]; !exists {
38 if configData, exists = outputMap["dispatch_repository"]; !exists {
39 return nil
40 }
41 dispatchRepositoryLog.Print("WARNING: safe-outputs.dispatch_repository is deprecated; rename to dispatch-repository or run `gh aw fix`")
42 }
43
44 configMap, ok := configData.(map[string]any)
45 if !ok {
46 dispatchRepositoryLog.Print("dispatch-repository value is not a map, skipping")
47 return nil
48 }
49
50 dispatchRepositoryLog.Printf("Parsing dispatch-repository tools map with %d entries", len(configMap))
51
52 dispatchRepoConfig := &DispatchRepositoryConfig{
53 Tools: make(map[string]*DispatchRepositoryToolConfig),
54 }
55
56 for toolKey, toolValue := range configMap {
57 toolMap, ok := toolValue.(map[string]any)
58 if !ok {
59 dispatchRepositoryLog.Printf("Skipping tool %q: value is not a map", toolKey)
60 continue
61 }
62
63 tool := &DispatchRepositoryToolConfig{}
64
65 if desc, ok := toolMap["description"].(string); ok {
66 tool.Description = desc
67 }
68
69 if workflow, ok := toolMap["workflow"].(string); ok {
70 tool.Workflow = workflow
71 }
72
73 if eventType, ok := toolMap["event_type"].(string); ok {
74 tool.EventType = eventType
75 }
76
77 if repo, ok := toolMap["repository"].(string); ok {
78 tool.Repository = repo
79 }
80
81 // Parse allowed_repositories (list of repos)
82 if allowedReposRaw, exists := toolMap["allowed_repositories"]; exists {
83 if allowedReposList, ok := allowedReposRaw.([]any); ok {
84 for _, r := range allowedReposList {
85 if rStr, ok := r.(string); ok {
86 tool.AllowedRepositories = append(tool.AllowedRepositories, rStr)
87 }

Calls 5

templatableIntValueFunction · 0.85
defaultIntStrFunction · 0.85
PrintMethod · 0.80
PrintfMethod · 0.45