Stitch on CLIs
Some of the Stitch features, like preview or dry run, can be run through either Jython or XL CLI.
The Stitch Dry run allows you to execute a Stitch preview run with different sets of Stitch rules which are not yet defined in the system or that are run against the git branches. When a dry run is executed, the transformation engine will take all those rule files in the input or from the branch, validate them, parse them and use the rule files defined in them to do a Stitch transformation on specified deployment object.
The limitation of the dry run, when used with files or directories, is that it won't parse any processor templates in the external files. Running dry run against a Branch doesn't have this limitation.
Dry run using XL CLI
The Stitch dry or preview run can be run using the XL CLI. Following are supported XL CLI document kinds. Running Stitch preview using
StitchPreviewkind: Preview the stitch transformations by running thexl previewcommand:
---
apiVersion: xl-deploy/v1
kind: StitchDryRun
spec:
package: Applications/XL/cmd/AppWithCommands/1.0
environment: !value environmentName
The above example will take deployeds in package and run a Stitch preview for the environment. See Stitch peview for reference about preview and response received for this action.
StitchDryRunkind: Preview the stitch transformations by running thexl previewcommand:
---
apiVersion: xl-deploy/v1
kind: StitchDryRun
spec:
package: !value package
environment: !value environment
stitchSource: !value source
branchName: !value branch
The above example is similar to StitchPreview one with additional parameters for running dry run against given branch defined with stitchSource and branchName. See Stitch Branches for additional reference on GitOps for Stitch.
Dry run using Jython CLI
The Stitch dry run can be run using the Jython CLI. The methods available under the stitch in CLI are described below.
Validation of rule files
validateRules(stitchRules)- parameters:
stitchRulesList of stitch rule YAMLs as String
- returns: a list of errors, the list is empty if the rules provided are valid
- parameters:
validateRuleFiles(stitchFilePaths)- parameters:
stitchFilePathsList of stitch rule file paths
- returns: a list of errors, the list is empty if the rules provided are valid
- parameters:
validateRuleFromDirectory(stitchDirectoryPath)- parameters:
stitchDirectoryPathA path to a directory containing stitch files
- returns: a list of errors, the list is empty if the rules provided are valid
- parameters:
Dry run against Branch
dryRun(deployment, sourceId, branchName)- parameters:
deploymenta deployment objectsourceIdA source CI ID we want to run dry-run against.branchNameA branch name against which we want to run dry-run against.
- returns: a PreviewResult object containing a map of Deployeds and it's invocation list with details about: input, output, diff, processors and errors
- parameters:
dryRunWithBreakpoint(deployedName, invocationId, processorId, deployment, sourceId, branchName)- parameters:
deployedNameThe name of the deployed against which we want to check the processor breakpoint runinvocationIdThe order number in a list of invocations against which we want to the check processor breakpoint runprocessorIdThe UUID of the processor as a String - the actual place of breakpoint we want to see the diff fordeploymentThe deployment objectsourceIdThe source CI ID we want to run the dry-run against.branchNameThe branch name against which we want to run the dry-run against.
- returns: an InvocationDiffView object containing: input, output and diff for a processor call
- parameters:
Dry run against external defined rules
dryRun(deployment, stitchRules)- parameters:
deploymenta deployment objectstitchRulesA path to a directory containing stitch files
- returns: a PreviewResult object containing a map of Deployeds and it's invocation list with details about: input, output, diff, processors and errors
- parameters:
dryRunRuleFileList(deployment, stitchFilePaths)- parameters:
deploymenta deployment objectstitchFilePathsList of stitch rule file paths
- returns: a PreviewResult object containing a map of Deployeds and it's invocation list with details about: input, output, diff, processors and errors
- parameters:
dryRunRuleDirectory(deployment, stitchDirectoryPath)- parameters:
deploymenta deployment objectstitchDirectoryPathA path to a directory containing stitch files
- returns: a PreviewResult object containing a map of Deployeds and it's invocation list with details about: input, output, diff, processors and errors
- parameters: