VirtualEngine / Lability

Virtual Engine test lab deployment and configuration module
MIT License
283 stars 50 forks source link

Request: Add a Content tag to Resource instead of Uri #368

Open codykonior opened 5 years ago

codykonior commented 5 years ago

When I use Lability I use a custom resource to copy entire folders of modules over to the created VMs and this works pretty well.

But in some other places I want put single scripts somewhere on the filesystem. In my specific case it's a startup script that will be scheduled for ONSTART during CustomBootStrap - but is not available for download and writing it out myself in CustomBootStrap becomes really long (and a PITA escaping `"@$). I could put it somewhere on the local filesystem but then not bundling it with the DSC is irritating!

It would be cool to be able to use a Content tag on the Resource type instead of a Uri. If this exists it writes out Content to the Filename on the VM in UTF8 (no BOM) instead of trying to download the file or use one locally.

What do you think?

iainbrighton commented 5 years ago

Hi @codykonior

I think I see the value in this, however... You can inject local files (from the host) without a Uri (it might not even be documented?) like this:

@{
    NonNodeData = @{
        Lability = @{
            Resources = @(
                @{
                     ## Copies the (relative) .\Lab\Scripts folder to the C:\Scripts folder in the VM
                     Id = 'Scripts';               ## Id is used as the destination folder name
                     FileName = '.\Lab\Scripts\';  ## This could be a full or relative file path
                     IsLocal = $true;              ## The source file(s) are local to the host
                     DestinationPath = '\';        ## Destination path in the VM
                }
            )
        }
    }
}

Does this functionality meet your needs (and supports whatever encoding the source file is in) without having to extend any existing functionality?

codykonior commented 5 years ago

Yeah I said I do that already :)

But because this is DSC, specifying relative paths to the source files rarely works as intended. Whenever I distribute my module (which has the DSC, and now, the scripts) I pre-parse the configuration when building the lab and re-output it with the full location to the resources before passing it to Lability.

If I didn't have to specify a path at all and just had a content section then I could bundle the script into the DSC which would save that step. But it's okay if this is too troublesome and you don't want to do this.

iainbrighton commented 5 years ago

Would you still expect the content to be of type string[] or string? Would having it a base64 encoded string be beneficial (although it would be somewhat obfuscated)?

I do see some benefits to adding this, I just want to make sure we've explored all alternatives first 😉.

iainbrighton commented 5 years ago

@codykonior Any further thoughts on this?