@@ -669,13 +669,14 @@ int Cli::run(const RunOptions &options)
669669 LogD (" RunContext Config:\n {}" , nlohmann::json (runContextCfg).dump ());
670670
671671 auto containerID = runContext.getContainerId ();
672- LogD (" run app: {} container id: {}" , curAppRef->toString (), containerID);
672+ LogD (" run {} with container id: {}" , curAppRef->toString (), containerID);
673673
674- const auto &appLayerItem = runContext.getCachedAppItem ();
675- if (!appLayerItem) {
674+ auto targetItem = runContext.getCachedTargetItem ();
675+ if (!targetItem) {
676+ this ->printer .printErr (LINGLONG_ERRV (" failed to get cached target item" , targetItem));
676677 return -1 ;
677678 }
678- const auto &info = appLayerItem ->info ;
679+ const auto &info = targetItem ->info ;
679680
680681 auto commands = options.commands ;
681682 if (options.commands .empty ()) {
@@ -831,20 +832,20 @@ int Cli::runResolvedContext(runtime::RunContext &runContext,
831832{
832833 LINGLONG_TRACE (" run resolved context" );
833834
834- auto appLayerItem = runContext.getCachedAppItem ();
835- if (!appLayerItem ) {
836- this ->printer .printErr (LINGLONG_ERRV (" failed to get cached app item" ));
835+ auto targetItem = runContext.getCachedTargetItem ();
836+ if (!targetItem ) {
837+ this ->printer .printErr (LINGLONG_ERRV (" failed to get cached target item" , targetItem ));
837838 return -1 ;
838839 }
839840
840841 auto commands = options.commands ;
841842 if (options.commands .empty ()) {
842- commands = appLayerItem ->info .command .value_or (std::vector<std::string>{ " bash" });
843+ commands = targetItem ->info .command .value_or (std::vector<std::string>{ " bash" });
843844 }
844845 commands = filePathMapping (commands, options);
845846
846847 auto appCache =
847- common::dir::getContainerCacheDir (appLayerItem ->commit , runContext.getContainerId ());
848+ common::dir::getContainerCacheDir (targetItem ->commit , runContext.getContainerId ());
848849
849850 runtime::RunContainerOptions runOptions;
850851 runOptions.enableSecurityContext (runtime::getDefaultSecurityContexts ());
@@ -991,7 +992,9 @@ Cli::getCurrentContainers() const noexcept
991992
992993 myContainers.emplace_back (api::types::v1::CliContainer{
993994 .id = std::move (info->containerID ),
994- .package = std::move (info->app ),
995+ .package = !info->app .empty ()
996+ ? info->app
997+ : (info->runtime && !info->runtime ->empty () ? *info->runtime : info->base ),
995998 .pid = container->pid ,
996999 });
9971000 }
@@ -2089,12 +2092,12 @@ utils::error::Result<std::filesystem::path> Cli::ensureCache(runtime::RunContext
20892092 LINGLONG_TRACE (" ensure cache via PM" );
20902093
20912094 const auto &containerID = context.getContainerId ();
2092- auto appLayerItem = context.getCachedAppItem ();
2093- if (!appLayerItem ) {
2094- return LINGLONG_ERR (" failed to get cached app item" );
2095+ auto targetItem = context.getCachedTargetItem ();
2096+ if (!targetItem ) {
2097+ return LINGLONG_ERR (" failed to get cached target item" , targetItem );
20952098 }
20962099
2097- auto appCache = common::dir::getContainerCacheDir (appLayerItem ->commit , containerID);
2100+ auto appCache = common::dir::getContainerCacheDir (targetItem ->commit , containerID);
20982101 auto runContextConfigFile = appCache / " .config" ;
20992102 std::error_code ec;
21002103 if (std::filesystem::exists (runContextConfigFile, ec)) {
0 commit comments