@@ -348,7 +348,7 @@ func loadInstanceConfig(configPath, instName string,
348
348
349
349
// collectInstancesFromAppDir collects instances information from application directory.
350
350
func collectInstancesFromAppDir (appDir string , selectedInstName string ,
351
- integrityCtx integrity.IntegrityCtx , instancesScriptsRequired bool ) (
351
+ integrityCtx integrity.IntegrityCtx , configRequired bool ) (
352
352
[]InstanceCtx ,
353
353
error ,
354
354
) {
@@ -376,7 +376,7 @@ func collectInstancesFromAppDir(appDir string, selectedInstName string,
376
376
InstName : filepath .Base (appDir ),
377
377
AppDir : appDir ,
378
378
SingleApp : true }}, nil
379
- } else if instancesScriptsRequired {
379
+ } else if configRequired {
380
380
return nil , fmt .Errorf ("require files are missing in application directory %q: " +
381
381
"there must be instances config or the default instance script (%q)" ,
382
382
appDir , "init.lua" )
@@ -410,15 +410,15 @@ func collectInstancesFromAppDir(appDir string, selectedInstName string,
410
410
log .Debugf ("Instance %q" , instance .InstName )
411
411
412
412
if instance .Configuration , err = loadInstanceConfig (instance .ClusterConfigPath ,
413
- instance .InstName , integrityCtx ); err != nil {
413
+ instance .InstName , integrityCtx ); err != nil && configRequired {
414
414
return instances , fmt .Errorf ("error loading instance %q configuration from " +
415
415
"config %q: %w" , instance .InstName , instance .ClusterConfigPath , err )
416
416
}
417
417
418
418
instance .SingleApp = false
419
419
if instance .InstanceScript , err = findInstanceScriptInAppDir (appDir , instance .InstName ,
420
420
appDirFiles .clusterCfgPath , appDirFiles .defaultLuaPath ); err != nil &&
421
- instancesScriptsRequired {
421
+ configRequired {
422
422
return instances , fmt .Errorf ("cannot find instance script for %q in config %q: %w " ,
423
423
instance .InstName , appDirFiles .clusterCfgPath , err )
424
424
}
@@ -434,7 +434,7 @@ func collectInstancesFromAppDir(appDir string, selectedInstName string,
434
434
435
435
// CollectInstances searches all instances available in application.
436
436
func CollectInstances (appName string , applicationsDir string ,
437
- integrityCtx integrity.IntegrityCtx , instancesScriptsRequired bool ) ([]InstanceCtx , error ) {
437
+ integrityCtx integrity.IntegrityCtx , configRequired bool ) ([]InstanceCtx , error ) {
438
438
// The user can select a specific instance from the application.
439
439
// Example: `tt status application:server`.
440
440
selectedInstName := ""
@@ -463,7 +463,7 @@ func CollectInstances(appName string, applicationsDir string,
463
463
}
464
464
465
465
return collectInstancesFromAppDir (appDir , selectedInstName , integrityCtx ,
466
- instancesScriptsRequired )
466
+ configRequired )
467
467
}
468
468
469
469
// cleanup removes runtime artifacts.
@@ -625,7 +625,7 @@ func GetClusterConfigPath(cliOpts *config.CliOpts,
625
625
626
626
// CollectInstancesForApps collects instances information per application.
627
627
func CollectInstancesForApps (appList []string , cliOpts * config.CliOpts ,
628
- ttConfigDir string , integrityCtx integrity.IntegrityCtx , instancesScriptsRequired bool ) (
628
+ ttConfigDir string , integrityCtx integrity.IntegrityCtx , configRequired bool ) (
629
629
map [string ][]InstanceCtx , error ) {
630
630
instEnabledPath := cliOpts .Env .InstancesEnabled
631
631
if cliOpts .Env .InstancesEnabled == "." {
@@ -635,7 +635,7 @@ func CollectInstancesForApps(appList []string, cliOpts *config.CliOpts,
635
635
for _ , appName := range appList {
636
636
appName = strings .TrimSuffix (appName , ".lua" )
637
637
collectedInstances , err := CollectInstances (appName , instEnabledPath , integrityCtx ,
638
- instancesScriptsRequired )
638
+ configRequired )
639
639
if err != nil {
640
640
return apps , fmt .Errorf ("can't collect instance information for %s: %w" ,
641
641
appName , err )
@@ -676,7 +676,7 @@ func createInstanceDataDirectories(instance InstanceCtx) error {
676
676
677
677
// FillCtx fills the RunningCtx context.
678
678
func FillCtx (cliOpts * config.CliOpts , cmdCtx * cmdcontext.CmdCtx ,
679
- runningCtx * RunningCtx , args []string , instancesScriptsRequired bool ) error {
679
+ runningCtx * RunningCtx , args []string , configRequired bool ) error {
680
680
var err error
681
681
682
682
if len (args ) > 1 && cmdCtx .CommandName != "run" && cmdCtx .CommandName != "connect" &&
@@ -703,7 +703,7 @@ func FillCtx(cliOpts *config.CliOpts, cmdCtx *cmdcontext.CmdCtx,
703
703
}
704
704
705
705
instances , err := CollectInstancesForApps (appList , cliOpts ,
706
- cmdCtx .Cli .ConfigDir , cmdCtx .Integrity , instancesScriptsRequired )
706
+ cmdCtx .Cli .ConfigDir , cmdCtx .Integrity , configRequired )
707
707
if err != nil {
708
708
return err
709
709
}
0 commit comments