Skip to content

Add serializd tuf root E2E test - #39

Merged
JasonPowr merged 1 commit into
mainfrom
e2e-test-serialized-tuf-root
Jul 21, 2025
Merged

Add serializd tuf root E2E test#39
JasonPowr merged 1 commit into
mainfrom
e2e-test-serialized-tuf-root

Conversation

@JasonPowr

@JasonPowr JasonPowr commented Jul 21, 2025

Copy link
Copy Markdown
Member

Summary by Sourcery

Add end-to-end test and supporting utilities for installing a serialized TUF root with the policy-controller-operator

New Features:

  • Introduce TufMirrorFS and helper functions to mirror and serialize TUF metadata and targets into a tar.gz filesystem
  • Add custom resource templates for PolicyController, TrustRoot, and ClusterImagePolicy to exercise serialized TUF root installation
  • Implement an E2E test (serialized_tuf_root_install_test.go) that deploys the operator, renders and applies the serialized TUF root and cluster image policy, and exercises CA injection, webhook enforcement, image signing, provenance, and SBOM flows

Build:

  • Add go-tuf/v2 dependency and bump various indirect module versions in go.mod and go.sum

Tests:

  • Add Ginkgo/Gomega-based E2E tests to validate serialized TUF root installation and related admission webhooks

@sourcery-ai

sourcery-ai Bot commented Jul 21, 2025

Copy link
Copy Markdown

Reviewer's Guide

This PR introduces an end-to-end test for installing a serialized TUF root, extending the test utilities to mirror and package a TUF repository, updating module dependencies, and adding CR templates and a test suite for serialized root installation.

Class diagram for new E2E serialized TUF root test utilities

classDiagram
    class RhtasUtils {
        +MirrorTUFRepo()
        +PackageTUFRepo()
        ...
    }
    class SerializedTUFRootInstallTest {
        +TestInstallSerializedTUFRoot()
        ...
    }
    RhtasUtils <.. SerializedTUFRootInstallTest : uses
Loading

File-Level Changes

Change Details Files
Extend e2e utilities to mirror, package, and serialize a TUF repository
  • Add TufMirrorFS, tarDir, writeVersionedMetadataFile functions
  • Use go-tuf updater to fetch targets and metadata
  • Gzip and tar the mirrored repository directory
test/e2e/utils/rhtas.go
Add serialized TUF root end-to-end test and associated CR templates
  • Introduce serialized_tuf_root_install_test.go with test cases for TrustRoot and ClusterImagePolicy
  • Create policy_controller, trust_root, and cluster_image_policy YAML templates
  • Render and apply manifests in tests to verify resource injection
test/e2e/serialized_tuf_root_install_test.go
test/e2e/custom_resources/serialized_tuf_root/cluster_image_policy.yaml.tpl
test/e2e/custom_resources/serialized_tuf_root/policy_controller.yaml.tpl
test/e2e/custom_resources/serialized_tuf_root/trust_root.yaml.tpl
Bump go-tuf dependency and update indirect module versions
  • Add github.com/theupdateframework/go-tuf/v2 requirement
  • Update several golang.org/x and google.golang.org module versions
  • Regenerate go.sum accordingly
go.mod
go.sum

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey @JasonPowr - I've reviewed your changes - here's some feedback:

  • In tarDir you defer gw.Close() and tw.Close() but never check their returned errors—capture and return those Close() errors to avoid hiding I/O failures when writing the tarball.
  • os.MkdirTemp is invoked with "." which creates temp dirs in the repo root—pass an empty string ("" as the first arg) to use the system temp directory and avoid polluting your working tree.
  • TufMirrorFS buffers the entire gzipped tar in memory before returning—consider streaming to a file or using an io.Pipe to reduce peak memory usage for large repositories.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In tarDir you defer gw.Close() and tw.Close() but never check their returned errors—capture and return those Close() errors to avoid hiding I/O failures when writing the tarball.
- os.MkdirTemp is invoked with "." which creates temp dirs in the repo root—pass an empty string ("" as the first arg) to use the system temp directory and avoid polluting your working tree.
- TufMirrorFS buffers the entire gzipped tar in memory before returning—consider streaming to a file or using an io.Pipe to reduce peak memory usage for large repositories.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@JasonPowr
JasonPowr merged commit 08a586a into main Jul 21, 2025
4 checks passed
@JasonPowr
JasonPowr deleted the e2e-test-serialized-tuf-root branch July 21, 2025 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants