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:
jon brookes 2025-07-09 13:19:43 +01:00 committed by jon brookes
parent bd7cee720a
commit 924954d0ff
49 changed files with 2059 additions and 101 deletions

71
main.go Normal file
View file

@ -0,0 +1,71 @@
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package main
import (
"fmt"
"log"
"log/slog"
"os"
"headshed/infctl-cli/app"
"headshed/infctl-cli/config"
)
func main() {
var levelVar slog.LevelVar
levelVar.Set(slog.LevelDebug)
logger := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: &levelVar}))
slog.SetDefault(logger)
if err := run(); err != nil {
log.Fatalf("Application error: %v", err)
}
}
func run() error {
wd, err := os.Getwd()
if err != nil {
return fmt.Errorf("failed to get current directory: %w", err)
}
baseConfigPath := wd + string(os.PathSeparator) + "base.json"
configPath := wd + string(os.PathSeparator) + "config.json"
baseConfig, err := config.ReadBaseConfig(baseConfigPath)
if err != nil {
return fmt.Errorf("error reading base config file: %w", err)
}
customerConfig, err := config.ReadCustomerConfig(configPath)
if err != nil {
return fmt.Errorf("error reading customer config file: %w", err)
}
appState, err := app.NewAppState(customerConfig, baseConfig, "app.db")
if err != nil {
return fmt.Errorf("failed to initialize app state: %w", err)
}
defer func() {
if err := appState.DB.Close(); err != nil {
log.Printf("Error closing database: %v", err)
}
}()
if err := appState.CreatePipeline(); err != nil {
return fmt.Errorf("failed to create customer project: %w", err)
}
return nil
}