-
Notifications
You must be signed in to change notification settings - Fork 19
git scraper #1925
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
base: main
Are you sure you want to change the base?
git scraper #1925
Changes from all commits
5784b99
405391f
587670e
cee32dd
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 |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package v1 | ||
|
|
||
| import "github.com/flanksource/duty/connection" | ||
|
|
||
| type GitFileStrategy string | ||
|
|
||
| const ( | ||
| GitFileStrategyIgnore GitFileStrategy = "ignore" | ||
| GitFileStrategyTrack GitFileStrategy = "track" | ||
| GitFileStrategyDiff GitFileStrategy = "diff" | ||
| ) | ||
|
|
||
| type GitFileRule struct { | ||
| Pattern string `json:"pattern" yaml:"pattern"` | ||
| Strategy GitFileStrategy `json:"strategy" yaml:"strategy"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:generate=true | ||
| type Git struct { | ||
| BaseScraper `json:",inline" yaml:",inline"` | ||
| connection.GitConnection `json:",inline" yaml:",inline"` | ||
|
|
||
| // Branches to track. Supports glob patterns (e.g. "release/*"). | ||
| // Defaults to the default branch only. | ||
| Branches []string `json:"branches,omitempty" yaml:"branches,omitempty"` | ||
|
|
||
| // Files configures per-glob file handling strategy. | ||
| // Default strategy for unmatched files is "track". | ||
| Files []GitFileRule `json:"files,omitempty" yaml:"files,omitempty"` | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ var AllScraperConfigs = map[string]any{ | |
| "exec": Exec{}, | ||
| "file": File{}, | ||
| "gcp": GCP{}, | ||
| "git": Git{}, | ||
| "github": GitHub{}, | ||
| "githubactions": GitHubActions{}, | ||
| "http": HTTP{}, | ||
|
|
@@ -66,6 +67,7 @@ type ScraperSpec struct { | |
| GCP []GCP `json:"gcp,omitempty" yaml:"gcp,omitempty"` | ||
| AWS []AWS `json:"aws,omitempty" yaml:"aws,omitempty"` | ||
| File []File `json:"file,omitempty" yaml:"file,omitempty"` | ||
| Git []Git `json:"git,omitempty" yaml:"git,omitempty"` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Git-only scraper specs can be misclassified as empty because 🔧 Proposed fix func (c ScraperSpec) IsEmpty() bool {
- return len(c.AWS) == 0 && len(c.File) == 0
+ return len(c.AWS) == 0 && len(c.File) == 0 && len(c.Git) == 0
}🤖 Prompt for AI Agents |
||
| Kubernetes []Kubernetes `json:"kubernetes,omitempty" yaml:"kubernetes,omitempty"` | ||
| KubernetesFile []KubernetesFile `json:"kubernetesFile,omitempty" yaml:"kubernetesFile,omitempty"` | ||
| AzureDevops []AzureDevops `json:"azureDevops,omitempty" yaml:"azureDevops,omitempty"` | ||
|
|
@@ -115,6 +117,10 @@ func (c ScraperSpec) ApplyPlugin(plugins []ScrapePluginSpec) ScraperSpec { | |
| spec.File[i].BaseScraper = spec.File[i].BaseScraper.ApplyPlugins(plugins...) | ||
| } | ||
|
|
||
| for i := range spec.Git { | ||
| spec.Git[i].BaseScraper = spec.Git[i].BaseScraper.ApplyPlugins(plugins...) | ||
| } | ||
|
|
||
| for i := range spec.Kubernetes { | ||
| spec.Kubernetes[i].BaseScraper = spec.Kubernetes[i].BaseScraper.ApplyPlugins(plugins...) | ||
| } | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Constrain
GitFileStrategyvalues at the API layer.GitFileRule.Strategycurrently accepts arbitrary strings. Invalid values can silently bypass expected file handling logic.🛡️ Proposed fix
+// +kubebuilder:validation:Enum=ignore;track;diff type GitFileStrategy string📝 Committable suggestion
🤖 Prompt for AI Agents