Skip to content

Commit 6652448

Browse files
authored
Merge pull request #210 from metraction/PH-209/rate-limit-controller
Ph 209/rate limit controller action:create-release
2 parents 913ccf7 + 4f4988f commit 6652448

5 files changed

Lines changed: 13 additions & 1 deletion

File tree

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
- 'PH-198/*'
1414
- 'PH-201/*'
1515
- 'PH-205/*'
16-
- 'PH-207/*'
16+
- 'PH-209/*'
1717
pull_request:
1818
branches:
1919
- main

cmd/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ func init() {
182182
rootCmd.PersistentFlags().String("prometheus.auth.username", "", "Username for Prometheus authentication")
183183
rootCmd.PersistentFlags().String("prometheus.auth.password", "", "Password for Prometheus authentication")
184184
rootCmd.PersistentFlags().String("prometheus.auth.token", "", "Token for Prometheus authentication")
185+
rootCmd.PersistentFlags().String("prometheus.wait", "0s", "How long the reporter should wait after each post of a data")
185186

186187
rootCmd.PersistentFlags().String("database.driver", "postgres", "Database driver for the scanner, righ now, only 'postgres' is implemented.")
187188
defaultDSN := "postgres://postgres:postgres@localhost:5432/pharos?sslmode=disable" // run `brew install db-browser-for-sqlite` to view the database.

helm/pharos/templates/deployment-reporter.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ spec:
5252
- name: PHAROS_PROMETHEUS_CONTEXTLABELS
5353
value: {{ .Values.prometheus.contextLabels | quote }}
5454
{{- end }}
55+
{{- if .Values.prometheus.wait}}
56+
- name: PHAROS_PROMETHEUS_WAIT
57+
value: {{ .Values.prometheus.wait | quote }}
58+
{{- end }}
5559
- name: PHAROS_PROMETHEUS_NAMESPACE
5660
valueFrom:
5761
fieldRef:

internal/integrations/prometheus/pharostasksink.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"encoding/json"
66
"net/http"
7+
"time"
78

89
"github.com/metraction/pharos/internal/logging"
910
"github.com/metraction/pharos/internal/utils"
@@ -51,9 +52,14 @@ func (ps *PharosTaskSink) process() {
5152
ps.log.Error().Err(err).Msg("Failed to POST to PharosScanTask endpoint")
5253
continue
5354
}
55+
5456
pod := resp.Header.Get("Pharos-Pod-Name") // Read the pod name from the response header
5557
ps.log.Info().Str("image", scanTask.ImageSpec).Str("auth", utils.MaskDsn(scanTask.AuthDsn)).Str("Pod", pod).Msg("Sending task to PharosScanTask endpoint")
5658
resp.Body.Close()
59+
if d, err := time.ParseDuration(ps.Config.Prometheus.Wait); err == nil {
60+
ps.log.Info().Str("time", ps.Config.Prometheus.Wait).Msg("Waiting")
61+
time.Sleep(d)
62+
}
5763
}
5864
}
5965

pkg/model/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ type PrometheusReporterConfig struct {
105105
TTL string `mapstructure:"ttl"` // Time to live for the scan results
106106
Query string `mapstructure:"query"` // Query to use for fetching metrics
107107
Auth hwmodel.PrometheusAuth `mapstructure:"auth"` // Authentication details for Prometheus
108+
Wait string `mapstructure:"wait"` // How long to wait between each post of data
108109
}
109110

110111
// Redis holds Redis-specific configuration.

0 commit comments

Comments
 (0)