Documentation
¶
Index ¶
- func VersionPath(documentPath string) string
- type AppConfig
- type ClientConfig
- func (c *ClientConfig) AddCycle(newCycleConfig *CycleConfig) error
- func (c *ClientConfig) GetCycle(cycleName string) (*CycleConfig, error)
- func (c *ClientConfig) GetCycleByID(appID, cycleID int64) (*CycleConfig, error)
- func (c *ClientConfig) IsSetupRequired() bool
- func (c *ClientConfig) Load() error
- func (c *ClientConfig) Save() error
- func (c *ClientConfig) String() string
- type CycleConfig
- type GlobalConfig
- type ServerConfig
- type Version
- type VersionMap
- func (vm *VersionMap) BundleVersion(cycleName string) string
- func (vm *VersionMap) CurrentVersion(cycle string) string
- func (vm *VersionMap) Load(documentPath string) error
- func (vm *VersionMap) Save(documentPath string) error
- func (vm *VersionMap) SetActiveCycle(cycleName string)
- func (vm *VersionMap) SetCurrentVersion(cycle, version string, isBundle bool) bool
- func (vm *VersionMap) Version(cycle string) *Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func VersionPath ¶
VersionPath returns the proper path for loading versions.warp
Types ¶
type ClientConfig ¶
type ClientConfig struct { ServerAddr string `json:"server_addr"` App AppConfig `json:"app"` Cycles []*CycleConfig `json:"cycles"` // contains filtered or unexported fields }
ClientConfig is being used in both cli and client bundle in mobile app
func NewClientConfigsForCli ¶
func NewClientConfigsForCli() *ClientConfig
NewClientConfigsForCli creates a config for cli
func NewClientConfigsForMobile ¶
func NewClientConfigsForMobile(bundlePath string) *ClientConfig
NewClientConfigsForMobile creates a client config for mobile
func (*ClientConfig) AddCycle ¶
func (c *ClientConfig) AddCycle(newCycleConfig *CycleConfig) error
AddCycle adds a new cycle into the list, prevent duplicates, order are also matter
func (*ClientConfig) GetCycle ¶
func (c *ClientConfig) GetCycle(cycleName string) (*CycleConfig, error)
GetCycle gets config based on app's and cycle's names.
func (*ClientConfig) GetCycleByID ¶
func (c *ClientConfig) GetCycleByID(appID, cycleID int64) (*CycleConfig, error)
GetCycleByID is being used in warpify to found cycle info which contains public key
func (*ClientConfig) IsSetupRequired ¶
func (c *ClientConfig) IsSetupRequired() bool
IsSetupRequired will let us know whether the config is empty or not
func (*ClientConfig) Load ¶
func (c *ClientConfig) Load() error
Load the config from file name with the given path
func (*ClientConfig) Save ¶
func (c *ClientConfig) Save() error
Save config into a file in given path
func (*ClientConfig) String ¶
func (c *ClientConfig) String() string
type CycleConfig ¶
CycleConfig data represents each cycle in config
func (*CycleConfig) String ¶
func (c *CycleConfig) String() string
type GlobalConfig ¶
type GlobalConfig struct { // Sessions the key is the server url and the value of this key is jwt token // for authenticate to that server Sessions map[string]string `json:"sessions"` }
GlobalConfig store basic information about warpdrive
func NewGlobalConfig ¶
func NewGlobalConfig() *GlobalConfig
NewGlobalConfig creates and load the global config
func (*GlobalConfig) GetSessionFor ¶
func (g *GlobalConfig) GetSessionFor(serverAddr string) (string, error)
func (*GlobalConfig) Load ¶
func (g *GlobalConfig) Load() error
func (*GlobalConfig) Save ¶
func (g *GlobalConfig) Save() error
func (*GlobalConfig) SetSessionFor ¶
func (g *GlobalConfig) SetSessionFor(serverAddr, session string)
type ServerConfig ¶
type ServerConfig struct { // [server] Server struct { Addr string `toml:"addr"` DataDir string `toml:"data_dir"` BundlesFolder string TempFolder string } `toml:"server"` // [jwt] JWT struct { SecretKey string `toml:"secret_key"` MaxAge int `toml:"max_age"` Path string `toml:"path"` Domain string `toml:"domain"` Secure bool `toml:"secure"` } `toml:"jwt"` // [db] DB struct { Database string `toml:"database"` Hosts string `toml:"hosts"` Username string `toml:"username"` Password string `toml:"password"` } `toml:"db"` // [security] Security struct { KeySize int `toml:"key_size"` } `toml:"security"` // [file_upload] FileUpload struct { FileMaxSize int64 `toml:"file_max_size"` } `toml:"file_upload"` }
ServerConfig the configuration of warpdrive app
func NewConfig ¶
func NewConfig(filename string) (*ServerConfig, error)
NewConfig reads the config file and instanciated to global conf. you only need to call this one once. use it in your main app
type Version ¶
type Version struct { Current string `json:"current"` Available map[string]bool `json:"available"` }
Version is simple structure which holds information about which cycle uses which version
func (*Version) SetCurrent ¶
SetCurrent sets a version as current for Cycle, you have an option to add it to cache. The reason you might not to set it to cache is anything added to cache means download from warpdrive server
func (*Version) SortAvailable ¶
SortAvailable sort caches, it helps simplify the caller
type VersionMap ¶
type VersionMap struct { ActiveCycle string `json:"active_cycle"` Cycles map[string]*Version `json:"cycles"` }
VersionMap is a simple structure wrapping Version it provides basic structure to find and manipulate each version in an easy way
func NewVersionMapFromReader ¶
func NewVersionMapFromReader(r io.Reader) (*VersionMap, error)
NewVersionMapFromReader creates VersionMap from io.Reader added this function to simplify the creation of versionMap
func (*VersionMap) BundleVersion ¶
func (vm *VersionMap) BundleVersion(cycleName string) string
BundleVersion is a helper to return version belongs to bundle this is useful during check whther bundle version has changed due to new update in app store or play store
func (*VersionMap) CurrentVersion ¶
func (vm *VersionMap) CurrentVersion(cycle string) string
CurrentVersion returns the current version sets in given cycle
func (*VersionMap) Load ¶
func (vm *VersionMap) Load(documentPath string) error
Load loads the Cycles of VersionMap from target path. Path must ends with filename and must be `versions.warp`
func (*VersionMap) Save ¶
func (vm *VersionMap) Save(documentPath string) error
Save saves the VersionMap to target path. Path must ends with filename and must be `versions.warp`
func (*VersionMap) SetActiveCycle ¶
func (vm *VersionMap) SetActiveCycle(cycleName string)
SetActiveCycle set the ActiveCycle to load the value during bootup
func (*VersionMap) SetCurrentVersion ¶
func (vm *VersionMap) SetCurrentVersion(cycle, version string, isBundle bool) bool
SetCurrentVersion assing a new version to cycle. You can add it to cache as well returns whether the add version is in bundle or document folder we need this if for some reason, user rollback to original deployed bundle
func (*VersionMap) Version ¶
func (vm *VersionMap) Version(cycle string) *Version
Version gets a verion struct based on cycle name. if the cycle does not exist, it will create a new one, assign it to map and return the value most of the logic here is for making it easier for caller.