grahampugh / jamf-upload

Scripts for uploading packages to Jamf Cloud
Apache License 2.0
150 stars 39 forks source link

Added 'skip_script_key_substitution' Flag #92

Closed PeteToscano closed 1 year ago

PeteToscano commented 1 year ago

This flag indicates if the script being uploaded is or isn't a template. If the flag is set to False, it'll skip the substitute_assignable_keys(script_contents) call. This can be useful for scripts that have strings bracketed by % symbols. For example, this date command in a bash script: date +"%Y-%m-%d %H:%M:%S%z". Without this flag, JamfScriptUploader.py throws an autopkglib.ProcessorError exception saying, "Unsubstitutable key in template found: 'S'." This small example can be worked around, but in larger or more pathological cases, it might be simpler to bypass the variable-replacement entirely.

The script_is_template flag is not required, and the default value is True. This should ensure that the default behavior of JamfScriptUploader.py doesn't change with this PR applied. (Or at least it shouldn't.)

(Side note: I'm new to creating GH PRs, so apologies if the formatting is messed up somehow.)

PeteToscano commented 1 year ago

/me sighs.

Did I submit this to the wrong repo? Should it be here or under autopkg/grahampugh-recipes instead?

grahampugh commented 1 year ago

Here is correct! Thanks. I'll take a look when I get a chance.

PeteToscano commented 1 year ago

Thanks, Graham. No big deal if you'd rather decline this PR, and there is no rush.

grahampugh commented 1 year ago

Hi @PeteToscano just to let you know I do want to implement this, just I don't like the script_is_template key name. I think skip_script_key_substitution is probably what I'll go for :-) I'll try and get to it soon.

PeteToscano commented 1 year ago

Thanks for the feedback, Graham. I've updated the patch to reflect the new name and changed the default value so that not defining skip_script_key_substitution will still result in the usual behavior. I was able to test it in normal use (not set, set to False, and set to True), but not in an override, if that makes any difference.

grahampugh commented 1 year ago

Perfect, thanks for making the change. Merged it in this repo now, I'll do some load testing before it goes into grahampugh-recipes.

grahampugh commented 1 year ago

FYI, working a treat when the key is set to True either in the Input array (so will work in overrides) or directly in the Processor arguments. 👍 I was able to remove the workaround I had made in the one script I have where this mattered :)

PeteToscano commented 1 year ago

Good deal. Happy I can contribute back in some small way. Thanks again for writing and maintaining the Jamf processors for autopkg (not to mention the YAML support).