Jobs & Workflows https://armen.surge.sh
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

64 lines
1.5 KiB

/*
------------------------------------------------------------------------------------------------------------------------
####### data ####### Copyright (c) 2021 mls-361 #################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package data
import (
"encoding/json"
"fmt"
"forge.chapril.org/mls-361/errors"
)
// Data AFAIRE.
type Data struct {
Logger *Logger
Server *Server
Storage *Storage
}
// Validate AFAIRE.
func (d *Data) Validate() error {
if d.Logger == nil {
d.Logger = new(Logger)
}
if err := d.Logger.validate(); err != nil {
return errors.WithMessage(err, "logger") ///////////////////////////////////////////////////////////////////////
}
if d.Server == nil {
d.Server = new(Server)
}
if err := d.Server.validate(); err != nil {
return errors.WithMessage(err, "server") ///////////////////////////////////////////////////////////////////////
}
if d.Storage == nil {
d.Storage = new(Storage)
}
if err := d.Storage.validate(); err != nil {
return errors.WithMessage(err, "storage") //////////////////////////////////////////////////////////////////////
}
return nil
}
// String AFAIRE.
func (d *Data) String() string {
data, err := json.Marshal(d)
if err != nil {
return fmt.Sprintf(`{"ERROR":"%s"}`, err)
}
return string(data)
}
/*
######################################################################################################## @(°_°)@ #######
*/