Skip to content

Commit 12512f1

Browse files
committed
migrate schema.go and schema_test.go to golib/beamlines
1 parent 6f3ba3d commit 12512f1

4 files changed

Lines changed: 14 additions & 872 deletions

File tree

helpers.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"strings"
1212
"time"
1313

14+
beamlines "github.com/CHESSComputing/golib/beamlines"
1415
srvConfig "github.com/CHESSComputing/golib/config"
1516
server "github.com/CHESSComputing/golib/server"
1617
utils "github.com/CHESSComputing/golib/utils"
@@ -217,7 +218,7 @@ func genForm(c *gin.Context, fname string, record *map[string]any) (string, erro
217218
}
218219

219220
// helper function to create form entry
220-
func formEntry(c *gin.Context, smap map[string]SchemaRecord, k, s, required string, record *map[string]any) string {
221+
func formEntry(c *gin.Context, smap map[string]beamlines.SchemaRecord, k, s, required string, record *map[string]any) string {
221222
// check if provided record has value
222223
var defaultValue string
223224
if record != nil {
@@ -386,7 +387,7 @@ func processForm(r *http.Request) (string, map[string]any, error) {
386387
return fname, rec, err
387388
}
388389
} else {
389-
if !utils.InList(k, _skipKeys) {
390+
if !utils.InList(k, beamlines.SkipKeys) {
390391
log.Println("ERROR: no key", k, "found in schema map, error", err)
391392
return fname, rec, err
392393
}
@@ -449,10 +450,10 @@ func htmlInputs(rec map[string]any) []template.HTML {
449450
}
450451

451452
// helper function to parser form values
452-
func parseValue(schema *Schema, key string, items []string) (any, error) {
453+
func parseValue(schema *beamlines.Schema, key string, items []string) (any, error) {
453454
r, ok := schema.Map[key]
454455
if !ok {
455-
if srvConfig.Config.CHESSMetaData.TestMode && utils.InList[string](key, _skipKeys) {
456+
if srvConfig.Config.CHESSMetaData.TestMode && utils.InList[string](key, beamlines.SkipKeys) {
456457
return "", nil
457458
}
458459
msg := fmt.Sprintf("No key %s found in schema map", key)

0 commit comments

Comments
 (0)