-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcertdb.go
33 lines (27 loc) · 1.02 KB
/
certdb.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
30
31
32
33
package certdb
import (
"fmt"
"github.com/sirupsen/logrus"
"github.com/test-network-function/oct/pkg/certdb/offlinecheck"
"github.com/test-network-function/oct/pkg/certdb/onlinecheck"
"helm.sh/helm/v3/pkg/release"
)
type CertificationStatusValidator interface {
IsContainerCertified(registry, repository, tag, digest string) bool
IsOperatorCertified(csvName, ocpVersion, channel string) bool
IsHelmChartCertified(helm *release.Release, ourKubeVersion string) bool
}
func GetValidator(offlineDBPath string) (CertificationStatusValidator, error) {
// use the online certificator by default
onlineValidator := onlinecheck.NewOnlineValidator()
if onlineValidator.IsServiceReachable() {
return onlineValidator, nil
}
// use the offline DB for disconnected environments
logrus.Warnf("Online catalog not available. Testing with offline DB.")
err := offlinecheck.LoadCatalogs(offlineDBPath)
if err != nil {
return nil, fmt.Errorf("offline DB not available, err: %v", err)
}
return offlinecheck.OfflineValidator{}, nil
}