Extract certificate add token metadata from remote member#13733
Extract certificate add token metadata from remote member#13733tomponline merged 2 commits intocanonical:mainfrom
Conversation
There was a problem hiding this comment.
Thanks!
Could we do this wrangling inside certificateTokenValid and have it return a *api.CertificatesPost to avoid the caller having to care anything about how the operation is decoded.
9e3f120 to
f300e7f
Compare
Done. I've tested this locally by creating a two node cluster, getting a join token from one member, then using the URL of the other member when adding the remote. Should I also add a test for this somewhere in the clustering suite? Not sure how easy it'll be. |
That would be great if not too involved |
When a certificate add operation is returned by another member, the operation metadata is unmarshalled into a map[string]any. Since there is no hint that the value of `Metadata["request"]` should be an `api.CertificatesPost`, the contents will be another `map[string]any` following json unmarshalling defaults. So that we do not encounter issues with diverging field names if the `api.CertificatesPost` type changes, I have opted to marshal the `any` that is in `Metadata["request"]`, and subsequently unmarshal it into the correct type. Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
f300e7f to
af70982
Compare
Ok I'll give it a go tomorrow morning. |
|
Tests added in #13740 |
When a certificate add operation is returned by another member, the operation metadata is unmarshalled into a map[string]any. Since there is no hint that the value of
Metadata["request"]should be anapi.CertificatesPost, the contents will be anothermap[string]anyfollowing json unmarshalling defaults.So that we do not encounter issues with diverging field names if the
api.CertificatesPosttype changes, I have opted to marshal theanythat is inMetadata["request"], and subsequently unmarshal it into the correct type.Closes #13732