Selaa lähdekoodia

convert config to yaml

Tobias Simetsreiter 3 vuotta sitten
vanhempi
sitoutus
d6fff8f33b
2 muutettua tiedostoa jossa 17 lisäystä ja 21 poistoa
  1. 11 0
      etc/departments.yaml
  2. 6 21
      gitlab/groupusers.ps1

+ 11 - 0
etc/departments.yaml

@@ -0,0 +1,11 @@
+departments:
+  - name: ANNAX CH Testing and Integration
+    id: 3160
+    glgroup:
+      name: annax/teams/integrationtest
+      access_level: 20
+  - name: ANNAX DE Device Software Engineering
+    id: 3130
+    glgroup:
+      name: annax/teams/developers
+      access_level: 30

+ 6 - 21
gitlab/groupusers.ps1

@@ -13,8 +13,8 @@ $GITLAB_INVITE = "$PSScriptRoot\gitlab-invite.ps1"
 Set-Log ([IO.Path]::GetFullPath("$PSScriptRoot\..\runtime\groupusers-${env:computername}.log")) 1mb 2
 
 
-foreach ($module in @("ActiveDirectory")){
-    if (-not (Get-Module $module -All)) {
+foreach ($module in @("ActiveDirectory", "Powershell-Yaml")){
+    if (-not (Get-Module -ListAvailable -Name $module)) {
         Install-Module $module -Scope CurrentUser
     }
     if (-not (Get-Module $module)) {
@@ -22,28 +22,13 @@ foreach ($module in @("ActiveDirectory")){
     }
 }
 
-$departments = @(
-    @{
-        name="ANNAX CH Testing and Integration"
-        id=3160
-        glgroup=@{
-            name="annax/teams/integrationtest";
-            access_level="20";
-        }
-    },
-    @{
-        name="ANNAX DE Device Software Engineering"
-        id=3130
-        glgroup=@{
-            name="annax/teams/developers";
-            access_level="30";
-        }
-    }
-)
+$dp_file = [IO.Path]::GetFullPath("$PSScriptRoot\..\etc\departments.yaml")
+
+$deps=Get-Content $dp_file | ConvertFrom-Yaml
 
 function Main(){
 
-    $departments | ForEach-Object {
+    $deps.departments | ForEach-Object {
         $filter = "*($([string]$_.id))"
         $department = $_;