Conversation
|
I have the feeling this PR will not be accepted as it is, because you are already proposing other changes unrelated to the prometheus metrics. Th fastest way to have this feature merged is probably go easy on @crazy-max and provide him with a clean MR easy to review. |
| apimetrics: | ||
| enableApi: true | ||
| enableScan: true | ||
| token: ApiToken | ||
| port: 6080 | ||
| apiPath: /v1/metrics | ||
| scanPath: /v1/scan |
There was a problem hiding this comment.
Keys have inconsistent casing. It should probably be snake case ?
| Notif *model.Notif `yaml:"notif,omitempty" json:"notif,omitempty"` | ||
| RegOpts model.RegOpts `yaml:"regopts,omitempty" json:"regopts,omitempty" validate:"unique=Name,dive"` | ||
| Providers *model.Providers `yaml:"providers,omitempty" json:"providers,omitempty"` | ||
| APIMetrics *model.APIMetrics `yaml:"apimetrics,omitempty" json:"metricsapi,omitempty"` |
There was a problem hiding this comment.
The yaml and json key are different.
I personally think the naming is not the best, maybe "metrics" alone in better ?
| // New is a factory function creating a new Handler instance | ||
| func New(scanFn func()) *Handler { | ||
| return &Handler{ | ||
| fn: scanFn, | ||
| Path: "/v1/scan", | ||
| } | ||
| } | ||
|
|
||
| // Handler is an API handler used for triggering container update scans | ||
| type Handler struct { | ||
| fn func() | ||
| Path string | ||
| } | ||
|
|
||
| // Handle is the actual http.Handle function doing all the heavy lifting | ||
| func (handle *Handler) Handle(w http.ResponseWriter, r *http.Request) { | ||
| log.Info().Msg("Updates triggered by HTTP API request.") | ||
|
|
||
| _, err := io.Copy(os.Stdout, r.Body) | ||
| if err != nil { | ||
| log.Error().Err(err).Msg("Error") | ||
| return | ||
| } | ||
|
|
||
| handle.fn() | ||
| } |
There was a problem hiding this comment.
What is this used for in the context of the prometheus metrics ?
|
Hi @AthrogatePEQ would be awesome if you could get this merged, as this is really helpful. Would it be a problem if you took a look at @jooola suggestions and try to get it merged? Thank you! |
Added feature api end points for pulling metrics and triggering a new scan.
Added feature to pull docker images