refacto(models): Move models to the root of the project
This commit is contained in:
@ -6,7 +6,7 @@ import (
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers/api_types/gin_gonic"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers/api_types/go_swagger"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers/api_types/mojolicious"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers/models"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/models"
|
||||
)
|
||||
|
||||
// GetAPIType will return the APIType object based on an APITypeName.
|
||||
|
@ -1,7 +1,7 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers/models"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/models"
|
||||
)
|
||||
|
||||
// GetName return the APITypeName of the APIType.
|
||||
|
@ -1,7 +1,7 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers/models"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/models"
|
||||
|
||||
"github.com/juju/errors"
|
||||
)
|
||||
|
@ -1,7 +1,7 @@
|
||||
package gin_gonic
|
||||
|
||||
import (
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers/models"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/models"
|
||||
)
|
||||
|
||||
// GetName return the APITypeName of the APIType.
|
||||
|
@ -1,7 +1,7 @@
|
||||
package go_swagger
|
||||
|
||||
import (
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers/models"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/models"
|
||||
)
|
||||
|
||||
// GetName return the APITypeName of the APIType.
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"github.com/juju/errors"
|
||||
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers/models"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/models"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
@ -1,6 +1,6 @@
|
||||
package api_types
|
||||
|
||||
import "git.home.m-and-m.ovh/mderasse/gouick/helpers/models"
|
||||
import "git.home.m-and-m.ovh/mderasse/gouick/models"
|
||||
|
||||
// APITypeInterface is the interface that need to be respected by an APIType.
|
||||
type APITypeInterface interface {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package mojolicious
|
||||
|
||||
import (
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers/models"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/models"
|
||||
)
|
||||
|
||||
// GetName return the APITypeName of the APIType.
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"github.com/juju/errors"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers/models"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/models"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
@ -3,7 +3,7 @@ package dependencies
|
||||
import (
|
||||
"os/exec"
|
||||
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers/models"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/models"
|
||||
"github.com/juju/errors"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
"github.com/juju/errors"
|
||||
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers/models"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/models"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
@ -1,6 +1,6 @@
|
||||
package dependencies
|
||||
|
||||
import "git.home.m-and-m.ovh/mderasse/gouick/helpers/models"
|
||||
import "git.home.m-and-m.ovh/mderasse/gouick/models"
|
||||
|
||||
// DependencyInterface is the interface that need to be respected for a dependency.
|
||||
type DependencyInterface interface {
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers/models"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/models"
|
||||
"github.com/blang/semver"
|
||||
"github.com/juju/errors"
|
||||
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers/models"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/models"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
@ -1,71 +0,0 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/juju/errors"
|
||||
)
|
||||
|
||||
// APITypeName is a type used as an enum for possible API Type Name.
|
||||
type APITypeName string
|
||||
|
||||
//nolint:exported // keeping the enum simple and redeable.
|
||||
const (
|
||||
APITypeName_GIN_GONIC APITypeName = "Gin Gonic"
|
||||
APITypeName_GO_SWAGGER APITypeName = "Go Swagger"
|
||||
APITypeName_MOJOLICIOUS APITypeName = "Mojolicious"
|
||||
APITypeName_NULL APITypeName = ""
|
||||
)
|
||||
|
||||
// GetListOfAPITypeName returns a list of APITypeName.
|
||||
func GetListOfAPITypeName() []APITypeName {
|
||||
return []APITypeName{
|
||||
APITypeName_GIN_GONIC,
|
||||
APITypeName_GO_SWAGGER,
|
||||
APITypeName_MOJOLICIOUS,
|
||||
}
|
||||
}
|
||||
|
||||
// IsValid validates enum values.
|
||||
func (e APITypeName) IsValid() bool {
|
||||
for _, v := range GetListOfAPITypeName() {
|
||||
if e == v {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// NewAPITypeName return a APITypeName based on a given string.
|
||||
func NewAPITypeName(in string) (APITypeName, error) {
|
||||
out := APITypeName_NULL
|
||||
if in != "" {
|
||||
out = APITypeName(in)
|
||||
if !out.IsValid() {
|
||||
return APITypeName_NULL, errors.BadRequestf("Value %s invalid for enum APITypeName", in)
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// NewAPITypeNameFromInput will try to sluggify a given string and make it match with a APITypeName.
|
||||
func NewAPITypeNameFromInput(in string) (APITypeName, error) {
|
||||
in = strings.ToLower(in)
|
||||
in = strings.ReplaceAll(in, " ", "-")
|
||||
in = strings.ReplaceAll(in, "_", "-")
|
||||
|
||||
out := APITypeName_NULL
|
||||
if in != "" {
|
||||
for _, apiTypeName := range GetListOfAPITypeName() {
|
||||
apiTypeStr := strings.ToLower(string(apiTypeName))
|
||||
apiTypeStr = strings.ReplaceAll(apiTypeStr, " ", "-")
|
||||
apiTypeStr = strings.ReplaceAll(apiTypeStr, "_", "-")
|
||||
if in == apiTypeStr {
|
||||
return apiTypeName, nil
|
||||
}
|
||||
}
|
||||
return APITypeName_NULL, errors.BadRequestf("Value %s invalid for enum APITypeName", in)
|
||||
}
|
||||
return out, nil
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package models
|
||||
|
||||
// Config structure represent the main configuration of the project.
|
||||
type Config struct {
|
||||
ProjectName string `yaml:"project_name"`
|
||||
ProjectDescription string `yaml:"project_description"`
|
||||
ProjectOwner string `yaml:"project_owner"`
|
||||
ProjectType APITypeName `yaml:"project_type"`
|
||||
ModuleName *string `yaml:"module_name"`
|
||||
Features FeaturesConfig `yaml:"features"`
|
||||
}
|
||||
|
||||
// FeaturesConfig structure represent the configuration of all possible features.
|
||||
type FeaturesConfig struct {
|
||||
DatabaseModels DatabaseModelsConfig `yaml:"database_models"`
|
||||
}
|
||||
|
||||
// DatabaseModelsConfig structure represent the configuration of the Database Models feature.
|
||||
type DatabaseModelsConfig struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package models
|
||||
|
||||
// DependencyName is a type used as an enum for possible Dependency Name.
|
||||
type DependencyName string
|
||||
|
||||
//nolint:exported // keeping the enum simple and redeable.
|
||||
const (
|
||||
DependencyName_GIT DependencyName = "Git"
|
||||
DependencyName_GOLANG DependencyName = "Golang"
|
||||
DependencyName_GO_SWAGGER DependencyName = "Go Swagger"
|
||||
)
|
@ -1,11 +0,0 @@
|
||||
package models
|
||||
|
||||
// UserInputParams is a struct containing all fields that can be useful for project generation.
|
||||
type UserInputParams struct {
|
||||
DatabaseModels bool
|
||||
GoModuleName *string
|
||||
ProjectDescription string
|
||||
ProjectDirectory string
|
||||
ProjectName string
|
||||
ProjectOwner string
|
||||
}
|
Reference in New Issue
Block a user