changed app to use json config for pipeline steps
readme command line usage - to specify pipeline file name readme updated to include reasoning behind the project use native golang sqlite RunScriptCommand named in functionMap removed unused functions removed unused functions run script and pipeline example renamed functions to drop the word script and add pipeline verb
This commit is contained in:
parent
bd7cee720a
commit
924954d0ff
49 changed files with 2059 additions and 101 deletions
63
config/base.go
Normal file
63
config/base.go
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
type BaseConfig struct {
|
||||
ProjectsDirectory string `json:"projects_directory"`
|
||||
Env string `json:"env"`
|
||||
StaticImages string `json:"static_images"`
|
||||
PublicImages string `json:"public_images"`
|
||||
PhpConf string `json:"php_conf"`
|
||||
Exports string `json:"exports"`
|
||||
Logs string `json:"logs"`
|
||||
PreviewPath string `json:"preview_path"`
|
||||
DataWww string `json:"data_www"`
|
||||
NginxConf string `json:"nginx_conf"`
|
||||
AdminURL string `json:"admin_url"`
|
||||
PreviewURL string `json:"preview_url"`
|
||||
AppImage string `json:"app_image"`
|
||||
WebserverImage string `json:"webserver_image"`
|
||||
EmptyDB string `json:"empty_db"`
|
||||
DB string `json:"db"`
|
||||
EmptyImages string `json:"empty_imaages"`
|
||||
DeploymentType string `json:"deployment_type"`
|
||||
DeploymentFile string `json:"deployment_file"`
|
||||
Port int `json:"port"`
|
||||
}
|
||||
|
||||
func ReadBaseConfig(path string) (BaseConfig, error) {
|
||||
|
||||
deploymentType := os.Getenv("DEPLOYMENT_TYPE")
|
||||
|
||||
deploymentFile := flag.String("deployment-file", "", "path to config file")
|
||||
helpFlag := flag.Bool("help", false, "show help")
|
||||
flag.Parse()
|
||||
|
||||
if *helpFlag {
|
||||
fmt.Println("Usage: infctl-cli --deployment-file=<path_to_config_file>")
|
||||
fmt.Println("DEPLOYMENT_TYPE environment variable must be set to 'json' or 'api (api is not implemented yet)'")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
var config BaseConfig
|
||||
if *deploymentFile != "" {
|
||||
config.DeploymentFile = *deploymentFile
|
||||
}
|
||||
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return BaseConfig{}, fmt.Errorf("failed to read file: %w", err)
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(data, &config); err != nil {
|
||||
return BaseConfig{}, fmt.Errorf("failed to unmarshal JSON: %w", err)
|
||||
}
|
||||
config.DeploymentType = deploymentType
|
||||
|
||||
return config, nil
|
||||
}
|
||||
29
config/customer.go
Normal file
29
config/customer.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
type CustomerConfig struct {
|
||||
Project string `json:"project"`
|
||||
CustomerDirectory string `json:"customer_directory"`
|
||||
UIURL string `json:"ui_url"`
|
||||
StaticURL string `json:"static_url"`
|
||||
Port int `json:"port"`
|
||||
}
|
||||
|
||||
func ReadCustomerConfig(path string) (CustomerConfig, error) {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return CustomerConfig{}, fmt.Errorf("failed to read file: %w", err)
|
||||
}
|
||||
|
||||
var cust CustomerConfig
|
||||
if err := json.Unmarshal(data, &cust); err != nil {
|
||||
return CustomerConfig{}, fmt.Errorf("failed to unmarshal JSON: %w", err)
|
||||
}
|
||||
|
||||
return cust, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue