Functions/Publish-DatabricksFilesToWorkspaceByName.ps1
<#
.SYNOPSIS Deploys DataBricks Files from configuration json file to a workspace .DESCRIPTION Deploys DataBricks Files from configuration json file to a workspace .PARAMETER config Configuration json file from the environment used to workout whether to deploy a clusters from a folder or file(s) .EXAMPLE Publish-DatabricksFilesToWorkspaceByName -config $config -bearerToken 'dapi1234567890' -localInputPath '</path/to/file>' .NOTES Author: Sabin IO #> Function Publish-DatabricksFilesToWorkspaceByName { [cmdletbinding()] Param( [parameter(Mandatory = $true)]$config, [parameter(Mandatory = $true)][string]$localInputPath, [parameter(Mandatory = $false)][switch]$testFileExists ) try { $localInputPath = Resolve-Path $localInputPath Write-Verbose $localInputPath Push-Location Set-Location $localInputPath if ($config.dbfsFiles) { Write-Output "dbfsFiles config key supplied" if ($config.dbfsFiles.Length -ge 1) { # Check if files exist in the first place foreach ($file in $config.dbfsFiles) { if ($PSBoundParameters.ContainsKey('testFileExists') -eq $true) { $DoesFileExist = Test-Path (Join-Path $localInputPath $file.filePattern) If ($DoesFileExist -eq $True) { Write-Host "Yippee" } Else { Write-Host "No file at this location" Throw } } Add-DatabricksDBFSFile ` -LocalRootFolder $localInputPath ` -FilePattern $file.filePattern ` -TargetLocation $file.targetLocation } } } else { Write-Warning "dbfsFiles config key not supplied, but the switch has been supplied to the pipeline." } } catch { #uh oh Pop-Location throw $_.Exception } Pop-Location } |