func (AzureRenderer) Render(cfg cloudinit.CloudConfig, os jujuos.OSType) ([]byte, error) { switch os { case jujuos.Ubuntu: return renderers.RenderYAML(cfg, utils.Gzip, renderers.ToBase64) case jujuos.CentOS: return renderers.RenderScript(cfg, renderers.ToBase64) case jujuos.Windows: return renderers.RenderYAML(cfg, renderers.WinEmbedInScript, renderers.ToBase64) default: return nil, errors.Errorf("Cannot encode userdata for OS: %s", os) } }
func (s *RenderersSuite) TestRenderScript(c *gc.C) { cloudcfg := &cloudinittest.CloudConfig{Script: "script"} d1 := func(in []byte) []byte { return []byte("1." + string(in)) } d2 := func(in []byte) []byte { return []byte("2." + string(in)) } out, err := renderers.RenderScript(cloudcfg, d2, d1) c.Assert(err, jc.ErrorIsNil) c.Assert(string(out), jc.DeepEquals, "1.2.script") cloudcfg.CheckCallNames(c, "RenderScript") }