Skip to content

Commit

Permalink
change method of setting config defaults (#192)
Browse files Browse the repository at this point in the history
* change method of setting config defaults

* update engine test to use podman

* update load test to podman

* test go lint and test w/ podman added

* revert lint and test to action main branch

* simplify if condition
  • Loading branch information
dustinblack authored Jun 21, 2024
1 parent d1e42bc commit d8af555
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 25 deletions.
21 changes: 3 additions & 18 deletions cmd/arcaflow/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,6 @@ func main() {
Stdout: os.Stderr,
})

defaultConfig := `
log:
level: info
deployers:
image:
deployer_name: podman
deployment:
imagePullPolicy: IfNotPresent
logged_outputs:
error:
level: info`

configFile := ""
input := ""
dir := "."
Expand Down Expand Up @@ -133,12 +121,9 @@ logged_outputs:
}

var configData any
if len(configFile) == 0 {
if err := yaml.Unmarshal([]byte(defaultConfig), &configData); err != nil {
tempLogger.Errorf("Failed to load default configuration", err)
os.Exit(ExitCodeInvalidData)
}
} else {
// If no config file is passed, we use an empty map to accept the schema defaults
configData = make(map[string]any)
if len(configFile) > 0 {
configFilePath, err := fileCtx.AbsPathByKey(RequiredFileKeyConfig)
if err != nil {
tempLogger.Errorf("Unable to find configuration file %s (%v)", configFile, err)
Expand Down
9 changes: 5 additions & 4 deletions config/load_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package config_test

import (
"go.arcalot.io/log/v2"
"testing"

"go.arcalot.io/log/v2"

"go.arcalot.io/lang"
"go.flow.arcalot.io/engine/config"
"gopkg.in/yaml.v3"
Expand All @@ -19,7 +20,7 @@ var configLoadData = map[string]struct {
expectedOutput: &config.Config{
TypeHintPlugins: nil,
LocalDeployers: map[string]any{
"image": map[string]string{"deployer_name": "docker"},
"image": map[string]string{"deployer_name": "podman"},
},
Log: log.Config{
Level: log.LevelInfo,
Expand All @@ -35,7 +36,7 @@ log:
expectedOutput: &config.Config{
TypeHintPlugins: nil,
LocalDeployers: map[string]any{
"image": map[string]string{"deployer_name": "docker"},
"image": map[string]string{"deployer_name": "podman"},
},
Log: log.Config{
Level: log.LevelDebug,
Expand Down Expand Up @@ -70,7 +71,7 @@ plugins:
"quay.io/arcalot/example-plugin:latest",
},
LocalDeployers: map[string]any{
"image": map[string]string{"deployer_name": "docker"},
"image": map[string]string{"deployer_name": "podman"},
},
Log: log.Config{
Level: log.LevelInfo,
Expand Down
2 changes: 1 addition & 1 deletion config/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func getConfigSchema() *schema.TypedScopeSchema[*Config] {
nil,
nil,
nil,
schema.PointerTo(`{"image": {"deployer_name": "docker"}}`),
schema.PointerTo(`{"image": {"deployer_name": "podman"}}`),
nil,
),
"logged_outputs": schema.NewPropertySchema(
Expand Down
5 changes: 3 additions & 2 deletions engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package engine_test
import (
"context"
"errors"
"go.flow.arcalot.io/engine/loadfile"
"testing"

"go.flow.arcalot.io/engine/loadfile"

log "go.arcalot.io/log/v2"
"go.flow.arcalot.io/engine"
"go.flow.arcalot.io/engine/workflow"
Expand All @@ -29,7 +30,7 @@ func createTestEngine(t *testing.T) engine.WorkflowEngine {
cfg.Log.Level = log.LevelDebug
cfg.Log.Destination = log.DestinationTest
cfg.LocalDeployers["image"] = map[string]any{
"deployer_name": "docker",
"deployer_name": "podman",
"deployment": map[string]any{
"imagePullPolicy": "IfNotPresent",
},
Expand Down

0 comments on commit d8af555

Please sign in to comment.