From bf7ebf27588f597a6878cdb69973a380ef693bf2 Mon Sep 17 00:00:00 2001 From: Dustin Black Date: Wed, 19 Jun 2024 19:15:39 +0200 Subject: [PATCH 1/6] change method of setting config defaults --- cmd/arcaflow/main.go | 22 ++++------------------ config/schema.go | 2 +- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/cmd/arcaflow/main.go b/cmd/arcaflow/main.go index 66f8533b..3905321a 100644 --- a/cmd/arcaflow/main.go +++ b/cmd/arcaflow/main.go @@ -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 := "." @@ -133,12 +121,7 @@ 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 len(configFile) > 0 { configFilePath, err := fileCtx.AbsPathByKey(RequiredFileKeyConfig) if err != nil { tempLogger.Errorf("Unable to find configuration file %s (%v)", configFile, err) @@ -152,6 +135,9 @@ logged_outputs: flag.Usage() 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) } cfg, err := config.Load(configData) diff --git a/config/schema.go b/config/schema.go index 9bd216e5..25ff6eea 100644 --- a/config/schema.go +++ b/config/schema.go @@ -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( From 7c90f7ad868477156e7fac9d9ee120828655696a Mon Sep 17 00:00:00 2001 From: Dustin Black Date: Wed, 19 Jun 2024 19:27:57 +0200 Subject: [PATCH 2/6] update engine test to use podman --- engine_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/engine_test.go b/engine_test.go index 50f524a0..9f167ac0 100644 --- a/engine_test.go +++ b/engine_test.go @@ -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" @@ -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", }, From bf73a03019133873bd6cbca953a2753c5266fd9b Mon Sep 17 00:00:00 2001 From: Dustin Black Date: Wed, 19 Jun 2024 19:29:25 +0200 Subject: [PATCH 3/6] update load test to podman --- config/load_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/config/load_test.go b/config/load_test.go index daabe002..a815da7e 100644 --- a/config/load_test.go +++ b/config/load_test.go @@ -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" @@ -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, @@ -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, @@ -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, From 7046dd9e611e26c6b285e976d0f2d1d4cc2ecc23 Mon Sep 17 00:00:00 2001 From: Dustin Black Date: Wed, 19 Jun 2024 19:42:08 +0200 Subject: [PATCH 4/6] test go lint and test w/ podman added --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 412c0d93..ccf21365 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -9,7 +9,7 @@ on: jobs: lint_and_test: name: lint and test - uses: arcalot/arcaflow-reusable-workflows/.github/workflows/go_lint_and_test.yaml@main + uses: arcalot/arcaflow-reusable-workflows/.github/workflows/go_lint_and_test.yaml@add-podman with: go_version: ${{ vars.ARCALOT_GO_VERSION }} generate: From fb23b03c4cfd27c9213b61dd0c6bc71711ae1692 Mon Sep 17 00:00:00 2001 From: Dustin Black Date: Wed, 19 Jun 2024 19:48:48 +0200 Subject: [PATCH 5/6] revert lint and test to action main branch --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ccf21365..412c0d93 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -9,7 +9,7 @@ on: jobs: lint_and_test: name: lint and test - uses: arcalot/arcaflow-reusable-workflows/.github/workflows/go_lint_and_test.yaml@add-podman + uses: arcalot/arcaflow-reusable-workflows/.github/workflows/go_lint_and_test.yaml@main with: go_version: ${{ vars.ARCALOT_GO_VERSION }} generate: From ac6e415e8f19743ea93d9490150ad042cd28fa32 Mon Sep 17 00:00:00 2001 From: Dustin Black Date: Thu, 20 Jun 2024 14:43:01 +0200 Subject: [PATCH 6/6] simplify if condition --- cmd/arcaflow/main.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cmd/arcaflow/main.go b/cmd/arcaflow/main.go index 3905321a..7ec17213 100644 --- a/cmd/arcaflow/main.go +++ b/cmd/arcaflow/main.go @@ -121,6 +121,8 @@ func main() { } var configData any + // 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 { @@ -135,9 +137,6 @@ func main() { flag.Usage() 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) } cfg, err := config.Load(configData)