validateSafeOutputsTarget validates target fields in all safe-outputs configurations Valid target values: - "" (empty/default) - uses "triggering" behavior - "triggering" - targets the triggering issue/PR/discussion - "*" - targets any item specified in the output - A positive integer as a string (e
(config *SafeOutputsConfig)
| 78 | // - A positive integer as a string (e.g., "123") |
| 79 | // - A GitHub Actions expression (e.g., "${{ github.event.issue.number }}") |
| 80 | func validateSafeOutputsTarget(config *SafeOutputsConfig) error { |
| 81 | if config == nil { |
| 82 | return nil |
| 83 | } |
| 84 | |
| 85 | safeOutputsTargetValidationLog.Print("Validating safe-outputs target fields") |
| 86 | |
| 87 | // List of configs to validate - each with a name for error messages |
| 88 | type targetConfig struct { |
| 89 | name string |
| 90 | target string |
| 91 | } |
| 92 | |
| 93 | var configs []targetConfig |
| 94 | |
| 95 | // Collect all target fields from various safe-output configurations |
| 96 | if config.UpdateIssues != nil { |
| 97 | configs = append(configs, targetConfig{"update-issue", config.UpdateIssues.Target}) |
| 98 | } |
| 99 | if config.UpdateDiscussions != nil { |
| 100 | configs = append(configs, targetConfig{"update-discussion", config.UpdateDiscussions.Target}) |
| 101 | } |
| 102 | if config.UpdatePullRequests != nil { |
| 103 | configs = append(configs, targetConfig{"update-pull-request", config.UpdatePullRequests.Target}) |
| 104 | } |
| 105 | if config.CloseIssues != nil { |
| 106 | configs = append(configs, targetConfig{"close-issue", config.CloseIssues.Target}) |
| 107 | } |
| 108 | if config.CloseDiscussions != nil { |
| 109 | configs = append(configs, targetConfig{"close-discussion", config.CloseDiscussions.Target}) |
| 110 | } |
| 111 | if config.ClosePullRequests != nil { |
| 112 | configs = append(configs, targetConfig{"close-pull-request", config.ClosePullRequests.Target}) |
| 113 | } |
| 114 | if config.AddLabels != nil { |
| 115 | configs = append(configs, targetConfig{"add-labels", config.AddLabels.Target}) |
| 116 | } |
| 117 | if config.RemoveLabels != nil { |
| 118 | configs = append(configs, targetConfig{"remove-labels", config.RemoveLabels.Target}) |
| 119 | } |
| 120 | if config.ReplaceLabel != nil { |
| 121 | configs = append(configs, targetConfig{"replace-label", config.ReplaceLabel.Target}) |
| 122 | } |
| 123 | if config.AddReviewer != nil { |
| 124 | configs = append(configs, targetConfig{"add-reviewer", config.AddReviewer.Target}) |
| 125 | } |
| 126 | if config.AssignMilestone != nil { |
| 127 | configs = append(configs, targetConfig{"assign-milestone", config.AssignMilestone.Target}) |
| 128 | } |
| 129 | if config.AssignToAgent != nil { |
| 130 | configs = append(configs, targetConfig{"assign-to-agent", config.AssignToAgent.Target}) |
| 131 | } |
| 132 | if config.AssignToUser != nil { |
| 133 | configs = append(configs, targetConfig{"assign-to-user", config.AssignToUser.Target}) |
| 134 | } |
| 135 | if config.LinkSubIssue != nil { |
| 136 | configs = append(configs, targetConfig{"link-sub-issue", config.LinkSubIssue.Target}) |
| 137 | } |