Skip to content

Commit

Permalink
add --approver flag to report approval
Browse files Browse the repository at this point in the history
  • Loading branch information
sami-alajrami committed Nov 14, 2023
1 parent 5540510 commit ff2c2fb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion cmd/kosli/reportApproval.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ kosli report approval FILE.tgz \
--description "An optional description for the approval" \
--newest-commit $(git rev-parse HEAD) \
--oldest-commit $(git rev-parse HEAD~5) \
--approver username \
--org yourOrgName \
--flow yourFlowName
Expand All @@ -34,6 +35,7 @@ kosli report approval \
--description "An optional description for the approval" \
--newest-commit $(git rev-parse HEAD) \
--oldest-commit $(git rev-parse HEAD~5) \
--approver username \
--org yourOrgName \
--flow yourFlowName \
--fingerprint yourArtifactFingerprint
Expand All @@ -47,6 +49,7 @@ type reportApprovalOptions struct {
srcRepoRoot string
userDataFile string
payload ApprovalPayload
approver string
}

type ApprovalPayload struct {
Expand Down Expand Up @@ -89,6 +92,7 @@ func newReportApprovalCmd(out io.Writer) *cobra.Command {
cmd.Flags().StringVar(&o.oldestSrcCommit, "oldest-commit", "", oldestCommitFlag)
cmd.Flags().StringVar(&o.newestSrcCommit, "newest-commit", "HEAD", newestCommitFlag)
cmd.Flags().StringVar(&o.srcRepoRoot, "repo-root", ".", repoRootFlag)
cmd.Flags().StringVar(&o.approver, "approver", "", approverFlag)
addFingerprintFlags(cmd, o.fingerprintOptions)
addDryRunFlag(cmd)

Expand Down Expand Up @@ -147,12 +151,16 @@ func (o *reportApprovalOptions) payloadArtifactSHA256(args []string) (string, er
}

func (o *reportApprovalOptions) payloadReviews(request bool) []map[string]string {
approver := "External"
if o.approver != "" {
approver = o.approver
}

Check warning on line 157 in cmd/kosli/reportApproval.go

View check run for this annotation

Codecov / codecov/patch

cmd/kosli/reportApproval.go#L156-L157

Added lines #L156 - L157 were not covered by tests
if !request {
return []map[string]string{
{
"state": "APPROVED",
"comment": o.payload.Description,
"approved_by": "External",
"approved_by": approver,
"approval_url": "undefined",
},
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/kosli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ The service principal needs to have the following permissions:
evidencePathsFlag = "[optional] The comma-separated list of paths containing supporting proof for the reported evidence. Paths can be for files or directories. All provided proofs will be uploaded to Kosli's evidence vault."
fingerprintFlag = "[conditional] The SHA256 fingerprint of the artifact. Only required if you don't specify '--artifact-type'."
evidenceCommitFlag = "The git commit SHA1 for which the evidence belongs. (defaulted in some CIs: https://docs.kosli.com/ci-defaults )."
intervalFlag = "[optional] Expression to define specified snapshots range"
intervalFlag = "[optional] Expression to define specified snapshots range."
showUnchangedArtifactsFlag = "[defaulted] Show the unchanged artifacts present in both snapshots within the diff output."
approverFlag = "[optional] The user approving an approval."
)

var global *GlobalOpts
Expand Down

0 comments on commit ff2c2fb

Please sign in to comment.