From f729a21a497ca3326ec0d361c21e863078311a9f Mon Sep 17 00:00:00 2001 From: Alexey Potapenko Date: Mon, 30 Dec 2024 14:34:50 +0300 Subject: [PATCH] skip config loading and script searching --- cli/running/running.go | 28 ++++++++++++++++------------ cli/running/running_test.go | 12 ++++++------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/cli/running/running.go b/cli/running/running.go index 5cca02fe2..9a468dfd8 100644 --- a/cli/running/running.go +++ b/cli/running/running.go @@ -409,19 +409,23 @@ func collectInstancesFromAppDir(appDir string, selectedInstName string, } log.Debugf("Instance %q", instance.InstName) - instance.Configuration, err = loadInstanceConfig(instance.ClusterConfigPath, - instance.InstName, integrityCtx) - if err != nil && !skipClusterConfig { - return instances, fmt.Errorf("error loading instance %q configuration from "+ - "config %q: %w", instance.InstName, instance.ClusterConfigPath, err) - } + if !skipClusterConfig { + instance.Configuration, err = loadInstanceConfig(instance.ClusterConfigPath, + instance.InstName, integrityCtx) + if err != nil { + return instances, fmt.Errorf("error loading instance %q configuration from "+ + "config %q: %w", instance.InstName, instance.ClusterConfigPath, err) + } - instance.SingleApp = false - instance.InstanceScript, err = findInstanceScriptInAppDir(appDir, instance.InstName, - appDirFiles.clusterCfgPath, appDirFiles.defaultLuaPath) - if err != nil && !skipClusterConfig { - return instances, fmt.Errorf("cannot find instance script for %q in config %q: %w ", - instance.InstName, appDirFiles.clusterCfgPath, err) + instance.SingleApp = false + instance.InstanceScript, err = findInstanceScriptInAppDir(appDir, instance.InstName, + appDirFiles.clusterCfgPath, appDirFiles.defaultLuaPath) + if err != nil { + return instances, fmt.Errorf("cannot find instance script for %q in config %q: %w ", + instance.InstName, appDirFiles.clusterCfgPath, err) + } + } else { + instance.SingleApp = false } instances = append(instances, instance) } diff --git a/cli/running/running_test.go b/cli/running/running_test.go index a3265b5a9..a68b2cf60 100644 --- a/cli/running/running_test.go +++ b/cli/running/running_test.go @@ -35,7 +35,7 @@ func Test_CollectInstances(t *testing.T) { instances, err := CollectInstances("script", instancesEnabledPath, integrity.IntegrityCtx{ Repository: &mockRepository{}, - }, true) + }, false) require.NoError(t, err) require.Equal(t, 1, len(instances)) require.Equal(t, InstanceCtx{ @@ -50,7 +50,7 @@ func Test_CollectInstances(t *testing.T) { instances, err = CollectInstances("single_inst", instancesEnabledPath, integrity.IntegrityCtx{ Repository: &mockRepository{}, - }, true) + }, false) require.NoError(t, err) require.Equal(t, 1, len(instances)) require.Equal(t, InstanceCtx{ @@ -67,7 +67,7 @@ func Test_CollectInstances(t *testing.T) { instances, err = CollectInstances(appName, instancesEnabledPath, integrity.IntegrityCtx{ Repository: &mockRepository{}, - }, true) + }, false) require.NoError(t, err) require.Equal(t, 3, len(instances)) assert.True(t, slices.Contains(instances, InstanceCtx{ @@ -103,7 +103,7 @@ func Test_CollectInstances(t *testing.T) { instances, err = CollectInstances("script", instancesEnabledPath, integrity.IntegrityCtx{ Repository: &mockRepository{}, - }, true) + }, false) assert.ErrorContains(t, err, "script\" doesn't exist or not a directory") assert.Equal(t, 0, len(instances)) @@ -113,7 +113,7 @@ func Test_CollectInstances(t *testing.T) { instances, err = CollectInstances("script", instancesEnabledPath, integrity.IntegrityCtx{ Repository: &mockRepository{}, - }, true) + }, false) assert.NoError(t, err) assert.Equal(t, 1, len(instances)) @@ -121,7 +121,7 @@ func Test_CollectInstances(t *testing.T) { instances, err = CollectInstances("script", instancesEnabledPath, integrity.IntegrityCtx{ Repository: &mockRepository{}, - }, true) + }, false) assert.ErrorContains(t, err, "script.lua: permission denied") assert.Equal(t, 1, len(instances)) require.NoError(t, os.Chmod(instancesEnabledPath, 0755))