-
Notifications
You must be signed in to change notification settings - Fork 107
/
storage.go
99 lines (83 loc) · 3.17 KB
/
storage.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package harbor
import (
"context"
goharborv1 "github.com/goharbor/harbor-operator/apis/goharbor.io/v1alpha3"
corev1 "k8s.io/api/core/v1"
)
func (r *Reconciler) ChartMuseumStorage(ctx context.Context, harbor *goharborv1.Harbor) goharborv1.ChartMuseumChartStorageDriverSpec {
if harbor.Spec.ImageChartStorage.S3 != nil {
return goharborv1.ChartMuseumChartStorageDriverSpec{
Amazon: harbor.Spec.ImageChartStorage.S3.ChartMuseum(),
}
}
if harbor.Spec.ImageChartStorage.Swift != nil {
return goharborv1.ChartMuseumChartStorageDriverSpec{
OpenStack: harbor.Spec.ImageChartStorage.Swift.ChartMuseum(),
}
}
prefix := ""
pvc := &harbor.Spec.ImageChartStorage.FileSystem.RegistryPersistentVolume.PersistentVolumeClaimVolumeSource
if harbor.Spec.ImageChartStorage.FileSystem.ChartPersistentVolume != nil {
pvc = &harbor.Spec.ImageChartStorage.FileSystem.ChartPersistentVolume.PersistentVolumeClaimVolumeSource
prefix = harbor.Spec.ImageChartStorage.FileSystem.ChartPersistentVolume.Prefix
}
return goharborv1.ChartMuseumChartStorageDriverSpec{
FileSystem: &goharborv1.ChartMuseumChartStorageDriverFilesystemSpec{
VolumeSource: corev1.VolumeSource{
PersistentVolumeClaim: pvc,
},
Prefix: prefix,
},
}
}
func (r *Reconciler) TrivyReportsStorage(ctx context.Context, harbor *goharborv1.Harbor) goharborv1.TrivyStorageVolumeSpec {
if harbor.Spec.Trivy.Storage.ReportsPersistentVolume != nil {
pvc := &harbor.Spec.Trivy.Storage.ReportsPersistentVolume.PersistentVolumeClaimVolumeSource
return goharborv1.TrivyStorageVolumeSpec{
VolumeSource: corev1.VolumeSource{
PersistentVolumeClaim: pvc,
},
}
}
return goharborv1.TrivyStorageVolumeSpec{
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{},
},
}
}
func (r *Reconciler) TrivyCacheStorage(ctx context.Context, harbor *goharborv1.Harbor) goharborv1.TrivyStorageVolumeSpec {
if harbor.Spec.Trivy.Storage.CachePersistentVolume != nil {
pvc := &harbor.Spec.Trivy.Storage.CachePersistentVolume.PersistentVolumeClaimVolumeSource
return goharborv1.TrivyStorageVolumeSpec{
VolumeSource: corev1.VolumeSource{
PersistentVolumeClaim: pvc,
},
}
}
return goharborv1.TrivyStorageVolumeSpec{
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{},
},
}
}
func (r *Reconciler) RegistryStorage(ctx context.Context, harbor *goharborv1.Harbor) goharborv1.RegistryStorageDriverSpec {
if harbor.Spec.ImageChartStorage.S3 != nil {
return goharborv1.RegistryStorageDriverSpec{
S3: harbor.Spec.ImageChartStorage.S3.Registry(),
}
}
if harbor.Spec.ImageChartStorage.Swift != nil {
return goharborv1.RegistryStorageDriverSpec{
Swift: harbor.Spec.ImageChartStorage.Swift.Registry(),
}
}
return goharborv1.RegistryStorageDriverSpec{
FileSystem: &goharborv1.RegistryStorageDriverFilesystemSpec{
VolumeSource: corev1.VolumeSource{
PersistentVolumeClaim: &harbor.Spec.ImageChartStorage.FileSystem.RegistryPersistentVolume.PersistentVolumeClaimVolumeSource,
},
MaxThreads: harbor.Spec.ImageChartStorage.FileSystem.RegistryPersistentVolume.MaxThreads,
Prefix: harbor.Spec.ImageChartStorage.FileSystem.RegistryPersistentVolume.Prefix,
},
}
}