-
Notifications
You must be signed in to change notification settings - Fork 53
initial commit of module #14
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
97aeddc
initial commit of module
TylerLeonhardt c3d15a0
address feedback and move module into worker
TylerLeonhardt 1476d62
address Dongbo's feedback
TylerLeonhardt 128fdc1
remove psd1 fields and change Set logic
TylerLeonhardt e8cdd81
don't expose vars in psd1
TylerLeonhardt ae595fb
alpha sort functions
TylerLeonhardt e921ec2
helper function refactoring
TylerLeonhardt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
...er/Azure.Functions.PowerShell.Worker.Module/Azure.Functions.PowerShell.Worker.Module.psd1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
@{ | ||
|
||
# Script module or binary module file associated with this manifest. | ||
RootModule = 'Azure.Functions.PowerShell.Worker.Module.psm1' | ||
|
||
# Version number of this module. | ||
ModuleVersion = '0.1.0' | ||
|
||
# Supported PSEditions | ||
CompatiblePSEditions = @('Desktop', 'Core') | ||
|
||
# ID used to uniquely identify this module | ||
GUID = 'f0149ba6-bd6f-4dbd-afe5-2a95bd755d6c' | ||
|
||
# Author of this module | ||
Author = 'Microsoft Corporation' | ||
|
||
# Company or vendor of this module | ||
CompanyName = 'Microsoft Corporation' | ||
|
||
# Copyright statement for this module | ||
Copyright = '(c) Microsoft Corporation. All rights reserved.' | ||
|
||
# Description of the functionality provided by this module | ||
Description = 'The module used in an Azure Functions environment for setting and retrieving Output Bindings.' | ||
|
||
# Minimum version of the PowerShell engine required by this module | ||
PowerShellVersion = '5.1' | ||
|
||
# Modules that must be imported into the global environment prior to importing this module | ||
RequiredModules = @() | ||
|
||
# Assemblies that must be loaded prior to importing this module | ||
RequiredAssemblies = @() | ||
|
||
# Script files (.ps1) that are run in the caller's environment prior to importing this module. | ||
ScriptsToProcess = @() | ||
|
||
# Type files (.ps1xml) to be loaded when importing this module | ||
TypesToProcess = @() | ||
|
||
# Format files (.ps1xml) to be loaded when importing this module | ||
FormatsToProcess = @() | ||
|
||
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess | ||
NestedModules = @() | ||
|
||
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. | ||
FunctionsToExport = @('Push-OutputBinding', 'Get-OutputBinding') | ||
|
||
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. | ||
CmdletsToExport = @() | ||
|
||
# Variables to export from this module | ||
VariablesToExport = @() | ||
|
||
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. | ||
AliasesToExport = @() | ||
|
||
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. | ||
PrivateData = @{ | ||
|
||
PSData = @{ | ||
|
||
# Tags applied to this module. These help with module discovery in online galleries. | ||
Tags = @('Microsoft', 'Azure', 'Functions', 'Serverless', 'Cloud') | ||
|
||
# A URL to the license for this module. | ||
LicenseUri = 'https://github.com/Azure/azure-functions-powershell-worker/blob/dev/LICENSE' | ||
|
||
# A URL to the main website for this project. | ||
ProjectUri = 'https://github.com/Azure/azure-functions-powershell-worker' | ||
|
||
# A URL to an icon representing this module. | ||
# IconUri = '' | ||
|
||
# ReleaseNotes of this module | ||
ReleaseNotes = '# 0.1.0 | ||
Initial Release. | ||
' | ||
|
||
} | ||
} | ||
} |
126 changes: 126 additions & 0 deletions
126
...er/Azure.Functions.PowerShell.Worker.Module/Azure.Functions.PowerShell.Worker.Module.psm1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
# | ||
# Copyright (c) Microsoft. All rights reserved. | ||
# Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
# | ||
|
||
# This holds the current state of the output bindings | ||
$script:_OutputBindings = @{} | ||
|
||
<# | ||
.SYNOPSIS | ||
Gets the hashtable of the output bindings set so far. | ||
.DESCRIPTION | ||
Gets the hashtable of the output bindings set so far. | ||
.EXAMPLE | ||
PS > Get-OutputBinding | ||
Gets the hashtable of all the output bindings set so far. | ||
.EXAMPLE | ||
PS > Get-OutputBinding -Name res | ||
Gets the hashtable of specific output binding. | ||
.EXAMPLE | ||
PS > Get-OutputBinding -Name r* | ||
Gets the hashtable of output bindings that match the wildcard. | ||
.PARAMETER Name | ||
The name of the output binding you want to get. Supports wildcards. | ||
.OUTPUTS | ||
The hashtable of binding names to their respective value. | ||
#> | ||
function Get-OutputBinding { | ||
[CmdletBinding()] | ||
param( | ||
[Parameter(ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)] | ||
[string[]] | ||
$Name = '*' | ||
) | ||
begin { | ||
$bindings = @{} | ||
} | ||
process { | ||
$script:_OutputBindings.GetEnumerator() | Where-Object Name -Like $Name | ForEach-Object { $null = $bindings.Add($_.Name, $_.Value) } | ||
} | ||
end { | ||
return $bindings | ||
} | ||
} | ||
|
||
# Helper private function that sets an OutputBinding. | ||
function Push-KeyValueOutputBinding { | ||
param ( | ||
[Parameter(Mandatory=$true)] | ||
[string] | ||
$Name, | ||
|
||
[Parameter(Mandatory=$true)] | ||
[object] | ||
$Value, | ||
|
||
[switch] | ||
$Force | ||
) | ||
if(!$script:_OutputBindings.ContainsKey($Name) -or $Force.IsPresent) { | ||
$script:_OutputBindings[$Name] = $Value | ||
} else { | ||
throw "Output binding '$Name' is already set. To override the value, use -Force." | ||
} | ||
} | ||
|
||
<# | ||
.SYNOPSIS | ||
Sets the value for the specified output binding. | ||
.DESCRIPTION | ||
Sets the value for the specified output binding. | ||
.EXAMPLE | ||
PS > Push-OutputBinding -Name res -Value "my output" | ||
The output binding of "res" will have the value of "my output" | ||
.PARAMETER Name | ||
The name of the output binding you want to set. | ||
.PARAMETER Value | ||
The value of the output binding you want to set. | ||
.PARAMETER InputObject | ||
The hashtable that contains the output binding names to their respective value. | ||
.PARAMETER Force | ||
(Optional) If specified, will force the value to be set for a specified output binding. | ||
#> | ||
function Push-OutputBinding { | ||
[CmdletBinding()] | ||
param ( | ||
[Parameter( | ||
Mandatory=$true, | ||
ParameterSetName="NameValue", | ||
Position=0, | ||
ValueFromPipelineByPropertyName=$true)] | ||
[string] | ||
$Name, | ||
|
||
[Parameter( | ||
Mandatory=$true, | ||
ParameterSetName="NameValue", | ||
Position=1, | ||
ValueFromPipelineByPropertyName=$true)] | ||
[object] | ||
$Value, | ||
|
||
[Parameter( | ||
Mandatory=$true, | ||
ParameterSetName="InputObject", | ||
Position=0, | ||
ValueFromPipeline=$true)] | ||
[hashtable] | ||
$InputObject, | ||
|
||
[switch] | ||
$Force | ||
) | ||
process { | ||
switch ($PSCmdlet.ParameterSetName) { | ||
NameValue { | ||
Push-KeyValueOutputBinding -Name $Name -Value $Value -Force:$Force.IsPresent | ||
} | ||
InputObject { | ||
$InputObject.GetEnumerator() | ForEach-Object { | ||
Push-KeyValueOutputBinding -Name $_.Name -Value $_.Value -Force:$Force.IsPresent | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.