Skip to content

Conversation

olblak
Copy link
Member

@olblak olblak commented Apr 24, 2025

This pull request introduces a few changes around Pipeline report visualization.

  • Save each pipeline report locally on the disk in the directory "$TMPDIR/updatecli/report"
  • Add sanitized configuration to the report
  • Fix a bug where a resource report would be empty if it's skipped

Please note that pipeline report are saved in the following directory

/tmp/updatecli/report/<reportID>/<timestamp>.yaml

So running the same Updatecli pipeline multiple time will create multiple report in the directory

/tmp/updatecli/report/<reportID>/

Report Example
id: 38705491d468396f781fc2d6c22e3b6f25591e8c82f1af0d229e03f2b02fc515
pipelineid: e2e/dependsonchangeor
actions: {}
sources:
    "1":
        name: Should be succeeding
        result: ✔
        information: 1.2.3
        description: shell command executed successfully
        scm:
            url: ""
            branch:
                source: ""
                working: ""
                target: ""
            id: 91b8b7624574159cc04a5566f8abe32a2bf181144a5eeac8b0c60182fffe525c
            branchreset: false
        id: 0a5a087f22484d14fcbe2c32b9e64759f694ab720952ffc6379ef472726dd26c
        consoleoutput: "The shell \U0001F41A command \"/bin/sh /tmp/updatecli/bin/41225ee29857639e7d384e9f5add9b2042b4a732c3a2ab3971434ebcc288207f.sh\" ran successfully with the following output:\n----\n1.2.3\n----\n✔ shell command executed successfully\n"
        config:
            name: Should be succeeding
            kind: shell
            spec:
                command: echo 1.2.3
conditions:
    "1":
        name: Should be succeeding
        result: ✔
        pass: true
        description: shell condition of type "console/output", passing
        scm:
            url: ""
            branch:
                source: ""
                working: ""
                target: ""
            id: 91b8b7624574159cc04a5566f8abe32a2bf181144a5eeac8b0c60182fffe525c
            branchreset: false
        id: 477749c5c15e4168a86bbf4657dc0a629666540199125bc606a3e7c2c4179e52
        consoleoutput: "The shell \U0001F41A command \"/bin/sh /tmp/updatecli/bin/b5bea41b6c623f7c09f1bf24dcae58ebab3c0cdd90ad966bc43a45b44867e12b.sh\" ran successfully with the following output:\n----\n----\n✔ shell condition of type \"console/output\", passing\n"
        config:
            name: Should be succeeding
            kind: shell
            spec:
                command: "true"
        sourceid: ""
targets:
    "1":
        name: Should be succeeding
        dryrun: false
        result: ✔
        information: ""
        newinformation: ""
        description: ran shell command "true"
        files: []
        changed: false
        scm:
            url: ""
            branch:
                source: ""
                working: ""
                target: ""
            id: 91b8b7624574159cc04a5566f8abe32a2bf181144a5eeac8b0c60182fffe525c
            branchreset: false
        id: 651148204ef0b2da192da126db7024b52c0d2810dd7c71cbde708c144eb3c0dd
        consoleoutput: "\n**Dry Run enabled**\n\nThe shell \U0001F41A command \"/bin/sh /tmp/updatecli/bin/b5bea41b6c623f7c09f1bf24dcae58ebab3c0cdd90ad966bc43a45b44867e12b.sh\" ran successfully with the following output:\n----\n----\nNo change detected\n✔ - ran shell command \"true\"\n"
        changelogs: []
        config:
            name: Should be succeeding
            kind: shell
            spec:
                command: "true"
        sourceid: ""
    "2":
        name: Should be succeeding
        dryrun: false
        result: ✔
        information: ""
        newinformation: ""
        description: ran shell command "true"
        files: []
        changed: false
        scm:
            url: ""
            branch:
                source: ""
                working: ""
                target: ""
            id: 91b8b7624574159cc04a5566f8abe32a2bf181144a5eeac8b0c60182fffe525c
            branchreset: false
        id: 651148204ef0b2da192da126db7024b52c0d2810dd7c71cbde708c144eb3c0dd
        consoleoutput: "\n**Dry Run enabled**\n\nThe shell \U0001F41A command \"/bin/sh /tmp/updatecli/bin/b5bea41b6c623f7c09f1bf24dcae58ebab3c0cdd90ad966bc43a45b44867e12b.sh\" ran successfully with the following output:\n----\n----\nNo change detected\n✔ - ran shell command \"true\"\n"
        changelogs: []
        config:
            name: Should be succeeding
            kind: shell
            spec:
                command: "true"
        sourceid: ""
    "3":
        name: Should be skipped
        dryrun: false
        result: '-'
        information: ""
        newinformation: ""
        description: ""
        files: []
        changed: false
        scm:
            url: ""
            branch:
                source: ""
                working: ""
                target: ""
            id: 91b8b7624574159cc04a5566f8abe32a2bf181144a5eeac8b0c60182fffe525c
            branchreset: false
        id: a6dc821a3a2b692b144fe31b25ea9ee07a98101e5fc23ecda7550144a691ad79
        consoleoutput: ""
        changelogs: []
        config:
            dependson:
                - 1:or
                - 2:or
            name: Should be skipped
            kind: shell
            spec:
                command: echo 1.2.3
        sourceid: "1"
