← Back to team overview

cloud-init-dev team mailing list archive

Re: [Merge] ~smoser/cloud-init:bug/1717598-fix-gce-user-data into cloud-init:master

 

addressed Chad's comment. (thanks chad).


Diff comments:

> diff --git a/cloudinit/sources/DataSourceGCE.py b/cloudinit/sources/DataSourceGCE.py
> index 94484d6..5438842 100644
> --- a/cloudinit/sources/DataSourceGCE.py
> +++ b/cloudinit/sources/DataSourceGCE.py
> @@ -211,8 +209,17 @@ if __name__ == "__main__":
>                          help="Ignore smbios platform check",
>                          action='store_false', default=True)
>      args = parser.parse_args()
> -    print(json.dumps(
> -        read_md(address=args.endpoint, platform_check=args.platform_check),
> -        indent=1, sort_keys=True, separators=(',', ': ')))
> +    data = read_md(address=args.endpoint, platform_check=args.platform_check)
> +    # user-data is binary
> +    if 'user-data' in data:
> +        try:
> +            user_data = data['user-data'].decode()

fixed.

> +            data['user-data'] = data['user-data'].decode()
> +        except UnicodeDecodeError:
> +            sys.stderr.write("User-data cannot be decoded. "
> +                             "Writing as base64\n")
> +            data['user-data-b64'] = b64decode(data['user-data']).decode()
> +
> +    print(json.dumps(data, indent=1, sort_keys=True, separators=(',', ': ')))
>  
>  # vi: ts=4 expandtab


-- 
https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/330880
Your team cloud-init commiters is requested to review the proposed merge of ~smoser/cloud-init:bug/1717598-fix-gce-user-data into cloud-init:master.


References