-
Notifications
You must be signed in to change notification settings - Fork 200
Add plugin imports and merging support #14376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -29,6 +29,7 @@ type ImportsResult struct { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MergedPermissions string // Merged permissions configuration from all imports | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MergedSecretMasking string // Merged secret-masking steps from all imports | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MergedBots []string // Merged bots list from all imports (union of bot names) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MergedPlugins []string // Merged plugins list from all imports (union of plugin repos) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MergedPostSteps string // Merged post-steps configuration from all imports (appended in order) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MergedLabels []string // Merged labels from all imports (union of label names) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MergedCaches []string // Merged cache configurations from all imports (appended in order) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -180,6 +181,8 @@ func processImportsFromFrontmatterWithManifestAndSource(frontmatter map[string]a | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var safeInputs []string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var bots []string // Track unique bot names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| botsSet := make(map[string]bool) // Set for deduplicating bots | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var plugins []string // Track unique plugin repos | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pluginsSet := make(map[string]bool) // Set for deduplicating plugins | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var labels []string // Track unique labels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| labelsSet := make(map[string]bool) // Set for deduplicating labels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var caches []string // Track cache configurations (appended in order) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -544,6 +547,21 @@ func processImportsFromFrontmatterWithManifestAndSource(frontmatter map[string]a | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Extract plugins from imported file (merge into set to avoid duplicates) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pluginsContent, err := extractPluginsFromContent(string(content)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if err == nil && pluginsContent != "" && pluginsContent != "[]" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Parse plugins JSON array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var importedPlugins []string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if jsonErr := json.Unmarshal([]byte(pluginsContent), &importedPlugins); jsonErr == nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for _, plugin := range importedPlugins { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if !pluginsSet[plugin] { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pluginsSet[plugin] = true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| plugins = append(plugins, plugin) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+553
to
+560
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Parse plugins JSON array | |
| var importedPlugins []string | |
| if jsonErr := json.Unmarshal([]byte(pluginsContent), &importedPlugins); jsonErr == nil { | |
| for _, plugin := range importedPlugins { | |
| if !pluginsSet[plugin] { | |
| pluginsSet[plugin] = true | |
| plugins = append(plugins, plugin) | |
| } | |
| // Parse plugins JSON which may be either: | |
| // - a JSON array of strings: ["owner/repo", ...] | |
| // - a JSON object: { "repos": ["owner/repo", ...], "github-token": "..." } | |
| var importedPluginsRaw any | |
| if jsonErr := json.Unmarshal([]byte(pluginsContent), &importedPluginsRaw); jsonErr == nil { | |
| switch v := importedPluginsRaw.(type) { | |
| case []any: | |
| for _, item := range v { | |
| plugin, ok := item.(string) | |
| if !ok { | |
| continue | |
| } | |
| if !pluginsSet[plugin] { | |
| pluginsSet[plugin] = true | |
| plugins = append(plugins, plugin) | |
| } | |
| } | |
| case map[string]any: | |
| if reposRaw, ok := v["repos"]; ok { | |
| if reposSlice, ok := reposRaw.([]any); ok { | |
| for _, item := range reposSlice { | |
| plugin, ok := item.(string) | |
| if !ok { | |
| continue | |
| } | |
| if !pluginsSet[plugin] { | |
| pluginsSet[plugin] = true | |
| plugins = append(plugins, plugin) | |
| } | |
| } | |
| } | |
| } | |
| // Note: imported "github-token" (if present) is intentionally ignored here | |
| // to avoid changing existing token-handling behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extractPluginsFromContentreturns the raw JSON for thepluginsfrontmatter field. Sincepluginsalso supports the object form ({ repos: [...], github-token: ... }), callers that expect a JSON array (as in import processing) will silently fail to extract any plugins when the object form is used. Consider making this helper return a normalized JSON array of repos (matching the array form) or introducing a dedicated extractor that always yields[]stringrepos regardless of whether the source was array or object format.