Skip to content

Commit

Permalink
Add path to get system configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
srisco committed Jun 17, 2020
1 parent fabde91 commit 226a34a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 10 deletions.
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
31 changes: 31 additions & 0 deletions pkg/handlers/config.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
20 changes: 10 additions & 10 deletions pkg/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 226a34a

Please sign in to comment.