Repository navigation
refactor(get artifact, assert artifact): fetch through the Kosli API client - #1269
dangrondahl wants to merge 7 commits into
Conversation
33c5375 to
ff4a1ab
Compare
9fc2ea4 to
eb12fe0
Compare
|
Claude finished @dangrondahl's task in 2m 8s —— View job Follow-up review complete
Result: The one previous finding ( No new issues found in the fix commit itself. Note: |
eb12fe0 to
799d943
Compare
ff4a1ab to
2d1afdc
Compare
Follow-up review (commits eb12fe0..799d943)Previous finding — Verified by tracing the actual code path (couldn't run
I resolved the corresponding review thread. No new issues found in the fix commit (799d943) itself — the change is scoped to |
Stacked on #1249. This adds the Artifacts and Asserts endpoints to
internal/kosli, and movesget artifactandassert artifactonto them.internal/kosli/artifacts.goGetArtifactByFingerprint(ctx, flow, fingerprint, trail), which returns*Response[Artifact].ListArtifactsByCommitSHA(ctx, flow, commitSHA, trail), which returns*Response[[]Artifact].?trail=.cmdmoves here as the exportedArtifact, together withEnvironmentRefandArtifactEvent.internal/kosli/asserts.goaddsAssertArtifact(ctx, fingerprint, AssertArtifactFilter{Flow, Environment, Policies}). Assert has its own tag in the spec, so it gets its own file.client.gogetswithQuery, which appends a query string only when there is one.get artifactValue()and prints them. A fingerprint lookup becomes a one-element list, so the shim that wrapped a single object in[...]is gone.Artifacttype can't take fails only the table.TestGetArtifactPrintsJSONThatTheTableCannotDecodepins this down, usingcreated_at: "".assert artifactgoes throughkosliAPI().AssertArtifact.run(ctx, out, args).RunEpassescmd.Context().Why
AssertArtifactreturns the raw bodyReads normally return a typed
Response[T], which decodes only whenValue()is called.assert artifactis an exception for now. Its exit code, which CI gates on, deliberately decodes onlycompliant(#1246).TestAssertCompliantDependsOnlyOnCompliantpins that down: a malformedpolicy_evaluationsmust not fail a compliant artifact. Its result types stay incmdas the table printer's own view, so the client returns*Result. Because decoding is lazy, it can become aResponse[T]without risk once those types move.operationIds
These come from the published spec:
GetArtifactByFingerprintget_artifact_by_fingerprintListArtifactsByCommitSHAlist_artifacts_by_commit_shaAssertArtifactassert_artifactVerification
internal/koslihas 7 new httptest tests:json.Numbertrail_namedecodes as a non-nil pointerget artifactprinter tests now build typedkosli.Artifactvalues. The decoding cases they used to cover moved intointernal/kosli.go test -race ./internal/koslipasses, andmake lintis clean.get artifact: by fingerprint and by commit, with and without--trail, table and json, and a 404assert artifact: compliant and non-compliant, with--environment, with--flowand--policy p1,p2,-o json, and--dry-runGetArtifactCommandTestSuiteandAssertArtifactCommandTestSuite.Found, not fixed
When there are several artifacts,
printArtifactsAsTablewrites the separator between them withfmt.Print. That goes to stdout instead ofout. I left it alone so this PR doesn't change output, and it's listed for the later output slice.Checklist
Docs are autogenerated from CLI help — make sure the help text reflects your changes(no help text changes)Helm chart ((n/a)charts/k8s-reporter/) updated, if needed. Note: these changes live in a separate PRTerraform provider and related changes (terraform-provider-kosli, terraform-aws-evidence-reporter, terraform-aws-kosli-reporter) updated, if needed(n/a)