# lib-run-datastore.psm1


set-strictmode -version 2.0

function defineFlowTask([Flow]$flow,[Task]$task) {
#--- define
  $def = new-module -asCustomObject -scriptBlock {
    function getTaskDesc([Task]$task) {
      $tfs = $task.tfs;
      $gfn = $tfs.globMap.gaelGlobs.gfn;
      $desc = "Start Datastore Server - proj=$($gfn.gaelProj) curPort=$($gfn.curPort) dbPort=$($gfn.dbPort) locn=$($gfn.dbLocn)";
      $desc = $desc -replace "\\","/"
      hlogBoth("getTaskDesc $desc")
      return $desc
    }

    # ---------- define task parameters
    function params {
      param([Object]$task)
      $parms = @{};
      $parms.brief    = "$($task.statlocn)"
      $parms.str      = "create Brief"
      $parms.gen      = "5"
      $parms.genstr   = "output line from parm defintition line="
      $parms.bool1    = $null
      $parms['swkey=']  = 'key-value';
      return  $parms
    }

    # ---------- define task options
    <#function options {
      param([Object]$task)
      $opts = @();
      $opts += @{type='input';  parm='gen';     label='Gen';     place='number of lines to generate'; regex='^[0-9]+$'}
      $opts += @{type='input';  parm='genstr';  label='GenStr';  place='string to generate'}
      $opts += @{type='input';  parm='genbrf';  label='GenBrf';  place='number of brief.GenArr lines to generate'; regex='^[0-9]+$'}
      $opts += @{type='check';  parm='bool1';   label='bool1';   place='turns on bool1 option when checked'}
      $opts += @{type='radio';  parm='trap';    label='trap';    valset='*/*no trap,fail/gen FAIL,trap/gen TRAP'}
      $opts += @{type='combo';  parm='combo';   label='combo';   valset='*/*--none--,green,red/show red,blue/set blue'}
      return  ,$opts
    }#>

    # ---------- the actual script
    function runScript([Task]$task, [hashtable]$parms, [hashtable]$status) {
      $tfs = $task.tfs;
      $gfn = $tfs.globMap.gaelGlobs.gfn;
      $locn = "$($gfn.gaelicBase)".substring(0,"$($gfn.gaelicBase)".length - 4)
      $cmd  = "gcloud beta emulators datastore start  --data-dir=$($gfn.dbLocn) --host-port=localhost:$($gfn.dbPort)"
      $status.cmd = $cmd
      Start-Process -FilePath "C:\Windows\System32\cmd.exe" -verb runas -ArgumentList '/K',"$cmd"
      hlogBoth("Running datastore start script $($task.name) locn $locn")
      $status.sCondCode = "GOOD";
    }
    Export-ModuleMember -Variable * -Function *
  }
  hlogBoth("define-task $flow $task")
  #EC1B04 - dig out useful context info. Assumes GaelFlowBase without actually dragging it in.
  #$def.desc = $def.desc + " - proj=$($task.cfb.gaelProj) curPort=$($task.cfb.curPort) dbPort=$($task.cfb.dbPort) locn=$($task.cfb.dbLocn)";

  return $def;
}



X
PSEC - Powershell Enhanced Capability
1.2.1
  src: run-datastore-run-datastore-run-datastore-lib.psm1

Copyright © 2018-2021, 2022, Rexcel System Inc.