MCPcopy
hub / github.com/koderover/zadig / ToScanningAdvancedSetting

Function ToScanningAdvancedSetting

pkg/tool/openapi/conversion.go:29–58  ·  view source on GitHub ↗
(arg *types.OpenAPIAdvancedSetting)

Source from the content-addressed store, hash-verified

27)
28
29func ToScanningAdvancedSetting(arg *types.OpenAPIAdvancedSetting) (*models.ScanningAdvancedSetting, error) {
30 cluster, err := commonrepo.NewK8SClusterColl().FindByName(arg.ClusterName)
31 if err != nil {
32 return nil, fmt.Errorf("failed to find cluster of name: %s, the error is: %s", arg.ClusterName, err)
33 }
34
35 strategy := &models.ScheduleStrategy{}
36 if cluster.AdvancedConfig != nil {
37 for _, s := range cluster.AdvancedConfig.ScheduleStrategy {
38 if s.StrategyName == arg.StrategyName {
39 strategy = s
40 break
41 }
42 }
43 }
44
45 // scanninghooks, err := ToScanningHookCtl(arg.Webhooks)
46 // if err != nil {
47 // return nil, err
48 // }
49
50 return &models.ScanningAdvancedSetting{
51 ClusterID: cluster.ID.Hex(),
52 StrategyID: strategy.StrategyID,
53 Timeout: arg.Timeout,
54 ResReq: arg.Spec.FindResourceRequestType(),
55 ResReqSpec: arg.Spec,
56 // HookCtl: scanninghooks,
57 }, nil
58}
59
60func ToScanningHookCtl(req *types.OpenAPIWebhookSetting) (*models.ScanningHookCtl, error) {
61 if req == nil || req.Enabled == false {

Callers

nothing calls this directly

Calls 3

FindByNameMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected