ipm icon indicating copy to clipboard operation
ipm copied to clipboard

Missing pParams in resource processor phase method

Open janihur opened this issue 1 year ago • 3 comments

This is v0.7.3

I'm exploring an idea to use IPM to load module's installation env/site specific configuration.

I run into issue with parameters in resource processor. I have a simple processor Company.IPM.Config that only dumps information:

Method OnAfterPhase(pPhase As %String, ByRef pParams) As %Status
{
	write !
	write $classname(), ": OnAfterPhase(): phase: ", pPhase
	write !
	write $classname(), ": OnAfterPhase(): pParams: ", ..mdToString(.pParams)
	write !
	write $classname(), ": OnAfterPhase(): properties: ", ..propertiesToString()
	write !
	return $$$OK
}

In manifest:

<Resource Name="config" ProcessorClass="Company.IPM.Config"/>

I have RootDirectory parameter available when I'm loading the module:

zpm:IPM-TRIAL>load /home/irisowner/work/ipm-trial/company-module

[IPM-TRIAL|company-module]  Reload START (/home/irisowner/work/ipm-trial/company-module/)
Company.IPM.Config: OnAfterPhase(): phase: Reload
Company.IPM.Config: OnAfterPhase(): pParams: (md("DeveloperMode") 1)(md("RootDirectory") /home/irisowner/work/ipm-trial/company-module/)(md("cmd") load)
Company.IPM.Config: OnAfterPhase(): properties: (Name "config")

[IPM-TRIAL|company-module]  Reload SUCCESS
[company-module]       Module object refreshed.
[IPM-TRIAL|company-module]  Validate START
Company.IPM.Config: OnAfterPhase(): phase: Validate
Company.IPM.Config: OnAfterPhase(): pParams: (md("DeveloperMode") 1)(md("RootDirectory") /home/irisowner/work/ipm-trial/company-module/)(md("cmd") load)
Company.IPM.Config: OnAfterPhase(): properties: (Name "config")

[IPM-TRIAL|company-module]  Validate SUCCESS
[IPM-TRIAL|company-module]  Compile START
Company.IPM.Config: OnAfterPhase(): phase: Compile
Company.IPM.Config: OnAfterPhase(): pParams: (md("DeveloperMode") 1)(md("RootDirectory") /home/irisowner/work/ipm-trial/company-module/)(md("cmd") load)
Company.IPM.Config: OnAfterPhase(): properties: (Name "config")

[IPM-TRIAL|company-module]  Compile SUCCESS
[IPM-TRIAL|company-module]  Activate START
[IPM-TRIAL|company-module]  Configure START
Company.IPM.Config: OnAfterPhase(): phase: Configure
Company.IPM.Config: OnAfterPhase(): pParams: (md("DeveloperMode") 1)(md("RootDirectory") /home/irisowner/work/ipm-trial/company-module/)(md("cmd") load)
Company.IPM.Config: OnAfterPhase(): properties: (Name "config")

[IPM-TRIAL|company-module]  Configure SUCCESS
Company.IPM.Config: OnAfterPhase(): phase: Activate
Company.IPM.Config: OnAfterPhase(): pParams: (md("DeveloperMode") 1)(md("RootDirectory") /home/irisowner/work/ipm-trial/company-module/)(md("cmd") load)
Company.IPM.Config: OnAfterPhase(): properties: (Name "config")

[IPM-TRIAL|company-module]  Activate SUCCESS

But when I'm running only activate lifecycle to configure the module pParams is empty and now I don't know anymore where on the fileystem I can find config (directory) resource:

zpm:IPM-TRIAL>module-action company-module activate -only

[IPM-TRIAL|company-module]  Activate START
[IPM-TRIAL|company-module]  Configure START
Company.IPM.Config: OnAfterPhase(): phase: Configure
Company.IPM.Config: OnAfterPhase(): pParams:
Company.IPM.Config: OnAfterPhase(): properties: (Name "config")

[IPM-TRIAL|company-module]  Configure SUCCESS
Company.IPM.Config: OnAfterPhase(): phase: Activate
Company.IPM.Config: OnAfterPhase(): pParams:
Company.IPM.Config: OnAfterPhase(): properties: (Name "config")

[IPM-TRIAL|company-module]  Activate SUCCESS
zpm:IPM-TRIAL>

The plan is to have the resource processor to depend on -Denv value and act accordingly.

Second issue is why Denv=foo is expanded also to Dzpm.env=foo:

 pParams: (md("env") foo)(md("zpm","env") foo)
zpm:IPM-TRIAL>module-action company-module activate -only -Denv=foo

[IPM-TRIAL|company-module]  Activate START
[IPM-TRIAL|company-module]  Configure START
Company.IPM.Config: OnAfterPhase(): phase: Configure
Company.IPM.Config: OnAfterPhase(): pParams: (md("env") foo)(md("zpm","env") foo)
Company.IPM.Config: OnAfterPhase(): properties: (Name "config")

[IPM-TRIAL|company-module]  Configure SUCCESS
Company.IPM.Config: OnAfterPhase(): phase: Activate
Company.IPM.Config: OnAfterPhase(): pParams: (md("env") foo)(md("zpm","env") foo)
Company.IPM.Config: OnAfterPhase(): properties: (Name "config")

[IPM-TRIAL|company-module]  Activate SUCCESS
zpm:IPM-TRIAL>

janihur avatar Nov 07 '24 15:11 janihur

The workaround (?) is to pass the root directory as an attribute:

<Resource Name="config" ProcessorClass="Company.IPM.Config" RootDirectory="${root}"/>

Or:

<Resource Name="${root}/config" ProcessorClass="Company.IPM.Config"/>

janihur avatar Nov 07 '24 15:11 janihur

I'd call the workaround the current supported approach, but I think pParams would be good to have too.

isc-tleavitt avatar Nov 07 '24 18:11 isc-tleavitt

From a dummy (?) user perspective as long as the rules are not explained in the documentation I consider it's a bug that:

  • sometimes the data is available and sometimes it's not
  • -Denv expands both env and zpm.env global subscripts

janihur avatar Nov 08 '24 06:11 janihur