Skip to content

Commit 411b686

Browse files
author
Sami Alajrami
committed
Complete control deployment cmd
1 parent 143eb24 commit 411b686

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

cmd/reporter/controlDeployment.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"encoding/json"
45
"fmt"
56
"io"
67
"net/http"
@@ -45,9 +46,19 @@ func newControlDeploymentCmd(out io.Writer) *cobra.Command {
4546
if err != nil {
4647
return err
4748
}
48-
fmt.Println(response.Body)
4949

50-
return nil
50+
var approvals []map[string]interface{}
51+
err = json.Unmarshal([]byte(response.Body), &approvals)
52+
if err != nil {
53+
return err
54+
}
55+
56+
state, ok := approvals[len(approvals)-1]["state"].(string)
57+
if ok && state == "APPROVED" {
58+
log.Infof("artifact with sha256 %s is approved in approval no. [%d]", o.sha256, len(approvals))
59+
return nil
60+
}
61+
return fmt.Errorf("artifact with sha256 %s is not approved", o.sha256)
5162
},
5263
}
5364

0 commit comments

Comments
 (0)