mirror of
https://github.com/documize/community.git
synced 2025-08-05 13:35:25 +02:00
Continued MySQL/PostgreSQL store provider refactoring
Refactored, renamed, removed storage related code. Basic smoke test passed for PostgreSQL whilst fully working on MySQL variants as per usual.
This commit is contained in:
parent
b455e5eaf5
commit
97beb3f4d3
81 changed files with 1454 additions and 1497 deletions
|
@ -21,14 +21,14 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/section/provider"
|
||||
"github.com/documize/community/domain/store"
|
||||
)
|
||||
|
||||
// Provider represents Gemini
|
||||
type Provider struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Meta describes us.
|
||||
|
@ -154,7 +154,7 @@ func (p *Provider) Refresh(ctx *provider.Context, config, data string) (newData
|
|||
return
|
||||
}
|
||||
|
||||
func auth(ctx *provider.Context, store *domain.Store, w http.ResponseWriter, r *http.Request) {
|
||||
func auth(ctx *provider.Context, store *store.Store, w http.ResponseWriter, r *http.Request) {
|
||||
defer r.Body.Close()
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
|
||||
|
@ -222,7 +222,7 @@ func auth(ctx *provider.Context, store *domain.Store, w http.ResponseWriter, r *
|
|||
provider.WriteJSON(w, g)
|
||||
}
|
||||
|
||||
func workspace(ctx *provider.Context, store *domain.Store, w http.ResponseWriter, r *http.Request) {
|
||||
func workspace(ctx *provider.Context, store *store.Store, w http.ResponseWriter, r *http.Request) {
|
||||
defer r.Body.Close()
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
|
||||
|
@ -294,7 +294,7 @@ func workspace(ctx *provider.Context, store *domain.Store, w http.ResponseWriter
|
|||
provider.WriteJSON(w, workspace)
|
||||
}
|
||||
|
||||
func items(ctx *provider.Context, store *domain.Store, w http.ResponseWriter, r *http.Request) {
|
||||
func items(ctx *provider.Context, store *store.Store, w http.ResponseWriter, r *http.Request) {
|
||||
defer r.Body.Close()
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
|
||||
|
@ -369,7 +369,7 @@ func items(ctx *provider.Context, store *domain.Store, w http.ResponseWriter, r
|
|||
provider.WriteJSON(w, items)
|
||||
}
|
||||
|
||||
func secs(ctx *provider.Context, store *domain.Store, w http.ResponseWriter, r *http.Request) {
|
||||
func secs(ctx *provider.Context, store *store.Store, w http.ResponseWriter, r *http.Request) {
|
||||
sec, _ := getSecrets(ctx, store)
|
||||
provider.WriteJSON(w, sec)
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ package gemini
|
|||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/section/provider"
|
||||
"github.com/documize/community/domain/store"
|
||||
)
|
||||
|
||||
// the HTML that is rendered by this section.
|
||||
|
@ -87,7 +87,7 @@ type geminiConfig struct {
|
|||
Filter map[string]interface{} `json:"filter"`
|
||||
}
|
||||
|
||||
func (c *geminiConfig) Clean(ctx *provider.Context, store *domain.Store) {
|
||||
func (c *geminiConfig) Clean(ctx *provider.Context, store *store.Store) {
|
||||
if ctx != nil {
|
||||
sec, err := getSecrets(ctx, store)
|
||||
if err == nil {
|
||||
|
@ -103,7 +103,7 @@ func (c *geminiConfig) Clean(ctx *provider.Context, store *domain.Store) {
|
|||
c.URL = strings.TrimSpace(c.URL)
|
||||
}
|
||||
|
||||
func (c *geminiConfig) SaveSecrets(ctx *provider.Context, store *domain.Store) {
|
||||
func (c *geminiConfig) SaveSecrets(ctx *provider.Context, store *store.Store) {
|
||||
var sec secrets
|
||||
sec.APIKey = strings.TrimSpace(c.APIKey)
|
||||
sec.Username = strings.TrimSpace(c.Username)
|
||||
|
@ -117,7 +117,7 @@ type secrets struct {
|
|||
APIKey string `json:"apikey"`
|
||||
}
|
||||
|
||||
func getSecrets(ctx *provider.Context, store *domain.Store) (sec secrets, err error) {
|
||||
func getSecrets(ctx *provider.Context, store *store.Store) (sec secrets, err error) {
|
||||
err = ctx.UnmarshalSecrets(&sec, store)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue