Skip to content

Commit

Permalink
per-challenge pow (#276)
Browse files Browse the repository at this point in the history
* per-challenge pow

* Automated commit: update images.
  • Loading branch information
sroettger authored Mar 29, 2021
1 parent f577173 commit 4a06c8e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dist/resources/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
serviceAccountName: kctf-operator
containers:
- name: kctf-operator
image: gcr.io/kctf-docker/kctf-operator@sha256:f16c645a40d31aa72fd21c21c60d4b8ae517338575455310368239361f77804e
image: gcr.io/kctf-docker/kctf-operator@sha256:d9cebd766fbdbe898add623a2b3dc1c2574096d64d3b8d88bfd04a75378aea63
command:
- kctf-operator
imagePullPolicy: Always
Expand Down
16 changes: 9 additions & 7 deletions kctf-operator/pkg/controller/challenge/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,18 @@ func deployment(challenge *kctfv1.Challenge) *appsv1.Deployment {
},
}

volumeMounts := []corev1.VolumeMount{{
Name: "pow",
ReadOnly: true,
MountPath: "/kctf/pow",
},
volumeMounts := []corev1.VolumeMount{
{
Name: "pow",
ReadOnly: true,
MountPath: "/kctf/pow",
},
{
Name: "pow-bypass-pub",
ReadOnly: true,
MountPath: "/kctf/pow-bypass",
}}
},
}

deployment.Spec.Template.Spec.Containers[idx_challenge].VolumeMounts =
append(deployment.Spec.Template.Spec.Containers[idx_challenge].VolumeMounts, volumeMounts...)
Expand All @@ -98,7 +100,7 @@ func deployment(challenge *kctfv1.Challenge) *appsv1.Deployment {
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{
Name: "pow",
Name: challenge.Name + "-pow",
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion kctf-operator/pkg/controller/challenge/pow/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func generate(challenge *kctfv1.Challenge) *corev1.ConfigMap {
}
configmap := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "pow",
Name: challenge.Name + "-pow",
Namespace: challenge.Namespace,
},
Data: data,
Expand Down
4 changes: 2 additions & 2 deletions kctf-operator/pkg/controller/challenge/pow/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func create(challenge *kctfv1.Challenge, client client.Client, scheme *runtime.S
func Update(challenge *kctfv1.Challenge, cl client.Client, scheme *runtime.Scheme,
log logr.Logger, ctx context.Context) (bool, error) {
configmapFound := &corev1.ConfigMap{}
err := cl.Get(ctx, types.NamespacedName{Name: "pow",
err := cl.Get(ctx, types.NamespacedName{Name: challenge.Name + "-pow",
Namespace: challenge.Namespace}, configmapFound)

// Just enters here if it's a new configmap
Expand All @@ -55,7 +55,7 @@ func Update(challenge *kctfv1.Challenge, cl client.Client, scheme *runtime.Schem

} else if err != nil {
log.Error(err, "Couldn't get the ConfigMap of Proof of work", "Configmap Name: ",
"pow", " with namespace ", challenge.Namespace)
challenge.Name + "-pow", " with namespace ", challenge.Namespace)
return false, err
}

Expand Down

0 comments on commit 4a06c8e

Please sign in to comment.