Skip to content

Commit 557e12d

Browse files
committed
Add description flag to custom attestation creation command
1 parent 11242c4 commit 557e12d

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

cmd/kosli/createAttestationType.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ type createAttestationTypeOptions struct {
2020
}
2121

2222
type CreateAttestationTypePayload struct {
23-
TypeName string `json:"type_name"`
23+
TypeName string `json:"name"`
24+
Description string `json:"description"`
2425
}
2526

2627
func newCreateAttestationTypeCmd(out io.Writer) *cobra.Command {
@@ -43,7 +44,7 @@ func newCreateAttestationTypeCmd(out io.Writer) *cobra.Command {
4344
},
4445
}
4546

46-
//cmd.Flags().StringVarP(&o.payload.Description, "description", "d", "", envDescriptionFlag)
47+
cmd.Flags().StringVarP(&o.payload.Description, "description", "d", "", attestationTypeDescriptionFlag)
4748

4849
addDryRunFlag(cmd)
4950
return cmd
@@ -59,15 +60,15 @@ func (o *createAttestationTypeOptions) run(args []string) error {
5960
}
6061

6162
reqParams := &requests.RequestParams{
62-
Method: http.MethodPost,
63-
URL: url,
63+
Method: http.MethodPost,
64+
URL: url,
6465
Form: form,
65-
DryRun: global.DryRun,
66-
Token: global.ApiToken,
66+
DryRun: global.DryRun,
67+
Token: global.ApiToken,
6768
}
6869
_, err = kosliClient.Do(reqParams)
6970
if err == nil && !global.DryRun {
70-
logger.Info("foo bar fix me %s", o.payload.TypeName)
71+
logger.Info("attestation-type %s was created", o.payload.TypeName)
7172
}
7273
return err
7374
}

cmd/kosli/createAttestationType_test.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,19 @@ func (suite *CreateAttestationTypeTestSuite) TestCustomAttestationTypeCmd() {
2828
tests := []cmdTestCase{
2929
{
3030
wantError: true,
31-
name: "fails when more arguments are provided",
31+
name: "fails when no arguments are provided",
3232
cmd: "create attestation-type" + suite.defaultKosliArguments,
3333
golden: "Error: accepts 1 arg(s), received 0\n",
3434
},
3535
{
36-
name: "type name is provided",
37-
cmd: "create attestation-type wibble" + suite.defaultKosliArguments,
38-
golden: "attestation-type wibble was created\n",
36+
name: "type name is provided",
37+
cmd: "create attestation-type wibble" + suite.defaultKosliArguments,
38+
golden: "attestation-type wibble was created\n",
39+
},
40+
{
41+
name: "type description is provided",
42+
cmd: "create attestation-type wibble-2 -d 'description of attestation type'" + suite.defaultKosliArguments,
43+
golden: "attestation-type wibble-2 was created\n",
3944
},
4045
}
4146

cmd/kosli/root.go

+1
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ The ^.kosli_ignore^ will be treated as part of the artifact like any other file,
237237
sonarRevisionFlag = "[conditional] The revision of the SonarCloud/SonarQube project. Only required if you want to use the project key/revision to get the scan results rather than using Sonar's metadata file and you have overridden the default revision, or you aren't using a CI. Defaults to the value of the git commit flag."
238238
logicalEnvFlag = "[required] The logical environment."
239239
physicalEnvFlag = "[required] The physical environment."
240+
attestationTypeDescriptionFlag = "[optional] The attestation type description."
240241
)
241242

242243
var global *GlobalOpts

0 commit comments

Comments
 (0)