diff --git a/gateway/rest/router.go b/gateway/rest/router.go index 8b19606c..640114b8 100644 --- a/gateway/rest/router.go +++ b/gateway/rest/router.go @@ -146,6 +146,10 @@ func newRouter(log log.Logger, addr sdk.Address, pclient provider.Client, ctxCon createManifestHandler(log, pclient.Manifest())). Methods(http.MethodPut) + drouter.HandleFunc("/manifest", + getManifestHandler(pclient.Manifest())). + Methods(http.MethodGet) + lrouter := router.PathPrefix(leasePathPrefix).Subrouter() lrouter.Use( requireOwner(), @@ -591,6 +595,29 @@ func createManifestHandler(log log.Logger, mclient pmanifest.Client) http.Handle } } +func getManifestHandler(log log.Logger, cclient cluster.ReadClient) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + found, grp, err := cclient.GetManifestGroup(r.Context(), requestLeaseID(r)) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + if !found { + http.Error(w, "lease not found", http.StatusNotFound) + return + } + + mgrp, _, err := grp.FromCRD() + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + writeJSON(log, w, &manifest.Manifest{mgrp}) + } +} + func leaseKubeEventsHandler(log log.Logger, cclient cluster.ReadClient) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { upgrader := websocket.Upgrader{ diff --git a/pkg/apis/akash.network/v2beta2/manifest.go b/pkg/apis/akash.network/v2beta2/manifest.go index d1b5681f..b08c6a4e 100644 --- a/pkg/apis/akash.network/v2beta2/manifest.go +++ b/pkg/apis/akash.network/v2beta2/manifest.go @@ -171,7 +171,7 @@ func (m *Manifest) Deployment() (ctypes.IDeployment, error) { return nil, err } - group, schedulerParams, err := m.Spec.Group.fromCRD() + group, schedulerParams, err := m.Spec.Group.FromCRD() if err != nil { return nil, err } @@ -185,8 +185,8 @@ func (m *Manifest) Deployment() (ctypes.IDeployment, error) { }, nil } -// toAkash returns akash group details formatted from manifest group -func (m *ManifestGroup) fromCRD() (mani.Group, []*SchedulerParams, error) { +// FromCRD returns akash group details formatted from manifest group +func (m *ManifestGroup) FromCRD() (mani.Group, []*SchedulerParams, error) { am := mani.Group{ Name: m.Name, Services: make([]mani.Service, 0, len(m.Services)),