Skip to content

Latest commit

 

History

History
194 lines (140 loc) · 5.27 KB

File metadata and controls

194 lines (140 loc) · 5.27 KB

Developer README

Development

Install dev dependencies:

Install-Module Pester -Force
Import-Module Pester -PassThru
Install-Module PSScriptAnalyzer -Force
Import-Module PSScriptAnalyzer -PassThru

To load the module from the project directory:

. SetupDev.ps1

Repeat the command to reload module.

To see debug log messages, set:

$VerbosePreference = "Continue"

To run tests:

make check

Develop Using the Container

Container based development is only tested on Linux.

Build the container:

podman build --platform linux/amd64 -t tririga-manage-ps1-dev .

Start container:

podman run --network host -v .:/workspace -it tririga-manage-ps1-dev

Initialize:

. ./SetupDev.ps1
Initialize-TririgaConfiguration
. ~/.config/powershell/Microsoft.PowerShell_profile.ps1
Set-TririgaCredential LOCAL -Username system -Password badadmin

Verify:

Get-TririgaEnvironment
Get-TririgaAgent LOCAL

Parameter Handling

We have commands that:

  1. By default, operate on all instances in an environment, but can optionally operate on a single instance.

    Use this model for changes that can be uniquely set on each server, such as a Property Get-Property and Set-Property)

     [CmdletBinding()]
     param(
         # The TRIRIGA environment to use.
         [Parameter(Mandatory, Position=0)]
         [ValidateNotNullOrEmpty()]
         [Alias("Env", "E")]
         [string]$environment,
         # The TRIRIGA instance within the environment to use.
         # If omitted, command will act on all instances.
         [Alias("Inst", "I")]
         [Parameter(Position=1)]
         [string]$instance,
         ...
    )
  2. If the command has other mandatory parameters, remove Position from $instance.

     [CmdletBinding()]
     param(
         # The TRIRIGA environment to use.
         [Parameter(Mandatory, Position=0)]
         [ValidateNotNullOrEmpty()]
         [Alias("Env", "E")]
         [string]$environment,
         # The TRIRIGA instance within the environment to use.
         # If omitted, command will act on all instances.
         [Alias("Inst", "I")]
         [Parameter()]
         [string]$instance,
         ...
         [Parameter(Mandatory, Position=1)]
         [string]$someArg
         ...
    )

    You may also want to remove Position from $instance to be consistent with same nouns. Eg: Set-WorkflowInstance and Get-WorkflowInstance must have the same semantics.

  3. By default operate on the first instance in an environment, but can optionally operate on any specific instance or all instances with the -All switch (only where it makes sense).

    Use this models for commands that are ultimately database bound, such as Get-Agent or Start-Agent.

    [CmdletBinding()]
    param(
        # The TRIRIGA environment to use.
        [Parameter(Mandatory, Position=0)]
        [ValidateNotNullOrEmpty()]
        [Alias("Env", "E")]
        [string]$environment,
        # The TRIRIGA instance within the environment to use.
        # If omitted, command will act on the first instance.
        [Alias("Inst", "I")]
        [string]$instance,
        # By default only one instance is queried. Set this switch to query all instances.
        [switch]$all
    
    ...
    
    $apiCall = @{
         ...
         OnlyOnAnyOneInstance = !$all
         ...
    }
  4. Any commands that will modify the system must implement the SupportsShouldProcess interface:

    [CmdletBinding(SupportsShouldProcess)]
    param(
         ...

    In most cases, all you need to do is pass OperationLabel to CallTririgaApi to activate confirmation. User will be asked to confirm change to each instance.

Publish

To publish the modules to Gitea

  1. Make sure all tests pass:

    make check
    
  2. Edit install.ps1 and update the version.

  3. Build dist. This will update README and module definitions:

    make dist
    
  4. Commmit changes

  5. Create a tag:

    make git-tag
    
  6. Push all changes:

    git push && git push --tags
    git push gitea && git push gitea --tags
    
  7. Check for issues:

    make release-check
    
  8. Release:

    make release
    

PowerShell