generated from xoap-io/xoap-powershell-dsc-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
New-CompositeResource.ps1
executable file
·75 lines (65 loc) · 2 KB
/
New-CompositeResource.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#Requires -Modules @{ ModuleName="Plaster"; ModuleVersion="1.1.3" }
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]
$Module,
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]
$Version,
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]
$Ressource,
[Parameter()]
[ValidateNotNullOrEmpty()]
[string]
$Company = "RIS AG"
)
$globalPrefix = "XOAP"
$curDirectory = Resolve-Path .\
$templatePath = Join-Path $curDirectory "templates"
$rootModulePath = Resolve-Path .\source
$Module = "${globalPrefix}${Module}DSC"
$modulePath = Join-Path $rootModulePath "$Module"
$moduleVersionPath = Join-Path $modulePath $Version
$moduleRessources = Join-Path $moduleVersionPath "DSCResources"
$ressourcePath = Join-Path $moduleRessources $Ressource
Write-Output "Checking if module $Module already exists under $moduleVersionPath"
if(Test-Path "$moduleVersionPath")
{
Write-Output "Module $Module with version $Version already exists. Continuing."
}
else
{
Write-Warning "Module $Module with version $Version does not exist. Creating new module. Please provide missing data."
$template = Join-Path $templatePath "shared_module"
$moduleData = @{
project_name = $Module
version = $Version
company = $Company
TemplatePath = "$template"
DestinationPath = "$moduleVersionPath"
}
Invoke-Plaster @moduleData
}
Write-Output "Going to check if ressource $Ressource exists under $ressourcePath"
if(Test-Path "$ressourcePath")
{
Write-Error "Ressource $Ressource already exists. Aborting"
}
else
{
Write-Output "Creating new ressource $Ressource for module $Module"
$template = Join-Path $templatePath "composite_resource"
$moduleData = @{
project_name = "${Ressource}"
version = "0.0.1"
company = $Company
TemplatePath = "$template"
DestinationPath = "$ressourcePath"
}
Invoke-Plaster @moduleData
}