@@ -20,7 +20,7 @@ type createAttestationTypeOptions struct {
20
20
}
21
21
22
22
type CreateAttestationTypePayload struct {
23
- TypeName string
23
+ TypeName string `json:"type_name"`
24
24
}
25
25
26
26
func newCreateAttestationTypeCmd (out io.Writer ) * cobra.Command {
@@ -53,16 +53,41 @@ func (o *createAttestationTypeOptions) run(args []string) error {
53
53
o .payload .TypeName = args [0 ]
54
54
url := fmt .Sprintf ("%s/api/v2/custom-attestation-types/%s" , global .Host , global .Org )
55
55
56
+ form , err := prepareAttestationTypeForm (o .payload )
57
+ if err != nil {
58
+ return err
59
+ }
60
+
56
61
reqParams := & requests.RequestParams {
57
62
Method : http .MethodPost ,
58
63
URL : url ,
59
- Payload : o . payload ,
64
+ Form : form ,
60
65
DryRun : global .DryRun ,
61
66
Token : global .ApiToken ,
62
67
}
63
- _ , err : = kosliClient .Do (reqParams )
68
+ _ , err = kosliClient .Do (reqParams )
64
69
if err == nil && ! global .DryRun {
65
70
logger .Info ("foo bar fix me %s" , o .payload .TypeName )
66
71
}
67
72
return err
68
73
}
74
+
75
+ func prepareAttestationTypeForm (payload interface {}) ([]requests.FormItem , error ) {
76
+ form , err := newAttestationTypeForm (payload )
77
+ if err != nil {
78
+ return []requests.FormItem {}, err
79
+ }
80
+ return form , nil
81
+ }
82
+
83
+ // newAttestationTypeForm constructs a list of FormItems for an attestation-type
84
+ // form submission.
85
+ func newAttestationTypeForm (payload interface {}) (
86
+ []requests.FormItem , error ,
87
+ ) {
88
+ form := []requests.FormItem {
89
+ {Type : "field" , FieldName : "data_json" , Content : payload },
90
+ }
91
+
92
+ return form , nil
93
+ }
0 commit comments