mirror of
https://github.com/actions/runner-images.git
synced 2025-12-12 12:06:59 +00:00
Implement Software Report Base Module (#6707)
* Implement first version * fix tables rendering * Fix scripts * update test files * implement calculate image diff script * Polish code and make e2e validation * remove test files * render add and removed firstly
This commit is contained in:
47
helpers/software-report-base/SoftwareReport.BaseNodes.psm1
Normal file
47
helpers/software-report-base/SoftwareReport.BaseNodes.psm1
Normal file
@@ -0,0 +1,47 @@
|
||||
############################
|
||||
### Abstract base nodes ####
|
||||
############################
|
||||
|
||||
# Abstract base class for all nodes
|
||||
class BaseNode {
|
||||
[Boolean] ShouldBeIncludedToDiff() {
|
||||
return $False
|
||||
}
|
||||
|
||||
[Boolean] IsSimilarTo([BaseNode] $OtherNode) {
|
||||
throw "Abtract method 'IsSimilarTo' is not implemented for '$($this.GetType().Name)'"
|
||||
}
|
||||
|
||||
[Boolean] IsIdenticalTo([BaseNode] $OtherNode) {
|
||||
throw "Abtract method 'IsIdenticalTo' is not implemented for '$($this.GetType().Name)'"
|
||||
}
|
||||
}
|
||||
|
||||
# Abstract base class for all nodes that describe a tool and should be rendered inside diff table
|
||||
class BaseToolNode: BaseNode {
|
||||
[String] $ToolName
|
||||
|
||||
BaseToolNode([String] $ToolName) {
|
||||
$this.ToolName = $ToolName
|
||||
}
|
||||
|
||||
[Boolean] ShouldBeIncludedToDiff() {
|
||||
return $True
|
||||
}
|
||||
|
||||
[String] GetValue() {
|
||||
throw "Abtract method 'GetValue' is not implemented for '$($this.GetType().Name)'"
|
||||
}
|
||||
|
||||
[Boolean] IsSimilarTo([BaseNode] $OtherNode) {
|
||||
if ($this.GetType() -ne $OtherNode.GetType()) {
|
||||
return $False
|
||||
}
|
||||
|
||||
return $this.ToolName -eq $OtherNode.ToolName
|
||||
}
|
||||
|
||||
[Boolean] IsIdenticalTo([BaseNode] $OtherNode) {
|
||||
return $this.IsSimilarTo($OtherNode) -and ($this.GetValue() -eq $OtherNode.GetValue())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user