mirror of
https://github.com/kairos-io/kcrypt-challenger.git
synced 2025-04-27 11:30:52 +00:00
Slightly change spec
This commit is contained in:
parent
7c6fa7df06
commit
673bfcbd56
@ -25,10 +25,9 @@ import (
|
|||||||
|
|
||||||
// SealedVolumeSpec defines the desired state of SealedVolume
|
// SealedVolumeSpec defines the desired state of SealedVolume
|
||||||
type SealedVolumeSpec struct {
|
type SealedVolumeSpec struct {
|
||||||
TPMHash string `json:"TPMHash,omitempty"`
|
TPMHash string `json:"TPMHash,omitempty"`
|
||||||
Label string `json:"label,omitempty"`
|
Passphrase map[string]*SecretSpec `json:"partitionSecrets,omitempty"`
|
||||||
Passphrase *SecretSpec `json:"passphraseRef,omitempty"`
|
Quarantined bool `json:"quarantined,omitempty"`
|
||||||
Quarantined bool `json:"quarantined,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type SecretSpec struct {
|
type SecretSpec struct {
|
||||||
|
@ -89,8 +89,18 @@ func (in *SealedVolumeSpec) DeepCopyInto(out *SealedVolumeSpec) {
|
|||||||
*out = *in
|
*out = *in
|
||||||
if in.Passphrase != nil {
|
if in.Passphrase != nil {
|
||||||
in, out := &in.Passphrase, &out.Passphrase
|
in, out := &in.Passphrase, &out.Passphrase
|
||||||
*out = new(SecretSpec)
|
*out = make(map[string]*SecretSpec, len(*in))
|
||||||
**out = **in
|
for key, val := range *in {
|
||||||
|
var outVal *SecretSpec
|
||||||
|
if val == nil {
|
||||||
|
(*out)[key] = nil
|
||||||
|
} else {
|
||||||
|
in, out := &val, &outVal
|
||||||
|
*out = new(SecretSpec)
|
||||||
|
**out = **in
|
||||||
|
}
|
||||||
|
(*out)[key] = outVal
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@ metadata:
|
|||||||
namespace: default
|
namespace: default
|
||||||
spec:
|
spec:
|
||||||
TPMHash: "something"
|
TPMHash: "something"
|
||||||
label: "label"
|
partitionSecrets:
|
||||||
passphraseRef:
|
LABEL:
|
||||||
name: mysecret
|
name: mysecret
|
||||||
path: pass
|
path: pass
|
||||||
quarantined: false
|
quarantined: false
|
||||||
|
@ -87,10 +87,16 @@ func Start(ctx context.Context, kclient *kubernetes.Clientset, reconciler *contr
|
|||||||
|
|
||||||
found := false
|
found := false
|
||||||
var volume keyserverv1alpha1.SealedVolume
|
var volume keyserverv1alpha1.SealedVolume
|
||||||
|
var passsecret *keyserverv1alpha1.SecretSpec
|
||||||
for _, v := range volumeList.Items {
|
for _, v := range volumeList.Items {
|
||||||
if hashEncoded == v.Spec.TPMHash && v.Spec.Label == label {
|
if hashEncoded == v.Spec.TPMHash {
|
||||||
found = true
|
for l, secretRef := range v.Spec.Passphrase {
|
||||||
volume = v
|
if l == label {
|
||||||
|
found = true
|
||||||
|
volume = v
|
||||||
|
passsecret = secretRef
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,11 +125,10 @@ func Start(ctx context.Context, kclient *kubernetes.Clientset, reconciler *contr
|
|||||||
writer, _ := conn.NextWriter(websocket.BinaryMessage)
|
writer, _ := conn.NextWriter(websocket.BinaryMessage)
|
||||||
|
|
||||||
if !volume.Spec.Quarantined {
|
if !volume.Spec.Quarantined {
|
||||||
secret, err := kclient.CoreV1().Secrets(namespace).Get(ctx, volume.Spec.Passphrase.Name, v1.GetOptions{})
|
secret, err := kclient.CoreV1().Secrets(namespace).Get(ctx, passsecret.Name, v1.GetOptions{})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
passphrase := secret.Data[volume.Spec.Passphrase.Path]
|
passphrase := secret.Data[passsecret.Path]
|
||||||
json.NewEncoder(writer).Encode(map[string]string{"passphrase": string(passphrase)})
|
json.NewEncoder(writer).Encode(map[string]string{"passphrase": string(passphrase)})
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
conn.Close()
|
conn.Close()
|
||||||
|
Loading…
Reference in New Issue
Block a user