MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / getProjectConfig

Function getProjectConfig

cmd/cql-proxy/api/project.go:680–761  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

678}
679
680func getProjectConfig(c *gin.Context) {
681 // get all configs including tables/oauth config
682 r := struct {
683 DB proto.DatabaseID `json:"db" json:"project" form:"db" form:"project" uri:"db" uri:"project" binding:"required,len=64"`
684 }{}
685
686 _ = c.ShouldBindUri(&r)
687
688 if err := c.ShouldBind(&r); err != nil {
689 abortWithError(c, http.StatusBadRequest, err)
690 return
691 }
692
693 projectData, projectDB, err := getProjectDB(c, r.DB)
694 if err != nil {
695 _ = c.Error(err)
696 abortWithError(c, http.StatusForbidden, ErrLoadProjectDatabaseFailed)
697 return
698 }
699
700 projectConfigList, err := model.GetAllProjectConfig(projectDB)
701 if err != nil {
702 _ = c.Error(err)
703 abortWithError(c, http.StatusInternalServerError, ErrGetProjectConfigFailed)
704 return
705 }
706
707 var (
708 miscConfig interface{}
709 groupConfig interface{}
710 oauthConfig []gin.H
711 tablesConfig []gin.H
712 )
713 for _, p := range projectConfigList {
714 switch p.Type {
715 case model.ProjectConfigMisc:
716 miscConfig = p.Value
717 case model.ProjectConfigOAuth:
718 oauthConfig = append(oauthConfig, gin.H{
719 "provider": p.Key,
720 "config": p.Value,
721 })
722 case model.ProjectConfigTable:
723 tablesConfig = append(tablesConfig, gin.H{
724 "table": p.Key,
725 "config": p.Value,
726 })
727 case model.ProjectConfigGroup:
728 groupConfig = p.Value
729 }
730 }
731
732 if miscConfig == nil {
733 miscConfig = map[string]interface{}{}
734 } else if mc, ok := miscConfig.(*model.ProjectMiscConfig); !ok || mc == nil {
735 miscConfig = map[string]interface{}{}
736 }
737

Callers

nothing calls this directly

Calls 6

GetAllProjectConfigFunction · 0.92
abortWithErrorFunction · 0.85
getProjectDBFunction · 0.85
getConfigFunction · 0.85
responseWithDataFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected