Documentation ¶
Index ¶
- func ExecuteGoTools(fileName string) error
- type ColType
- type Config
- func (cfg *Config) GenerateAppConf(dstDir string) (fName string, err error)
- func (cfg *Config) GenerateSampleConfig(dstDir string) error
- func (cfg *Config) GenerateSampleDockerConfig(dstDir string) error
- func (cfg Config) GetIsProd() bool
- func (cfg Config) IsLastServiceActivationRec(name string) bool
- type DBConfig
- type Entity
- func (ent *Entity) BuildTestPostJSON(isUpdate bool) string
- func (ent *Entity) CreateControllerExtensionPointsFile(tDir string) (fName string, err error)
- func (ent *Entity) CreateControllerFile(tDir string) (fName string, err error)
- func (ent *Entity) CreateControllerRelationsFile(tDir string, entities []Entity) (fName string, err error)
- func (ent *Entity) CreateModelExtensionPointsFile(tDir string) (fName string, err error)
- func (ent *Entity) CreateModelFile(tDir string) (fName string, err error)
- func (ent *Entity) GetDateTimeStamp() string
- func (ent *Entity) GetHasStart() bool
- func (ent *Entity) GetLowerCasePrefixLetter() string
- type Info
- func (i *Info) BuildTestValidationExpression(isUpdate bool) string
- func (i *Info) GetHasEQOp() bool
- func (i *Info) GetHasGEOp() bool
- func (i *Info) GetHasGTOp() bool
- func (i *Info) GetHasLEOp() bool
- func (i *Info) GetHasLIKEOp() bool
- func (i *Info) GetHasLTOp() bool
- func (i *Info) GetHasNEOp() bool
- func (i *Info) GetJSONTagLine() string
- func (i *Info) GetPtrIfNullable() string
- func (i *Info) GetQueryComponentFuncCall() string
- func (i *Info) GetQueryOps() []string
- func (i *Info) GetSelBoolRegex() string
- func (i *Info) GetSelNumberRegex() string
- func (i *Info) GetSelStringRegex() string
- func (i *Info) GetSqacTagLine(b bool) string
- func (i *Info) IsBoolFieldType() bool
- func (i *Info) IsFloatFieldType() bool
- func (i *Info) IsIntFieldType() bool
- func (i *Info) IsNumberFieldType() bool
- func (i *Info) IsStringFieldType() bool
- func (i *Info) IsUIntFieldType() bool
- type KeyConfig
- type Relation
- func (r *Relation) GetAreFromAndToKeysOpt(fromEntKeyName, toEntKeyName string, fromInfo, toInfo []Info) bool
- func (r *Relation) GetAreFromAndToKeysReq(fromEntKeyName, toEntKeyName string, fromInfo, toInfo []Info) bool
- func (r *Relation) GetBelongsTo() bool
- func (r *Relation) GetHasMany() bool
- func (r *Relation) GetHasOne() bool
- func (r *Relation) GetIsFromKeyOptAndToKeyReq(fromEntKeyName, toEntKeyName string, fromInfo, toInfo []Info) bool
- func (r *Relation) GetIsFromKeyReqAndToKeyOpt(fromEntKeyName, toEntKeyName string, fromInfo, toInfo []Info) bool
- type ServiceActivation
- type Static
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteGoTools ¶
ExecuteGoTools runs gofmt -w and goimports on the specified file
Types ¶
type Config ¶
type Config struct { ExternalAddress string `json:"external_address"` InternalAddress string `json:"internal_address"` Env string `json:"env"` PingCycle uint `json:"ping_cycle"` FailureThreshold uint64 `json:"failure_threshold"` Pepper string `json:"pepper"` HMACKey string `json:"hmac_key"` Database DBConfig `json:"database"` CertFile string `json:"cert_file"` KeyFile string `json:"key_file"` RSA256PrivKeyFile string `json:"rsa256_priv_key_file"` RSA256PubKeyFile string `json:"rsa256_pub_key_file"` RSA384PrivKeyFile string `json:"rsa384_priv_key_file"` RSA384PubKeyFile string `json:"rsa384_pub_key_file"` RSA512PrivKeyFile string `json:"rsa512_priv_key_file"` RSA512PubKeyFile string `json:"rsa512_pub_key_file"` ECDSA256PrivKeyFile string `json:"ecdsa256_priv_key_file"` ECDSA256PubKeyFile string `json:"ecdsa256_pub_key_file"` ECDSA384PrivKeyFile string `json:"ecdsa384_priv_key_file"` ECDSA384PubKeyFile string `json:"ecdsa384_pub_key_file"` ECDSA521PrivKeyFile string `json:"ecdsa521_priv_key_file"` ECDSA521PubKeyFile string `json:"ecdsa521_pub_key_file"` JWTSignMethod string `json:"jwt_sign_method"` // {EC256|EC384|EC521|RS256|RS384|RS312} JWTLifetime uint `json:"jwt_lifetime"` // minutes // JWTPrivKeyFile string `json:"jwt_priv_key_file"` // JWTPubKeyFile string `json:"jwt_pub_key_file"` ServiceActivations []ServiceActivation `json:"service_activations"` }
Config type holds the generated application's configuration info
func (*Config) GenerateAppConf ¶
GenerateAppConf generates the default application configuration source file appconf.go.
func (*Config) GenerateSampleConfig ¶
GenerateSampleConfig creates a sample .config.json file to hold the production application config.
func (*Config) GenerateSampleDockerConfig ¶
GenerateSampleDockerConfig creates a sample .config.json file to hold the production application config.
func (Config) GetIsProd ¶
GetIsProd returns a bool value indicating to the calling template that the cfg struct is holding production configuration.
func (Config) IsLastServiceActivationRec ¶
IsLastServiceActivationRec is used to determine whether the config.json.gotmpl has processed the last ServiceActivation while building the .dec / .prd config files.
type DBConfig ¶
type DBConfig struct { DBDialect string `json:"db_dialect"` Host string `json:"host"` Port int `json:"port"` Usr string `json:"Usr"` Password string `json:"Password"` Name string `json:"name"` }
DBConfig type holds db config info
func (DBConfig) ConnectionInfo ¶
ConnectionInfo returns a DBConfig string
type Entity ¶
type Entity struct { Header Info Fields []Info Relations []Relation // CompositeIndexes []string // AppPath string }
Entity definition
func ReadModelFile ¶
ReadModelFile reads a model file
func (*Entity) BuildTestPostJSON ¶
BuildTestPostJSON constructs a basic JSON message body based on the definition of the Entity passed in from the template. The intent is to create a body which can be edited by the developer in order to add more meaningful data.
- string types will be assigned: "string_value"
- float64 type will be assigned an incrementing float value starting at 9.91
- int types will be assigned an incrementing int value starting at 10.
- uint types will be assigned an incrementing uint value starting at 10.
`{"name":"test_product",
"height":55.5, "cost":66.6, "supplier":"Ace Hardware", "weight":88.8, "length":44.4, "width":33.3, "name":"TEST_PRODUCT", "description":"a nice test product", "uom":"EA"}`
func (*Entity) CreateControllerExtensionPointsFile ¶
CreateControllerExtensionPointsFile generates a controller extension- point implementation file for the Entity if the 'gen_controller' element is set to true in the user-defined model.json file. Returns the fully-qualified file-name / error.
func (*Entity) CreateControllerFile ¶
CreateControllerFile generates a controller file for the Entity using the user-defined model.json file in conjunction with the controller.gotmpl text/template. Returns the fully-qualified file-name / error.
func (*Entity) CreateControllerRelationsFile ¶
func (ent *Entity) CreateControllerRelationsFile(tDir string, entities []Entity) (fName string, err error)
CreateControllerRelationsFile generates a controller file for the Entity relations using the user-defined model.json file in conjunction with the controller_relationships.gotmpl text/template. The complete set of Entities is passed into the method in order to facilitate the validation of the ToEntity field used in the foreign-key definition. Returns the fully-qualified file-name / error.
func (*Entity) CreateModelExtensionPointsFile ¶
CreateModelExtensionPointsFile generates a model extension-point implementation file for the Entity if the 'gen_controller' element is set to true in the user-defined model.json file. Returns the fully-qualified file-name / error.
func (*Entity) CreateModelFile ¶
CreateModelFile generates a model file for the Entity using the user-defined model.json file in conjunction with the model.gotmpl text/template. Returns the fully-qualified file-name / error. pkger is used to bundle the .gotmpl files into the binary. Pkger implements the File interface, so the file handling is a little more pedantic than it would be with ioutil.
func (*Entity) GetDateTimeStamp ¶
GetDateTimeStamp returns a stringified date-time in RFC822 format for use in template execution. Called from within a text/template.
func (*Entity) GetHasStart ¶
GetHasStart returns a bool indicating whether or not an entity has been provided with a start-value for its id in the model file.
func (*Entity) GetLowerCasePrefixLetter ¶
GetLowerCasePrefixLetter is a method that will be called from within the templates to return the first letter of the lower-case name of the entity. used for the model -> service vars. defaults to "e" for entity, but this should never occur. Called from within a text/template.
type Info ¶
type Info struct { Name string // field name from model Value string // type // LowerCaseName string // field name in lower-case for query path - possibly deprecated SnakeCaseName string // field name in sqac database format (snake_case) DBType string IsKey bool Start uint64 Format string NoDB bool // true = no persistence on the db Required bool Unique bool Index string // unique, not-unique, "" Selectable string // "eq,like,gt,lt,ge,le,ne" DefaultValue string // DefaultFunc string // "now; bot; eot etc." RefEntity string // foreign-key reference entity for field RefField string // foreign-key reference field SqacTagLine string JSONTagLine string // `json:"field_name,omitempty"` GenControllerExt bool GenValidatorExt bool GenModelExt bool }
Info is used to hold name-value-pairs for Entity definitions
func (*Info) BuildTestValidationExpression ¶
BuildTestValidationExpression is used to build a starter-validation statement for each entity's Create / Update tests in main_test.go.
func (*Info) GetHasEQOp ¶
GetHasEQOp checks to see if an Entity field has been configured for simple-selection via the use of the 'EQ' operator.
func (*Info) GetHasGEOp ¶
GetHasGEOp checks to see if an Entity field has been configured for simple-selection via the use of the 'GE' operator.
func (*Info) GetHasGTOp ¶
GetHasGTOp checks to see if an Entity field has been configured for simple-selection via the use of the 'GT' operator.
func (*Info) GetHasLEOp ¶
GetHasLEOp checks to see if an Entity field has been configured for simple-selection via the use of the 'LE' operator.
func (*Info) GetHasLIKEOp ¶
GetHasLIKEOp checks to see if an Entity field has been configured for simple-selection via the use of the 'LIKE' operator.
func (*Info) GetHasLTOp ¶
GetHasLTOp checks to see if an Entity field has been configured for simple-selection via the use of the 'LT' operator.
func (*Info) GetHasNEOp ¶
GetHasNEOp checks to see if an Entity field has been configured for simple-selection via the use of the 'NE' operator.
func (*Info) GetJSONTagLine ¶
GetJSONTagLine returns a string containing the json tag directives for the column. Called from within readmodel.go/ReadModelFile()
func (*Info) GetPtrIfNullable ¶
GetPtrIfNullable is used to provide a pointer-glyph (*) to the calling template as a preface to nullable model structure members. Called from within a text/template.
func (*Info) GetQueryComponentFuncCall ¶
GetQueryComponentFuncCall is used to determine the function to call in order to separate simple query strings into an operator and predicate value of the appropriate type. Called from within a text/template.
func (*Info) GetQueryOps ¶
GetQueryOps is used to obtain a slice of the required simple query operators for the entity controller template. Acceptable types are 'EQ','LT','LE','GT','GE','LIKE'. Called from within a text/template.
func (*Info) GetSelBoolRegex ¶
GetSelBoolRegex examines the Selectable field and generates a GET-type gorilla mux route regex based on the requested (and supported) operators for the bool type.
func (*Info) GetSelNumberRegex ¶
GetSelNumberRegex examines the Selectable field and generates a GET-type gorilla mux route regex based on the requested (and supported) operators for the numeric type (uint, int, float).
func (*Info) GetSelStringRegex ¶
GetSelStringRegex examines the Selectable field and generates a GET-type gorilla mux route regex based on the requested (and supported) operators.
func (*Info) GetSqacTagLine ¶
GetSqacTagLine returns a string containing a set of sqac directives for the column attributes. Called from within readmodel.go/ReadModelFile()
func (*Info) IsBoolFieldType ¶
IsBoolFieldType is used in the text/templates to determine whether an Info.Value is of type "bool", or other. Called from within a text/template.
func (*Info) IsFloatFieldType ¶
IsFloatFieldType is used to determine whether an Info record has a float-type. Called internally via Info.IsNumberFieldType.
func (*Info) IsIntFieldType ¶
IsIntFieldType is used to determine whether an Info record has an int-type. Called internally via Info.IsNumberFieldType.
func (*Info) IsNumberFieldType ¶
IsNumberFieldType is used in the text/templates to determine whether an Info.Value is of type uint*, int* or float*. Called from within a text/template.
func (*Info) IsStringFieldType ¶
IsStringFieldType is used in the text/templates to determine whether an Info.Value is of type "string", or other. Called from within a text/template.
func (*Info) IsUIntFieldType ¶
IsUIntFieldType is used to determine whether an Info record has a uint-type. Called internally via Info.IsNumberFieldType.
type KeyConfig ¶
type KeyConfig struct { RSABits uint // 0 // ECDSACurve string // "P256" || "P384" || "P521" // deprecated ECDSA []string // {"256", "384", "521"} RSA []string // {"256", "384", "512"}, TargetDir string // target directory to write keys to }
KeyConfig holds the basic certificate configuration
func (*KeyConfig) GenerateJWTKeys ¶
GenerateJWTKeys creates some ECDSA and RSA keys
type Relation ¶
type Relation struct { RelName string // "ToStreetAddress" || "StreetAddress" for example RelNameLC string // "tostreetaddress" || "streetaddress" for example - used in mux route RefKey string // "ID" - default key name in FromEntity RefKeyOptional bool // true/false RelType string // "hasOne; belongsTo; hasMany" FromEntity string // "Person" FromEntityLC string // "person" ToEntity string // "StreetAddress" ToEntityLC string // "streetaddress" ToEntInfo []Info // ToEntity-field-meta-data ForeignPK string // "<FromEntity>ID" ForeignPKOptional bool // true/false }
Relation definition
func (*Relation) GetAreFromAndToKeysOpt ¶
func (r *Relation) GetAreFromAndToKeysOpt(fromEntKeyName, toEntKeyName string, fromInfo, toInfo []Info) bool
GetAreFromAndToKeysOpt returns true if the fromEntKey and toEntKey are both defined as optional. Called from within the controller_relations text/template.
func (*Relation) GetAreFromAndToKeysReq ¶
func (r *Relation) GetAreFromAndToKeysReq(fromEntKeyName, toEntKeyName string, fromInfo, toInfo []Info) bool
GetAreFromAndToKeysReq returns true if the fromEntKey and toEntKey are both defined as required. Called from within the controller_relations text/template.
func (*Relation) GetBelongsTo ¶
GetBelongsTo is used to provide a boolean response indicating whether the relation is of relType 'belongsTo'. Called from within the controller_relations text/template.
func (*Relation) GetHasMany ¶
GetHasMany is used to provide a boolean response indicating whether the relation is of relType 'hasMany'. Called from within the controller_relations text/template.
func (*Relation) GetHasOne ¶
GetHasOne is used to provide a boolean response indicating whether the relation is of relType 'hasOne'. Called from within the controller_relations text/template.
func (*Relation) GetIsFromKeyOptAndToKeyReq ¶
func (r *Relation) GetIsFromKeyOptAndToKeyReq(fromEntKeyName, toEntKeyName string, fromInfo, toInfo []Info) bool
GetIsFromKeyOptAndToKeyReq returns true if the fromEntKey has been defined as optional, the the toEntKey has been defined as required. Called from within the controller_relations text/template.
func (*Relation) GetIsFromKeyReqAndToKeyOpt ¶
func (r *Relation) GetIsFromKeyReqAndToKeyOpt(fromEntKeyName, toEntKeyName string, fromInfo, toInfo []Info) bool
GetIsFromKeyReqAndToKeyOpt returns true if the fromEntKey has been defined as required, the the toEntKey has been defined as optional. Called from within the controller_relations text/template.
type ServiceActivation ¶
type ServiceActivation struct { ServiceName string `json:"service_name"` ServiceActive bool `json:"service_active"` }
ServiceActivation struct
type Static ¶
type Static struct { SrcDir string DstDir string AppPath string Entities []Entity ECDSA []string RSA []string }
Static definition
func (*Static) GenerateGoMod ¶
func (*Static) GenerateStaticTemplates ¶
============================================================================================= static generation functions ============================================================================================= GenerateStaticTemplates reads the ./static folder and uses Glob to execute each template in-turn. Returns the fully-qualified file-names or an error. Processes .gotmpl files into .go files.
func (*Static) GetAddrConcatenatedEntities ¶
GetAddrConcatenatedEntities returns a string of concatenated entity addresses in the form of "&Entity1{}, &Entity2{}, &Entity3{}". this is useful for AutoMigrate and DestructiveReset purposes. Called from within a text/template.
func (*Static) GetConcatenatedEntities ¶
GetConcatenatedEntities returns a string of concatenated entities in the form of "Entity1{}, Entity2{}, Entityn{}...". this is useful for AutoMigrate and DestructiveReset purposes. Called from within a text/template.
func (*Static) GetDateTimeStamp ¶
GetDateTimeStamp returns a stringified date-time in RFC822 format for use in template execution. Called from within a text/template.