diff --git a/main.go b/main.go index 2964788f..a1348fde 100644 --- a/main.go +++ b/main.go @@ -70,6 +70,9 @@ func main() { cfg.Username: cfg.Password, })) + // Config path + system.GET("/config", handlers.MakeConfigHandler(cfg)) + // CRUD Services system.POST("/services", handlers.MakeCreateHandler(cfg, back)) system.GET("/services", handlers.MakeListHandler(back)) diff --git a/pkg/handlers/config.go b/pkg/handlers/config.go new file mode 100644 index 00000000..29160756 --- /dev/null +++ b/pkg/handlers/config.go @@ -0,0 +1,31 @@ +/* +Copyright (C) GRyCAP - I3M - UPV + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package handlers + +import ( + "net/http" + + "github.com/gin-gonic/gin" + "github.com/grycap/oscar/pkg/types" +) + +// MakeConfigHandler makes a handler for getting server's configuration +func MakeConfigHandler(cfg *types.Config) gin.HandlerFunc { + return func(c *gin.Context) { + c.JSON(http.StatusOK, cfg) + } +} diff --git a/pkg/types/config.go b/pkg/types/config.go index 25fdf059..1bdc29bd 100644 --- a/pkg/types/config.go +++ b/pkg/types/config.go @@ -39,35 +39,35 @@ const ( // Config stores the configuration for the OSCAR server type Config struct { // MinIOProvider access info - MinIOProvider *MinIOProvider + MinIOProvider *MinIOProvider `json:"minio_provider"` // Basic auth username - Username string + Username string `json:"-"` // Basic auth password - Password string + Password string `json:"-"` // Kubernetes name for the deployment and service (default: oscar) - Name string + Name string `json:"name"` // Kubernetes namespace for the deployment and service (default: oscar) - Namespace string + Namespace string `json:"namespace"` // Kubernetes namespace for services and jobs (default: oscar-svc) - ServicesNamespace string + ServicesNamespace string `json:"services_namespace"` // Port used for the ClusterIP k8s service (default: 8080) - ServicePort int + ServicePort int `json:"-"` // Serverless framework used to deploy services (Openfaas | Knative) // If not defined only async invokations allowed (Using KubeBackend) - ServerlessBackend string + ServerlessBackend string `json:"serverless_backend,omitempty"` // HTTP timeout for reading the payload (default: 300) - ReadTimeout time.Duration + ReadTimeout time.Duration `json:"-"` // HTTP timeout for writing the response (default: 300) - WriteTimeout time.Duration + WriteTimeout time.Duration `json:"-"` } func parseSeconds(s string) (time.Duration, error) {