-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathselinux.go
48 lines (39 loc) · 1.36 KB
/
selinux.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
package kubernetes
import (
"context"
"fmt"
"path/filepath"
"strings"
"github.com/suse-edge/edge-image-builder/pkg/http"
"github.com/suse-edge/edge-image-builder/pkg/image"
)
func SELinuxPackage(version string, sources *image.ArtifactSources) (string, error) {
switch {
case strings.Contains(version, image.KubernetesDistroK3S):
return sources.Kubernetes.K3s.SELinuxPackage, nil
case strings.Contains(version, image.KubernetesDistroRKE2):
return sources.Kubernetes.Rke2.SELinuxPackage, nil
default:
return "", fmt.Errorf("invalid kubernetes version: %s", version)
}
}
func SELinuxRepository(version string, sources *image.ArtifactSources) (image.AddRepo, error) {
var url string
switch {
case strings.Contains(version, image.KubernetesDistroK3S):
url = sources.Kubernetes.K3s.SELinuxRepository
case strings.Contains(version, image.KubernetesDistroRKE2):
url = sources.Kubernetes.Rke2.SELinuxRepository
default:
return image.AddRepo{}, fmt.Errorf("invalid kubernetes version: %s", version)
}
return image.AddRepo{
URL: url,
Unsigned: true,
}, nil
}
func DownloadSELinuxRPMsSigningKey(gpgKeysDir string) error {
const rancherSigningKeyURL = "https://rpm.rancher.io/public.key"
var signingKeyPath = filepath.Join(gpgKeysDir, "rancher-public.key")
return http.DownloadFile(context.Background(), rancherSigningKeyURL, signingKeyPath, nil)
}