Merge pull request #438 from hujingnb/fix/k8s_secret

fix: k8s secret not updated
This commit is contained in:
Yoan.liu 2025-02-08 08:56:52 +08:00 committed by GitHub
commit 049707acdc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -131,6 +131,11 @@ func (d *K8sSecretDeployer) Deploy(ctx context.Context, certPem string, privkeyP
secretPayload.ObjectMeta.Annotations[k] = v secretPayload.ObjectMeta.Annotations[k] = v
} }
} }
if secretPayload.Data == nil {
secretPayload.Data = make(map[string][]byte)
}
secretPayload.Data[d.config.SecretDataKeyForCrt] = []byte(certPem)
secretPayload.Data[d.config.SecretDataKeyForKey] = []byte(privkeyPem)
secretPayload, err = client.CoreV1().Secrets(d.config.Namespace).Update(context.TODO(), secretPayload, k8sMeta.UpdateOptions{}) secretPayload, err = client.CoreV1().Secrets(d.config.Namespace).Update(context.TODO(), secretPayload, k8sMeta.UpdateOptions{})
if err != nil { if err != nil {
return nil, xerrors.Wrap(err, "failed to update k8s secret") return nil, xerrors.Wrap(err, "failed to update k8s secret")