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

Function parseAppConfig

pkg/workflow/safe_outputs_app_config.go:35–104  ·  view source on GitHub ↗

======================================== App Configuration Parsing ======================================== parseAppConfig parses the app configuration from a map

(appMap map[string]any)

Source from the content-addressed store, hash-verified

33
34// parseAppConfig parses the app configuration from a map
35func parseAppConfig(appMap map[string]any) *GitHubAppConfig {
36 safeOutputsAppLog.Print("Parsing GitHub App configuration")
37 appConfig := &GitHubAppConfig{}
38
39 // Parse client-id/app-id (required)
40 // Prefer client-id when both are provided; app-id is accepted for backward compatibility.
41 if clientID, exists := appMap["client-id"]; exists {
42 if clientIDStr, ok := clientID.(string); ok {
43 appConfig.AppID = clientIDStr
44 }
45 } else if appID, exists := appMap["app-id"]; exists {
46 if appIDStr, ok := appID.(string); ok {
47 appConfig.AppID = appIDStr
48 }
49 }
50
51 // Parse private-key (required)
52 if privateKey, exists := appMap["private-key"]; exists {
53 if privateKeyStr, ok := privateKey.(string); ok {
54 appConfig.PrivateKey = privateKeyStr
55 }
56 }
57
58 // Parse ignore-if-missing behavior (optional): true to skip minting when key inputs are empty
59 if ignoreIfMissing, exists := appMap["ignore-if-missing"]; exists {
60 if ignore, ok := ignoreIfMissing.(bool); ok {
61 appConfig.IgnoreIfMissing = ignore
62 } else {
63 safeOutputsAppLog.Printf("Ignoring github-app.ignore-if-missing: expected boolean, got %T", ignoreIfMissing)
64 }
65 }
66
67 // Parse owner (optional)
68 if owner, exists := appMap["owner"]; exists {
69 if ownerStr, ok := owner.(string); ok {
70 appConfig.Owner = ownerStr
71 }
72 }
73
74 // Parse repositories (optional)
75 if repos, exists := appMap["repositories"]; exists {
76 if reposArray, ok := repos.([]any); ok {
77 var repoStrings []string
78 for _, repo := range reposArray {
79 if repoStr, ok := repo.(string); ok {
80 repoStrings = append(repoStrings, repoStr)
81 }
82 }
83 appConfig.Repositories = repoStrings
84 }
85 }
86
87 // Parse permissions (optional) - extra permission-* fields to merge into the minted token
88 if perms, exists := appMap["permissions"]; exists {
89 if permsMap, ok := perms.(map[string]any); ok {
90 appConfig.Permissions = make(map[string]string, len(permsMap))
91 for key, val := range permsMap {
92 if valStr, ok := val.(string); ok {

Calls 2

PrintMethod · 0.80
PrintfMethod · 0.45