Uh oh!
There was an error while loading. Please reload this page.
UI: Fix Userdata registration from UI - #8791
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@## 4.19 #8791 +/- ##
============================================
+ Coverage 30.91% 31.01% +0.10% - Complexity 34249 34339 +90
============================================
Files 5354 5354 Lines 376094 376482 +388 Branches 54696 54927 +231 ============================================
+ Hits 116258 116776 +518 + Misses 244542 244384 -158 - Partials 15294 15322 +28
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
weizhouapache
commented
Mar 14, 2024
@Pearl1594 |
Pearl1594
commented
Mar 14, 2024
@weizhouapache we could - do you mean that users would need to specify if its encoded or not? If so, wouldn't it be user friendly if we have the code decide if it's encoded or not and accordingly proceed ? |
@Pearl1594 let me explain with an example cloud-init supports userdata compressed by gzip. I use the same userdata as #8739 when I register userdata with userdata |
Pearl1594
commented
Mar 14, 2024
@weizhouapache sorry I didn't quite understand why the gzip in between. |
weizhouapache
commented
Mar 14, 2024
refer to https://cloudinit.readthedocs.io/en/latest/explanation/format.html#gzip-compressed-content Gzip compressed content
I think it is OK as the userdata is binary. moreover, if an user input a base64-encoded string on UI, we do not know if the user wants the string to be the userdata, or decode it as userdata, it would be good to ask the user to tell us. |
Pearl1594
commented
Mar 14, 2024
Ok got it, I'll add a checkbox that will only be used by the ui to determine whether to encode the provided userdata or not.. |
weizhouapache
commented
Mar 14, 2024
good ,looking forward to it |
| app.config.globalProperties.$toBase64AndURIEncoded = function (text) { | ||
| const base64regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/ | ||
| if (base64regex.test(text)) { | ||
| if (isBase64(text)) { |
There was a problem hiding this comment.
@Pearl1594
thanks for the update.
with your latest change, do we still need this ?
if (isBase64(text)) {
return text
}
There was a problem hiding this comment.
Do we not want the text that's not encoded to be encoded and saved in the DB .. I thought the idea of the flag was the prevent encoding an already encoded string
There was a problem hiding this comment.
@Pearl1594
I think the logic can be simple as below
- if checkbox is ticked, pass the origin input
- if checkbox is not ticked, (Base64AndURI) encode the input and pass to API
There was a problem hiding this comment.
oh, wait @Pearl1594
the method toBase64AndURIEncoded is being used in some other files..
ui/src/utils/plugins.js: app.config.globalProperties.$toBase64AndURIEncoded = function (text) {
ui/src/views/compute/CreateAutoScaleVmGroup.vue: createVmGroupData.userdata = this.$toBase64AndURIEncoded(values.userdata)
ui/src/views/compute/DeployVM.vue: deployVmData.userdata = this.$toBase64AndURIEncoded(values.userdata)
ui/src/views/compute/DeployVnfAppliance.vue: createVnfAppData.userdata = this.$toBase64AndURIEncoded(values.userdata)
ui/src/views/compute/EditVM.vue: params.userdata = this.$toBase64AndURIEncoded(values.userdata)
ui/src/views/compute/RegisterUserData.vue: params.userdata = this.$toBase64AndURIEncoded(values.userdata)
ui/src/views/compute/ResetUserData.vue: params.userdata = this.$toBase64AndURIEncoded(values.userdata)
There was a problem hiding this comment.
@Pearl1594 I think the logic can be simple as below
* if checkbox is ticked, pass the origin input * if checkbox is not ticked, (Base64AndURI) encode the input and pass to API
That is what is happening in RegisterUserdata component, that we see if it's unchecked and call the encode method.
There was a problem hiding this comment.
@Pearl1594@weizhouapache is there a consensus on changes here?
There was a problem hiding this comment.
I had forgotten about this PR - however, @weizhouapache 's input would be appreciated at this point.
DaanHoogland
commented
Jun 18, 2024
@weizhouapache is this ok by you? or else what still needs to be done ? cc @Pearl1594 ? |
weizhouapache
commented
Jun 18, 2024
verified ok
it looks good in database and UI |
weizhouapache
commented
Jun 18, 2024
thanks @Pearl1594 , merging |
* UI: Fix Userdata registration from UI * add isbase64 checkbox




Description
This PR fixes: #8736
Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
Userdata is base64 encoded:

Response:

Response:

How did you try to break this feature and the system with this change?