Add system-info instance callback
Allow runners to update their own system information. Runners can now send back os_name, os_version and agent_id back as part of a POST to CALLBACK_URL/system-info/. The goal is to get better info in regard to the actual OS that's running and to move the agent_id from the status updates to the system-info callback. The status updates should be used only to send back info about the status of the installation process. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
8fe4f17e1c
commit
2a5e2409b2
5 changed files with 58 additions and 2 deletions
|
|
@ -324,3 +324,23 @@ func (a *APIController) InstanceStatusMessageHandler(w http.ResponseWriter, r *h
|
|||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
func (a *APIController) InstanceSystemInfoHandler(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
var updateMessage runnerParams.UpdateSystemInfoParams
|
||||
if err := json.NewDecoder(r.Body).Decode(&updateMessage); err != nil {
|
||||
log.Printf("failed to decode: %s", err)
|
||||
handleError(w, gErrors.ErrBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
if err := a.r.UpdateSystemInfo(ctx, updateMessage); err != nil {
|
||||
log.Printf("error saving status message: %s", err)
|
||||
handleError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,6 +106,8 @@ func NewAPIRouter(han *controllers.APIController, logWriter io.Writer, authMiddl
|
|||
callbackRouter := apiSubRouter.PathPrefix("/callbacks").Subrouter()
|
||||
callbackRouter.Handle("/status/", http.HandlerFunc(han.InstanceStatusMessageHandler)).Methods("POST", "OPTIONS")
|
||||
callbackRouter.Handle("/status", http.HandlerFunc(han.InstanceStatusMessageHandler)).Methods("POST", "OPTIONS")
|
||||
callbackRouter.Handle("/system-info/", http.HandlerFunc(han.InstanceSystemInfoHandler)).Methods("POST", "OPTIONS")
|
||||
callbackRouter.Handle("/system-info", http.HandlerFunc(han.InstanceSystemInfoHandler)).Methods("POST", "OPTIONS")
|
||||
callbackRouter.Use(instanceMiddleware.Middleware)
|
||||
|
||||
///////////////////
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue