Skip to content

refactor(attest): read explicit repo flags from the flag set - #1421

Open
mbevc1 wants to merge 2 commits into
20261127_attest-no-commit-infofrom
20261127_attest-explicit-repo-flags
Open

mbevc1 wants to merge 2 commits into
20261127_attest-no-commit-infofrom
20261127_attest-explicit-repo-flags

Conversation

@mbevc1

@mbevc1 mbevc1 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Removes the hand-wired repoURLExplicit and repoNameExplicit fields from CommonAttestationOptions. The shared run now asks the flag set it already holds, through the explicit() helper added in #1420.

Each of the 13 attest commands had to set the two fields in its RunE before calling run. A command that forgot would silently treat --repository and --repo-url as defaulted from CI. This follows up a suggestion in the review of #1420.

Stacked on #1420: the base branch is 20261127_attest-no-commit-info, which holds the helper. Review and merge that PR first.

  • No behaviour change. cmd.Flags().Changed(...) is evaluated at the same point as before, on the same flag set.
  • Not touched: attest artifact and begin trail keep their own repoNameExplicit. Their option structs do not embed CommonAttestationOptions.
  • Test: the repo-info wiring suite gains a case for an explicit --repo-url being validated. This change moved that read, and no dry-run test covered it. The case fails when the read is broken.

Checklist

  • Docs are autogenerated from CLI help — make sure the help text reflects your changes (no help text changes)
  • Helm chart (charts/k8s-reporter/) updated, if needed. Note: these changes live in a separate PR (not needed)
  • Terraform provider and related changes (terraform-provider-kosli, terraform-aws-kosli-reporter) updated, if needed (not needed)

@mbevc1
mbevc1 force-pushed the 20261127_attest-explicit-repo-flags branch from 37cc5a2 to 9e9e808 Compare November 27, 2026 22:22
@github-actions github-actions Bot added go Pull requests that update go code refactor labels Nov 27, 2026
@claude

claude Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @mbevc1's task in 1m 21s —— View job


Review of new commits (c1d86662, 8975d3b7)

  • Fetch existing review comments/findings
  • Diff BEFORE..AFTER and check each prior finding's status
  • Check new commits for bugs/regressions in changed lines
  • Post summary comment

Previous findings: None — this is the first automated review pass on this PR (no prior Claude review or inline comments exist).

New commits reviewed:

  • c1d86662 removes repoURLExplicit/repoNameExplicit from CommonAttestationOptions and the per-command RunE lines that set them, replacing both call sites in attestation.go's run() with o.explicit("repo-url") / o.explicit("repository").
  • 8975d3b7 renames/extends the wiring test with a new wantError case for an invalid --repo-url that fails validation without needing the test server.

Verification performed:

  • Confirmed o.flags is assigned once at construction time via addAttestationFlags (cmd/kosli/flags.go:98), and all 13 touched command files (attestCustom, attestDecision, attestGeneric, attestJira, attestJunit, attestOverride, attestPRAzure, attestPRBitbucket, attestPRGithub, attestPRGitlab, attestSbom, attestSnyk, attestSonar) call it, so o.flags.Changed(...) is evaluated against the same parsed flag set as before — no behaviour change.
  • Confirmed attest artifact and begin trail correctly retain their own repoNameExplicit field (they don't embed CommonAttestationOptions), and no stray references to the removed fields remain anywhere else in cmd/kosli/.
  • The new test case in repoInfoWiring_test.go exercises exactly the line that moved (validateRepoFlags(..., o.explicit("repo-url"))), and is correctly scoped as a no-server-needed guard (validation runs before any API call).

No bugs, regressions, or security issues found in the changed lines. No new inline comments were needed.
(branch)

@mbevc1 mbevc1 closed this Nov 27, 2026
@mbevc1 mbevc1 reopened this Nov 27, 2026
@mbevc1
mbevc1 marked this pull request as ready for review November 27, 2026 22:35
@mbevc1
mbevc1 force-pushed the 20261127_attest-explicit-repo-flags branch from 38ef228 to 095f27e Compare November 27, 2026 22:35
CommonAttestationOptions kept repoURLExplicit and repoNameExplicit,
which each of the 13 attest commands had to set by hand in its RunE
before calling run. A command that forgot would silently treat
--repository and --repo-url as defaulted. run already holds the flag
set, so it now asks it directly through explicit(), as the
--no-commit-info path does.

No behaviour changes. attest artifact and begin trail keep their own
repoNameExplicit: they do not embed CommonAttestationOptions.

The wiring suite gains a case for an explicit --repo-url being
validated, the read this change moved that no dry-run test covered.
The server-backed suites already test an invalid --repo-url. This case
exists because it runs in dry-run mode, which its name now says.

This branch has not been deployed

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

Labels

go Pull requests that update go code refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant