Skip to content

ci: add utility functions for file management and RPMs#13154

Open
danudey wants to merge 5 commits into
projectcalico:masterfrom
danudey:add-utils-and-rpm-signing-master
Open

ci: add utility functions for file management and RPMs#13154
danudey wants to merge 5 commits into
projectcalico:masterfrom
danudey:add-utils-and-rpm-signing-master

Conversation

@danudey

@danudey danudey commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@danudey danudey requested a review from a team as a code owner July 7, 2026 19:27
Copilot AI review requested due to automatic review settings July 7, 2026 19:27
@danudey danudey added docs-not-required Docs not required for this change release-note-not-required Change has no user-facing impact labels Jul 7, 2026
@marvin-tigera marvin-tigera added this to the Calico v3.33.0 milestone Jul 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds new release tooling utilities under release/internal/utils to support (1) linking/copying directory trees with flexible inclusion filters and (2) signing + verifying RPMs using GPG/RPM tooling, along with unit/integration-style tests.

Changes:

  • Add RPM signing (rpmsign) and signature verification (rpmkeys --checksig) helpers in gpg.go.
  • Add directory/file helpers (LinkOrCopyDir, FindRecursiveFiles, Match* include-func builders, LinkOrCopyFile, PathExists) in files.go.
  • Add tests covering the new utilities.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
release/internal/utils/gpg.go Adds helpers to sign RPMs and validate RPM signatures using external tooling.
release/internal/utils/gpg_test.go Adds sandboxed tests that generate a temporary GPG key and validate RPM signing/verification behavior.
release/internal/utils/files.go Adds directory traversal + inclusion utilities, hardlink/copy fallback, and a path existence helper.
release/internal/utils/files_test.go Adds unit tests for file/directory utilities and include-function helpers.

Comment on lines +44 to +58
func SignRPMFiles(gpgKeyID string, rpmFiles []string) error {
logrus.Infof("Signing RPM files with GPG key %s", gpgKeyID)
cmdArgs := []string{
"-D", fmt.Sprintf("%%_openpgp_sign_id %s", gpgKeyID),
"--resign",
"--rpmv4",
}
cmdArgs = append(cmdArgs, rpmFiles...)
logrus.Debugf("Running rpmsign with args %s", strings.Join(cmdArgs, " "))
_, err := command.Run("rpmsign", cmdArgs)
if err != nil {
return fmt.Errorf("unable to sign RPM files: %w", err)
}
return nil
}
Comment on lines +68 to +81
rpmOut, err := command.Run("rpmkeys", cmdArgs)
if err != nil {
return fmt.Errorf("unable to check RPM signature: %w", err)
}
rpmOutFields := strings.Fields(rpmOut)
if len(rpmOutFields) == 0 {
return fmt.Errorf("rpmkeys --checksig returned no output")
}
if strings.Contains(rpmOut, "NOT OK") {
logrus.Errorf("RPM signature/digest check failed: %s", rpmOut)
return fmt.Errorf("RPM signature/digest check failed: %s", rpmOut)
}
return nil
}
Comment thread release/internal/utils/files.go
Comment on lines +114 to +130
err := filepath.WalkDir(srcDir, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d.IsDir() {
return nil
}
relPath, err := filepath.Rel(srcDir, path)
if err != nil {
return fmt.Errorf("failed to determine relative path for %s: %w", path, err)
}
if !include(srcDir, "", relPath) {
return nil
}
matches = append(matches, filepath.Join(srcDir, relPath))
return nil
})
Comment thread release/internal/utils/files.go
@danudey danudey enabled auto-merge July 7, 2026 19:31

@radTuti radTuti left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the copilot comment also deserve a looking

// RPM files. We use --rpmv4 here to ensure that, even on newer
// RPM versions, we're using backwards-compatible RPM signatures.
func SignRPMFiles(gpgKeyID string, rpmFiles []string) error {
logrus.Infof("Signing RPM files with GPG key %s", gpgKeyID)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what if rpmFIles is empty?

Suggested change
logrus.Infof("Signing RPM files with GPG key %s", gpgKeyID)
if len(rpmFiles) == 0 { return ... }
logrus.Infof("Signing RPM files with GPG key %s", gpgKeyID)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-not-required Docs not required for this change release-note-not-required Change has no user-facing impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants