Skip to content
Open

Pr/exec #1787

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
key: cache-${{ hashFiles('**/go.sum') }}-${{ hashFiles('.bin/*') }}
restore-keys: |
cache-
- name: Install pyyaml for backstage test
run: pip3 install pyyaml
- name: Test
run: make test

Expand Down Expand Up @@ -104,6 +106,8 @@ jobs:
key: cache-${{ hashFiles('**/go.sum') }}-${{ hashFiles('.bin/*') }}
restore-keys: |
cache-
- name: Install pyyaml for backstage test
run: pip3 install pyyaml
- name: Test
run: make test-prod

Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ external/diffgen/target
# For AI agents
TODO.md
.envrc
.db/
bin/
out/
._DS_Store

exec-checkout/
__debug_bin*
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ MODERNIZE ?= $(LOCALBIN)/modernize
## Tool Versions
KUSTOMIZE_VERSION ?= v3.8.7
CONTROLLER_TOOLS_VERSION ?= v0.19.0
GOLANGCI_LINT_VERSION ?= v2.1.6
GOLANGCI_LINT_VERSION ?= v2.7.2

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"

Expand Down
26 changes: 26 additions & 0 deletions api/v1/exec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package v1

import (
"github.com/flanksource/duty/connection"
"github.com/flanksource/duty/shell"
"github.com/flanksource/duty/types"
)

type Exec struct {
BaseScraper `json:",inline"`

// Script is an inline script to run
Script string `json:"script" yaml:"script" template:"true"`

// Connections for AWS/GCP/Azure/K8s credential injection
Connections *connection.ExecConnections `json:"connections,omitempty" yaml:"connections,omitempty" template:"true"`

// Git repository to checkout before running script
Checkout *connection.GitConnection `json:"checkout,omitempty" yaml:"checkout,omitempty"`

// Environment variables
Env []types.EnvVar `json:"env,omitempty" yaml:"env,omitempty"`

// Artifacts to collect after execution
Artifacts []shell.Artifact `json:"artifacts,omitempty" yaml:"artifacts,omitempty" template:"true"`
}
3 changes: 3 additions & 0 deletions api/v1/scrapeconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ func (t *ScrapeConfig) Type() string {
if len(t.Spec.HTTP) != 0 {
return "http"
}
if len(t.Spec.Exec) != 0 {
return "exec"
}
return ""
}

Expand Down
6 changes: 6 additions & 0 deletions api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var AllScraperConfigs = map[string]any{
"aws": AWS{},
"azure": Azure{},
"azuredevops": AzureDevops{},
"exec": Exec{},
"file": File{},
"gcp": GCP{},
"githubactions": GitHubActions{},
Expand Down Expand Up @@ -68,6 +69,7 @@ type ScraperSpec struct {
Clickhouse []Clickhouse `json:"clickhouse,omitempty"`
Logs []Logs `json:"logs,omitempty"`
PubSub []PubSub `json:"pubsub,omitempty"`
Exec []Exec `json:"exec,omitempty" yaml:"exec,omitempty"`
System bool `json:"system,omitempty"`

// CRDSync when set to true, will create (or update) the corresponding database record
Expand Down Expand Up @@ -140,6 +142,10 @@ func (c ScraperSpec) ApplyPlugin(plugins []ScrapePluginSpec) ScraperSpec {
spec.Logs[i].BaseScraper = spec.Logs[i].BaseScraper.ApplyPlugins(plugins...)
}

for i := range spec.Exec {
spec.Exec[i].BaseScraper = spec.Exec[i].BaseScraper.ApplyPlugins(plugins...)
}

return *spec
}

Expand Down
46 changes: 46 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading