nacx commented on this pull request.

>I intentionally left the old "wrong" variant via the userMetaData map in place 
>in order to not break existing code.

Good! In that case, what about overriding the `userMetadata` methods in the 
DigitalOceanTemplateOptions too, and mark them `@Deprecated` pointing users to 
the right version? That would help them migrate the code and would also allow 
us to identify this when it comes to remove this legacy code in future versions.

> -         List<String> regionFeatures = (List<String>) 
> template.getLocation().getMetadata().get("features");
-         if (regionFeatures.contains("metadata")) {
-            options.userData(json.toJson(metadataAndTags));
-         } else {
-            logger.debug(">> region %s does not support metadata, ignoring 
provided user data", template.getLocation()
-                  .getId());
-         }
+      // In DigitalOcean, user_data is a SINGLE string, NOT a map!
+      // Encoding tags or anything else than user_data in here breaks their 
functionality.
+      if (null != templateOptions.getUserData()) {
+         setUserDataIfSupported(template, options, new 
String(templateOptions.getUserData()));
+      }
+      // Backwards compatible variant, getting userData from userMetaData map.
+      Map<String, String> metadataAndTags = templateOptions.getUserMetadata();
+      if (null != metadataAndTags.get("user_data")) {
+         setUserDataIfSupported(template, options, 
metadataAndTags.get("user_data"));
       }

Set this in an `else` block for the first conditional to only call the 
backwards compatible logic if the new method has not been configured?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1042#pullrequestreview-10499313

Reply via email to