fix: import cycle

This commit is contained in:
tomaz jejcic
2023-09-13 14:01:54 +02:00
parent 0edbef3173
commit 32392b9a61
6 changed files with 34 additions and 38 deletions
+8 -12
View File
@@ -1,20 +1,16 @@
package constants
import (
"github.com/foomo/contentfulvalidation/validator"
const (
SeverityFatal Severity = "fatal"
SeverityError Severity = "error"
SeverityWarn Severity = "warn"
SeverityInfo Severity = "info"
)
const (
SeverityFatal validator.Severity = "fatal"
SeverityError validator.Severity = "error"
SeverityWarn validator.Severity = "warn"
SeverityInfo validator.Severity = "info"
)
const (
HealthError validator.Health = "error"
HealthWarn validator.Health = "warn"
HealthOk validator.Health = "ok"
HealthError Health = "error"
HealthWarn Health = "warn"
HealthOk Health = "ok"
)
const DateFormat = "02 Jan 2006"
+4
View File
@@ -0,0 +1,4 @@
package constants
type Severity string
type Health string
+1 -16
View File
@@ -2,11 +2,9 @@ package utils
import (
"encoding/json"
catvo "github.com/bestbytes/catalogue/vo"
"github.com/foomo/contentfulvalidation/constants"
"github.com/foomo/contentfulvalidation/validator"
"time"
catvo "github.com/bestbytes/catalogue/vo"
"github.com/foomo/contentful"
"github.com/pkg/errors"
)
@@ -54,16 +52,3 @@ func ConvertTimeFormat(timeToFormat string, parseTemplate string, formatTemplate
}
return p.Format(formatTemplate), nil
}
func InitEmptyValidationResult(modelType validator.ModelType, modelID validator.ModelID, title string, internalTitle string, lastUpdatedDate string) *validator.ValidationResult {
var messages []*validator.ValidationResultMessage
return &validator.ValidationResult{
ID: modelID,
Title: title,
InternalTitle: internalTitle,
LastUpdatedDate: lastUpdatedDate,
ModelType: modelType,
Health: constants.HealthOk,
Messages: messages,
}
}
+5 -5
View File
@@ -8,17 +8,17 @@ type ValidationResult struct {
InternalTitle string `json:"internalTitle,omitempty"`
LastUpdatedDate string `json:"lastUpdatedDate,omitempty"`
ModelType ModelType `json:"modelType"`
Health Health `json:"health"`
Health constants.Health `json:"health"`
Messages []*ValidationResultMessage `json:"messages"`
}
type ValidationResultMessage struct {
Code MessageCode `json:"code"`
Message string `json:"message"`
Severity Severity `json:"severity"`
Code MessageCode `json:"code"`
Message string `json:"message"`
Severity constants.Severity `json:"severity"`
}
func (result *ValidationResult) Log(severity Severity, message string, code MessageCode) {
func (result *ValidationResult) Log(severity constants.Severity, message string, code MessageCode) {
msg := &ValidationResultMessage{
Code: code,
Message: message,
+16 -3
View File
@@ -1,12 +1,12 @@
package validator
import (
"github.com/foomo/contentfulvalidation/constants"
"github.com/foomo/contentfulvalidation/errors"
"github.com/foomo/contentfulvalidation/utils"
"strings"
"time"
"github.com/foomo/contentfulvalidation/constants"
"github.com/foomo/contentfulvalidation/errors"
"github.com/foomo/contentfulvalidation/utils"
"github.com/foomo/contentserver/client"
keellog "github.com/foomo/keel/log"
"go.uber.org/zap"
@@ -159,3 +159,16 @@ func (v *Validator) getValidatorByType(modelType ModelType) (ModelValidator, *er
}
return validator, nil
}
func InitEmptyValidationResult(modelType ModelType, modelID ModelID, title string, internalTitle string, lastUpdatedDate string) *ValidationResult {
var messages []*ValidationResultMessage
return &ValidationResult{
ID: modelID,
Title: title,
InternalTitle: internalTitle,
LastUpdatedDate: lastUpdatedDate,
ModelType: modelType,
Health: constants.HealthOk,
Messages: messages,
}
}
-2
View File
@@ -4,8 +4,6 @@ type SysType string
type ModelType string
type ModelID string
type MessageCode string
type Severity string
type Health string
type ValidationResults map[ModelType]map[ModelID]*ValidationResult