コード例 #1
0
ファイル: trivial_test.go プロジェクト: CSRedRat/juju-core
func (utilsSuite) TestCompression(c *C) {
	cdata := utils.Gzip(data)
	c.Assert(len(cdata) < len(data), Equals, true)
	data1, err := utils.Gunzip(cdata)
	c.Assert(err, IsNil)
	c.Assert(data1, DeepEquals, data)

	data1, err = utils.Gunzip(compressedData)
	c.Assert(err, IsNil)
	c.Assert(data1, DeepEquals, data)
}
コード例 #2
0
ファイル: cloudinit.go プロジェクト: hivetech/judo.legacy
// ComposeUserData puts together a binary (gzipped) blob of user data.
// The additionalScripts are additional command lines that you need cloudinit
// to run on the instance.  Use with care.
func ComposeUserData(cfg *cloudinit.MachineConfig, additionalScripts ...string) ([]byte, error) {
	cloudcfg := coreCloudinit.New()
	for _, script := range additionalScripts {
		cloudcfg.AddRunCmd(script)
	}
	cloudcfg, err := cloudinit.Configure(cfg, cloudcfg)
	if err != nil {
		return nil, err
	}
	data, err := cloudcfg.Render()
	if err != nil {
		return nil, err
	}
	return utils.Gzip(data), nil
}