-
Notifications
You must be signed in to change notification settings - Fork 14
/
scanner.go
29 lines (20 loc) · 905 Bytes
/
scanner.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package module
import (
operation "github.com/goharbor/xk6-harbor/pkg/harbor/client/scanner"
"github.com/goharbor/xk6-harbor/pkg/harbor/models"
)
func (h *Harbor) CreateScanner(registration models.ScannerRegistrationReq) string {
h.mustInitialized()
params := operation.NewCreateScannerParams().WithRegistration(®istration)
res, err := h.api.Scanner.CreateScanner(h.vu.Context(), params)
Checkf(h.vu.Runtime(), err, "failed to create scanner %s", *registration.Name)
return NameFromLocation(res.Location)
}
func (h *Harbor) SetScannerAsDefault(registrationID string) {
h.mustInitialized()
params := operation.NewSetScannerAsDefaultParams().
WithRegistrationID(registrationID).
WithPayload(&models.IsDefault{IsDefault: true})
_, err := h.api.Scanner.SetScannerAsDefault(h.vu.Context(), params)
Checkf(h.vu.Runtime(), err, "failed to set scanner %s as default", registrationID)
}