jclouds-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ignasi Barrera <notificati...@github.com>
Subject Re: [jclouds] [Softlayer] Implements setting and retrieving the notes property (#756)
Date Fri, 05 Jun 2015 12:44:50 GMT
> +         Map<String, String> meta = templateOptions.getUserMetadata();
> +         if (meta != null && !meta.isEmpty()) {
> +            if (meta.containsKey(USER_META_NOTES)) {
> +               return meta.get(USER_META_NOTES);
> +            } else {
> +               String notes = "User Metadata\n===========\n\n" + Joiner.on("\n").withKeyValueSeparator(":
").join(meta);
> +               if (notes.length() > SoftLayerTemplateOptions.NOTES_MAX_LENGTH) {
> +                  String suffix = "...\n<truncated>";
> +                  notes = notes.substring(0, SoftLayerTemplateOptions.NOTES_MAX_LENGTH
- suffix.length()) + suffix;
> +               }
> +               return notes;
> +            }
> +         }
> +      }
> +      return null;
> +   }

Ok. In that case, and given that SoftLayer does not support user metadata I wouldn't have
the two approaches of having a dedicated "key" or serialise the entire metadata map. I'd pick
just one. We'd document the key to use to set the notes, or we document that we'll assume
all user metadata to be serialised as the notes, but not both. Pick the one you prefer :)

Also note that you are not taking not account the notes max length when reading the `USER_META_NOTES`
key. Perhaps you also have to truncate it there?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/756/files#r31808918
Mime
View raw message