Skip to content

Commit

Permalink
skip config loading and script searching
Browse files Browse the repository at this point in the history
  • Loading branch information
patapenka-alexey committed Jan 3, 2025
1 parent 8b8bd6d commit f729a21
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
28 changes: 16 additions & 12 deletions cli/running/running.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
12 changes: 6 additions & 6 deletions cli/running/running_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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{
Expand All @@ -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{
Expand Down Expand Up @@ -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))

Expand All @@ -113,15 +113,15 @@ 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))

require.NoError(t, os.Chmod(instancesEnabledPath, 0666))
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))
Expand Down

0 comments on commit f729a21

Please sign in to comment.