From ff2c2fb36f45cd5d70a5ea00895c891e1abd1092 Mon Sep 17 00:00:00 2001 From: Sami Alajrami Date: Tue, 14 Nov 2023 08:35:40 +0100 Subject: [PATCH] add --approver flag to report approval --- cmd/kosli/reportApproval.go | 10 +++++++++- cmd/kosli/root.go | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/kosli/reportApproval.go b/cmd/kosli/reportApproval.go index 73fd185b1..8398f0d5f 100644 --- a/cmd/kosli/reportApproval.go +++ b/cmd/kosli/reportApproval.go @@ -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 @@ -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 @@ -47,6 +49,7 @@ type reportApprovalOptions struct { srcRepoRoot string userDataFile string payload ApprovalPayload + approver string } type ApprovalPayload struct { @@ -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) @@ -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 + } if !request { return []map[string]string{ { "state": "APPROVED", "comment": o.payload.Description, - "approved_by": "External", + "approved_by": approver, "approval_url": "undefined", }, } diff --git a/cmd/kosli/root.go b/cmd/kosli/root.go index f669355ef..fef78c944 100644 --- a/cmd/kosli/root.go +++ b/cmd/kosli/root.go @@ -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