-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support passing in -env /path/to/env.json
at installation time.
#704
base: v0.10.x
Are you sure you want to change the base?
Conversation
@isc-shuliu general q: thoughts on having the helper method for consumers return the full json for their package? Gives them more control then instead of extracting individual keys |
@isc-kiyer Do you think we should omit the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@isc-shuliu looks mostly great! Few small comments/questions
While iter.%GetNext(.key, .value, .type) { | ||
If (type = "object") || (type = "array") { | ||
If dest.%GetTypeOf(key) = "unassigned" { | ||
Do dest.%Set(key, value.%New()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does value need a %New() here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So my idea was that, whenever dest[key]
is empty:
- if
src[key]
is an array, we assign an empty JSON array[ ]
and then keep recursing - if
src[key]
is an object, we assign an empty JSON object{ }
and then keep recursing
During the recursive calls, the newly created empty array [ ]
or empty object { }
will be populated.
Throughout this recursive function, I only call dest.%Set()
with primitive types, newly created array [ ]
, or newly created object { }
. This ensures dest[key]
doesn't reference the same object as src[key]
. In other words, I create a deep copy of src[key]
and assign to dest[key]
.
If we use Do dest.%Set(key, value)
where value
is src[key]
and modify src[key]
later, dest
will also change. This is an unexpected behavior.
Quit ..Config.%ToJSON() | ||
} | ||
|
||
Method SetJson(json As %String) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we ever be setting from anything other than a file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not at the moment. But just in case in the future we need the ability to inject config from another source (say network stream), I added this method. Shall I remove it?
src/cls/IPM/Lifecycle/Base.cls
Outdated
Set paths = $ListFromString(paths, ";") | ||
Set ptr = 0 | ||
While $ListNext(paths, ptr, file) { | ||
$$$ThrowOnError(config.Load(file)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also remove leading/trailing white space here before loading the file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace is a valid character in file names on both Unix and Windows. But I think it's uncommon to have a trailing whitespace and totally illegal to have a leading one in an absolute path.
@isc-tleavitt Ideas on whether to strip the whitespace?
@@ -272,9 +272,13 @@ load https://github.com/user/repository.git -branch feature-1 | |||
<example description="Loads the module described in C:\module\root\path\module.xml but set pip timeout to 30 seconds"> | |||
load -extra-pip-flags "--timeout 30" C:\module\root\path\ | |||
</example> | |||
<example description="Loads the module described in C:\module\root\path\module.xml using the C:\path\to\env.json as the install time configuration"> | |||
load -env C:\path\to\env.json C:\module\root\path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have semi-colon between the paths
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually an env.json file + a package folder. I'll add a couple examples to emphasize the "semicolon-separated" syntax.
// Methods with [CodeMode = objectgenerator] can then use this to access configuration set in env.json | ||
Set itconfig = ##class(%IPM.General.InstallTimeConfig).%Get() | ||
If 'itconfig.IsEmpty() { | ||
Set qSpec = qSpec _ "/multicompile=0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does multicompile affect regular use case outside of migration code?
|
||
|
||
<!-- Modifiers --> | ||
<modifier name="env" aliases="e" dataAlias="EnvFiles" value="true" description="Semicolon separated paths to the environment files in json format. See wiki for details." /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could env be added as a possible modifier for module-action too? A use case could be using it in a custom phase for invokes
Correct. I think we should keep the package-name part since one module may want to access package-name for another dependency perhaps? I could go either way on that though. I think it may be more complicated to keep context than is worth the effort though, especially since its a singleton and modules could be getting installed in parallel. |
I can see a use case for Sales when we'd like to install the same package in different namespaces with different configuration. It might be necessary to impose a standard for how to do this. Perhaps within the json object that is the value of the key there could be keys corresponding to the namespace in which configuration is applied? |
Implement #632
install <pacakge> -env /path/to/json1;/path/to/json2