@@ -7,12 +7,15 @@ import (
77
88 "github.com/arschles/kubeapp/api/rc"
99 "github.com/deis/workflow-manager/data"
10+ "github.com/deis/workflow-manager/pkg/swagger/client/operations"
1011 "github.com/gorilla/mux"
12+ "github.com/satori/go.uuid"
1113)
1214
1315const (
1416 componentsRoute = "/components" // resource value for components route
1517 idRoute = "/id" // resource value for ID route
18+ doctorRoute = "/doctor"
1619)
1720
1821// RegisterRoutes attaches handler functions to routes
@@ -21,6 +24,7 @@ func RegisterRoutes(
2124 secretGetterCreator data.KubeSecretGetterCreator ,
2225 rcLister rc.Lister ,
2326 availableVersions data.AvailableVersions ,
27+ apiClient * apiclient.WorkflowManager ,
2428) * mux.Router {
2529
2630 clusterID := data .NewClusterIDFromPersistentStorage (secretGetterCreator )
@@ -31,6 +35,13 @@ func RegisterRoutes(
3135 secretGetterCreator ,
3236 ))
3337 r .Handle (idRoute , IDHandler (clusterID ))
38+ r .Handle (doctorRoute , DoctorHandler (
39+ data .NewInstalledDeisData (rcLister ),
40+ clusterID ,
41+ data .NewLatestReleasedComponent (secretGetterCreator , rcLister , availableVersions ),
42+ secretGetterCreator ,
43+ apiclient ,
44+ ))
3445 return r
3546}
3647
@@ -53,6 +64,28 @@ func ComponentsHandler(
5364 })
5465}
5566
67+ // DoctorHandler route handler
68+ func DoctorHandler (
69+ c data.InstalledData ,
70+ i data.ClusterID ,
71+ v data.AvailableComponentVersion ,
72+ secretGetterCreator data.KubeSecretGetterCreator ,
73+ apiClient * apiclient.WorkflowManager ,
74+ ) http.Handler {
75+ return http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
76+ doctor , err := data .GetDoctorInfo (c , i , v , secretGetterCreator )
77+ if err != nil {
78+ http .Error (w , err .Error (), http .StatusInternalServerError )
79+ return
80+ }
81+ _ , err = apiClient .Operations .PublishDoctorInfo (& operations.PublishDoctorInfoParams {Body : doctor , UUID : uuid .NewV4 ().String ()})
82+ if err != nil {
83+ http .Error (w , err .Error (), http .StatusInternalServerError )
84+ return
85+ }
86+ })
87+ }
88+
5689// IDHandler route handler
5790func IDHandler (getter data.ClusterID ) http.Handler {
5891 return http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
0 commit comments