github.com/altoros/juju-vmware@v0.0.0-20150312064031-f19ae857ccca/provider/azure/customdata.go (about) 1 // Copyright 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package azure 5 6 import ( 7 "encoding/base64" 8 "fmt" 9 10 "github.com/juju/juju/environs" 11 "github.com/juju/juju/environs/cloudinit" 12 ) 13 14 // makeCustomData produces custom data for Azure. This is a base64-encoded 15 // zipfile of cloudinit userdata. 16 func makeCustomData(cfg *cloudinit.MachineConfig) (string, error) { 17 zipData, err := environs.ComposeUserData(cfg, nil) 18 if err != nil { 19 return "", fmt.Errorf("failure while generating custom data: %v", err) 20 } 21 logger.Debugf("user data; %d bytes", len(zipData)) 22 encodedData := base64.StdEncoding.EncodeToString(zipData) 23 logger.Debugf("base64-encoded custom data: %d bytes", len(encodedData)) 24 return encodedData, nil 25 }