Skip to content
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

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

Open
codykonior opened this issue Jun 19, 2019 · 4 comments
Open

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

codykonior opened this issue Jun 19, 2019 · 4 comments

Comments

@codykonior
Copy link
Contributor

codykonior commented Jun 19, 2019

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
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor

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
Copy link
Contributor

@codykonior Any further thoughts on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants