@@ -162,9 +162,14 @@ type Source struct {
162162 //
163163 // Mandatory
164164 //
165- Owner string `json:"owner"`
166- Repo string `json:"repo"`
165+ Owner string `json:"owner"`
166+ Repo string `json:"repo"`
167+ // Mandatory if not using github app auth
167168 AccessToken string `json:"access_token"` // SENSITIVE
169+
170+ // Mandatory if using github app auth
171+ GitHubApp * github.GitHubApp `json:"github_app,omitempty"`
172+
168173 //
169174 // Optional
170175 //
@@ -193,6 +198,21 @@ func (src Source) String() string {
193198 fmt .Fprintf (& bld , "omit_target_url: %t\n " , src .OmitTargetURL )
194199 fmt .Fprintf (& bld , "chat_append_summary: %t\n " , src .ChatAppendSummary )
195200 fmt .Fprintf (& bld , "chat_notify_on_states: %s\n " , src .ChatNotifyOnStates )
201+
202+ // fmt.Fprintf(&bld, "owner: %s\n", src.Owner)
203+ // fmt.Fprintf(&bld, "repo: %s\n", src.Repo)
204+ // fmt.Fprintf(&bld, "github_hostname: %s\n", src.GhHostname)
205+ // fmt.Fprintf(&bld, "access_token: %s\n", redact(src.AccessToken))
206+ // // FIX: avoid panic is src.GitHubApp is nil
207+ // fmt.Fprintf(&bld, "github_app.client_id: %s\n", src.GitHubApp.ClientId)
208+ // fmt.Fprintf(&bld, "github_app.installation_id: %d\n", src.GitHubApp.InstallationId)
209+ // fmt.Fprintf(&bld, "github_app.private_key: %s\n", redact(src.GitHubApp.PrivateKey))
210+ // fmt.Fprintf(&bld, "gchat_webhook: %s\n", redact(src.GChatWebHook))
211+ // fmt.Fprintf(&bld, "log_level: %s\n", src.LogLevel)
212+ // fmt.Fprintf(&bld, "context_prefix: %s\n", src.ContextPrefix)
213+ // fmt.Fprintf(&bld, "omit_target_url: %t\n", src.OmitTargetURL)
214+ // fmt.Fprintf(&bld, "chat_append_summary: %t\n", src.ChatAppendSummary)
215+ // fmt.Fprintf(&bld, "chat_notify_on_states: %s\n", src.ChatNotifyOnStates)
196216 // Last one: no newline.
197217 fmt .Fprintf (& bld , "sinks: %s" , src .Sinks )
198218
@@ -245,9 +265,23 @@ func (src *Source) Validate() error {
245265 if src .Repo == "" {
246266 mandatory = append (mandatory , "repo" )
247267 }
248- if src .AccessToken == "" {
268+ if src .AccessToken == "" && src .GitHubApp == nil {
269+ // missing access token or github_app
249270 mandatory = append (mandatory , "access_token" )
250271 }
272+ if src .AccessToken == "" && src .GitHubApp != nil {
273+ if src .GitHubApp .ClientId == "" {
274+ mandatory = append (mandatory , "github_app.client_id" )
275+ }
276+ if src .GitHubApp .InstallationId == 0 {
277+ mandatory = append (mandatory , "github_app.installation_id" )
278+ }
279+ if src .GitHubApp .PrivateKey == "" {
280+ mandatory = append (mandatory , "github_app.private_key" )
281+ }
282+ }
283+ // if both src.AccessToken and src.GitHubApp are set; we should
284+ // fail the run
251285 }
252286
253287 if sinks .Contains ("gchat" ) {
0 commit comments