reporturl: ""
Console Output
Experimental Mode Enabled


+++++++++++
+ PREPARE +
+++++++++++

Loading Pipeline "e2e/updatecli.d/success.d/dependsonchangeor.yaml"
WARNING: Updatecli binary version is unset. This means you are using a development version that ignores manifest version constraint.

SCM repository retrieved: 0


++++++++++++++++++
+ AUTO DISCOVERY +
++++++++++++++++++



++++++++++++
+ PIPELINE +
++++++++++++



########################################
# SHOULD SOURCE IMPACT DEPENDSONCHANGE #
########################################

source: source#1
--------
The shell 🐚 command "/bin/sh /tmp/updatecli/bin/41225ee29857639e7d384e9f5add9b2042b4a732c3a2ab3971434ebcc288207f.sh" ran successfully with the following output:
----
1.2.3
----
✔ shell command executed successfully

condition: condition#1
-----------
The shell 🐚 command "/bin/sh /tmp/updatecli/bin/b5bea41b6c623f7c09f1bf24dcae58ebab3c0cdd90ad966bc43a45b44867e12b.sh" ran successfully with the following output:
----
----
✔ shell condition of type "console/output", passing

target: target#2
--------

**Dry Run enabled**

The shell 🐚 command "/bin/sh /tmp/updatecli/bin/b5bea41b6c623f7c09f1bf24dcae58ebab3c0cdd90ad966bc43a45b44867e12b.sh" ran successfully with the following output:
----
----
No change detected
✔ - ran shell command "true"

target: target#1
--------

**Dry Run enabled**

The shell 🐚 command "/bin/sh /tmp/updatecli/bin/b5bea41b6c623f7c09f1bf24dcae58ebab3c0cdd90ad966bc43a45b44867e12b.sh" ran successfully with the following output:
----
----
No change detected
✔ - ran shell command "true"

target: target#3
--------


ACTIONS
========



UDASH - EXPERIMENTAL
=====================

Publishing report to Udash
ERROR: publishing to Udash:
errors occurred while publishing to Udash:
	* Should Source impact dependsonchangePost "http://testudash/api/pipeline/reports": dial tcp 172.19.0.3:80: connect: no route to host


REPORT - EXPERIMENTAL
======================

Should Source impact dependsonchange:
	=> "/tmp/updatecli/report/38705491d468396f781fc2d6c22e3b6f25591e8c82f1af0d229e03f2b02fc515/20250404164419.yaml"

=============================

SUMMARY:



✔ Should Source impact dependsonchange:
	Source:
		✔ [1] Should be succeeding
	Condition:
		✔ [1] Should be succeeding
	Target:
		✔ [1] Should be succeeding
		✔ [2] Should be succeeding
		- [3] Should be skipped


Run Summary
===========
Pipeline(s) run:
  * Changed:	0
  * Failed:	0
  * Skipped:	0
  * Succeeded:	1
  * Total:	1

Test

To test this pull request, you can run the following commands:

go build -o bin/updatecli .
./bin/updatecli diff --config e2e/updatecli.d/success.d/dependsonchangeor.yaml --experimental

A report should be available in /tmp/updatecli/report/38705491d468396f781fc2d6c22e3b6f25591e8c82f1af0d229e03f2b02fc515/

Additional Information

Checklist

  • I have updated the documentation via pull request in website repository.

Tradeoff

Only resource spec are sanitized, so parameters like kind or transformers are passed directly to the report.
Considering that report is publicly available, that could be an issue in the future, but I don't think we'll store secret information there.

Another option would be to restrict even more parameters shared with the report

Regarding the new plugin interface method, I hesitated for a long time between using this approach versus using custom tag in the yaml marshaller but due to early design decision made in Updatecli, resource spec are of type interface{} which would require some refactoring first.

