-
Notifications
You must be signed in to change notification settings - Fork 297
/
imagecontentsource.go
44 lines (39 loc) · 1.42 KB
/
imagecontentsource.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
package globalconfig
import (
operatorv1alpha1 "github.com/openshift/api/operator/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
hyperv1 "github.com/openshift/hypershift/api/v1beta1"
)
func ImageContentSourcePolicy() *operatorv1alpha1.ImageContentSourcePolicy {
return &operatorv1alpha1.ImageContentSourcePolicy{
TypeMeta: metav1.TypeMeta{
Kind: "ImageContentSourcePolicy",
APIVersion: operatorv1alpha1.GroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: "cluster",
},
}
}
func ImageContentSourcePolicyList() *operatorv1alpha1.ImageContentSourcePolicyList {
return &operatorv1alpha1.ImageContentSourcePolicyList{
TypeMeta: metav1.TypeMeta{
Kind: "ImageContentSourcePolicyList",
APIVersion: operatorv1alpha1.GroupVersion.String(),
},
}
}
func ReconcileImageContentSourcePolicy(icsp *operatorv1alpha1.ImageContentSourcePolicy, hcp *hyperv1.HostedControlPlane) error {
if icsp.Labels == nil {
icsp.Labels = map[string]string{}
}
icsp.Labels["machineconfiguration.openshift.io/role"] = "worker"
icsp.Spec.RepositoryDigestMirrors = []operatorv1alpha1.RepositoryDigestMirrors{}
for _, imageContentSourceEntry := range hcp.Spec.ImageContentSources {
icsp.Spec.RepositoryDigestMirrors = append(icsp.Spec.RepositoryDigestMirrors, operatorv1alpha1.RepositoryDigestMirrors{
Source: imageContentSourceEntry.Source,
Mirrors: imageContentSourceEntry.Mirrors,
})
}
return nil
}