mirror of
https://github.com/YuzuZensai/Minikura.git
synced 2026-09-13 10:49:21 +00:00
🐛 fix: override user env and complete proxy RBAC
This commit is contained in:
@@ -90,17 +90,29 @@ func JVMEnv(jvm v1alpha1.JVMOptions, limitMB int32) []corev1.EnvVar {
|
||||
}
|
||||
|
||||
func UserEnv(base []corev1.EnvVar, extra []v1alpha1.EnvVar) []corev1.EnvVar {
|
||||
index := make(map[string]int, len(base))
|
||||
for i, env := range base {
|
||||
index[env.Name] = i
|
||||
}
|
||||
for _, e := range extra {
|
||||
if i, ok := index[e.Name]; ok {
|
||||
base[i].Value = e.Value
|
||||
continue
|
||||
}
|
||||
index[e.Name] = len(base)
|
||||
base = append(base, corev1.EnvVar{Name: e.Name, Value: e.Value})
|
||||
}
|
||||
return base
|
||||
}
|
||||
|
||||
func TCPProbe(initialDelay int32) *corev1.Probe {
|
||||
func TCPProbe(initialDelay int32, port int32) *corev1.Probe {
|
||||
if port == 0 {
|
||||
port = ContainerPort
|
||||
}
|
||||
return &corev1.Probe{
|
||||
ProbeHandler: corev1.ProbeHandler{
|
||||
TCPSocket: &corev1.TCPSocketAction{
|
||||
Port: intstr.FromInt32(ContainerPort),
|
||||
Port: intstr.FromInt32(port),
|
||||
},
|
||||
},
|
||||
InitialDelaySeconds: initialDelay,
|
||||
|
||||
@@ -77,10 +77,10 @@ func TestUserEnvOverridesDefaults(t *testing.T) {
|
||||
base := []corev1.EnvVar{{Name: "TYPE", Value: "VANILLA"}}
|
||||
got := UserEnv(base, []v1alpha1.EnvVar{{Name: "TYPE", Value: "PAPER"}})
|
||||
|
||||
if len(got) != 2 {
|
||||
t.Fatalf("len = %d, want 2", len(got))
|
||||
if len(got) != 1 {
|
||||
t.Fatalf("len = %d, want 1", len(got))
|
||||
}
|
||||
if got[len(got)-1].Value != "PAPER" {
|
||||
t.Errorf("last TYPE = %q, want PAPER", got[len(got)-1].Value)
|
||||
if got[0].Value != "PAPER" {
|
||||
t.Errorf("TYPE = %q, want PAPER", got[0].Value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ func minecraftPodSpec(mc *v1alpha1.MinecraftServer, stateful bool) corev1.PodSpe
|
||||
}},
|
||||
Env: minecraftEnv(mc),
|
||||
VolumeMounts: mounts,
|
||||
ReadinessProbe: TCPProbe(initialDelay),
|
||||
ReadinessProbe: TCPProbe(initialDelay, ContainerPort),
|
||||
Resources: ResourceRequirements(mc.Spec.Resources),
|
||||
}},
|
||||
Volumes: volumes,
|
||||
|
||||
@@ -92,15 +92,7 @@ func ProxyDeployment(rp *v1alpha1.ReverseProxyServer) *appsv1.Deployment {
|
||||
VolumeMounts: []corev1.VolumeMount{
|
||||
{Name: "config", MountPath: "/config"},
|
||||
},
|
||||
ReadinessProbe: &corev1.Probe{
|
||||
ProbeHandler: corev1.ProbeHandler{
|
||||
TCPSocket: &corev1.TCPSocketAction{
|
||||
Port: intstr.FromInt32(rp.Spec.ListenPort),
|
||||
},
|
||||
},
|
||||
InitialDelaySeconds: 30,
|
||||
PeriodSeconds: 10,
|
||||
},
|
||||
ReadinessProbe: TCPProbe(30, rp.Spec.ListenPort),
|
||||
Resources: ResourceRequirements(rp.Spec.Resources),
|
||||
}},
|
||||
Volumes: []corev1.Volume{{
|
||||
|
||||
Reference in New Issue
Block a user