Potential improvement

  • For now the report are generated in yaml file, we could support other file format in the futur
  • The directory where reports are publish is hardcoded for now, we could provide a parameter to override this

@olblak olblak added enhancement New feature or request core All things related to Updatecli core engine labels Apr 24, 2025
@olblak olblak changed the title Feat/localreport feat: export pipeline report to disk Apr 24, 2025
dduportal
dduportal previously approved these changes Apr 27, 2025
@olblak olblak enabled auto-merge (squash) April 29, 2025 10:02
@olblak olblak requested a review from Copilot April 29, 2025 14:35
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements the functionality to export pipeline reports to disk while sanitizing resource configurations and updating report IDs for consistency. Key changes include:

  • Introducing ReportConfig methods in resource plugins to filter sensitive data.
  • Adding functions to initialize and export reports in YAML format.
  • Updating report generation in core pipeline and engine to incorporate the sanitized configuration and sorted hash generation.

Reviewed Changes

Copilot reviewed 53 out of 53 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/plugins/resources/* Added ReportConfig methods for dockerfile, dockerdigest, csv, cargopackage, and awsami to expose a sanitized configuration.
pkg/core/udash/publish.go Removed the inline UpdateID call, deferring report ID updates to a later stage.
pkg/core/tmp/main.go Introduced ReportDirectory and InitReport function to manage local report storage.
pkg/core/result/* Updated Source, Condition, and Target structs to include Config and SourceID fields.
pkg/core/reports/report.go Updated UpdateID to generate consistent report IDs using sorted keys; added additional logic if no configuration is available.
pkg/core/reports/export.go Added a new function to export reports to YAML files with timestamp-based filenames.
pkg/core/pipeline/* and pkg/core/engine/* Adjusted functions to update report configurations during pipeline execution and integrated report export in the engine run flow.
pkg/core/engine/exportReport.go Added a new export function to log and handle report YAML exports under experimental mode.
Comments suppressed due to low confidence (1)

pkg/core/engine/exportReport.go:26

  • [nitpick] Concatenating 'pipeline.Name' and 'err.Error()' directly without a clear separator could result in unclear error messages. Consider using a formatted string to clearly separate the pipeline name from the error message.
errs = append(errs, pipeline.Name+err.Error())

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request enhances the Updatecli report functionality by exporting pipeline reports to disk with a sanitized configuration and improving report consistency. Key changes include:

  • Implementation of ReportConfig methods in various resource plugins to remove sensitive data.
  • Addition of a YAML report export feature with new temporary directory initialization.
  • Updates to the report ID generation logic and cleanup of report updates in the pipeline.

Reviewed Changes

Copilot reviewed 53 out of 53 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/plugins/resources/dockerfile/main.go Added ReportConfig method for sanitized Dockerfile configuration
pkg/plugins/resources/dockerdigest/main.go Added ReportConfig method for DockerDigest
pkg/plugins/resources/csv/main.go Added ReportConfig method for CSV resources
pkg/plugins/resources/cargopackage/main.go Added ReportConfig method for CargoPackage
pkg/plugins/resources/awsami/main.go Added ReportConfig method for AWS AMI
pkg/core/udash/publish.go Removed redundant UpdateID call
pkg/core/tmp/main.go Introduced ReportDirectory and InitReport function
pkg/core/result/* Added Config (and SourceID for Target and Condition) fields to report models
pkg/core/reports/report.go Revised UpdateID logic with sorted map keys and enhanced hash generation
pkg/core/reports/export.go New export to YAML feature
pkg/core/pipeline/* Updated report updates in sources, conditions, targets, and resource configuration
pkg/core/engine/{run.go,exportReport.go} Updated engine run flow to update report IDs and export reports after execution
pkg/core/pipeline/sources_test.go Extended tests to cover scenarios with skipped and warning sources
Comments suppressed due to low confidence (1)

pkg/core/engine/exportReport.go:26

  • [nitpick] Consider adding a separator between the pipeline name and the error message (for example, using ' - ') to improve readability of the combined error string.
errs = append(errs, pipeline.Name+err.Error())

@olblak olblak merged commit 380e68d into updatecli:main May 1, 2025
6 checks passed
@olblak olblak changed the title feat: export pipeline report to disk feat: export pipeline report to disk [experimental] May 2, 2025
@olblak olblak deleted the feat/localreport branch May 5, 2025 06:07
@olblak olblak changed the title feat: export pipeline report to disk [experimental] feat(core): export pipeline report to disk [experimental] May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core All things related to Updatecli core engine enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants