예제 #1
0
func (s *ConverterSuite) TestConvertGitDeployerBeforeDeploy(c *gc.C) {
	gitDeployer := charm.NewGitDeployer(s.targetPath, s.dataPath, s.bundles)
	info := s.bundles.AddBundle(c, charmURL(1), mockBundle{})
	err := gitDeployer.Stage(info, nil)
	c.Assert(err, gc.IsNil)

	deployer, err := charm.NewDeployer(s.targetPath, s.dataPath, s.bundles)
	c.Assert(err, gc.IsNil)
	err = charm.FixDeployer(&deployer)
	c.Assert(err, gc.IsNil)
	c.Assert(deployer, jc.Satisfies, charm.IsManifestDeployer)
	ft.Removed{"current"}.Check(c, s.dataPath)

	err = deployer.Stage(info, nil)
	c.Assert(err, gc.IsNil)
	err = deployer.Deploy()
	c.Assert(err, gc.IsNil)
	ft.Removed{".git"}.Check(c, s.targetPath)
}
예제 #2
0
func (s *ConverterSuite) TestPathological(c *gc.C) {
	initial := s.bundles.AddCustomBundle(c, charmURL(1), func(path string) {
		ft.File{"common", "initial", 0644}.Create(c, path)
		ft.File{"initial", "blah", 0644}.Create(c, path)
	})
	staged := s.bundles.AddCustomBundle(c, charmURL(2), func(path string) {
		ft.File{"common", "staged", 0644}.Create(c, path)
		ft.File{"user", "badwrong", 0644}.Create(c, path)
	})
	final := s.bundles.AddCustomBundle(c, charmURL(3), func(path string) {
		ft.File{"common", "final", 0644}.Create(c, path)
		ft.File{"final", "blah", 0644}.Create(c, path)
	})

	gitDeployer := charm.NewGitDeployer(s.targetPath, s.dataPath, s.bundles)
	err := gitDeployer.Stage(initial, nil)
	c.Assert(err, gc.IsNil)
	err = gitDeployer.Deploy()
	c.Assert(err, gc.IsNil)

	preserveUser := ft.File{"user", "preserve", 0644}.Create(c, s.targetPath)
	err = gitDeployer.Stage(staged, nil)
	c.Assert(err, gc.IsNil)

	deployer, err := charm.NewDeployer(s.targetPath, s.dataPath, s.bundles)
	c.Assert(err, gc.IsNil)
	err = charm.FixDeployer(&deployer)
	c.Assert(err, gc.IsNil)

	err = deployer.Stage(final, nil)
	c.Assert(err, gc.IsNil)
	err = deployer.Deploy()
	c.Assert(err, gc.IsNil)
	ft.Removed{".git"}.Check(c, s.targetPath)
	ft.Removed{"initial"}.Check(c, s.targetPath)
	ft.Removed{"staged"}.Check(c, s.targetPath)
	ft.File{"common", "final", 0644}.Check(c, s.targetPath)
	preserveUser.Check(c, s.targetPath)
}
예제 #3
0
파일: uniter.go 프로젝트: klyachin/juju
// fixDeployer replaces the uniter's git-based charm deployer with a manifest-
// based one, if necessary. It should not be called unless the existing charm
// deployment is known to be in a stable state.
func (u *Uniter) fixDeployer() error {
	if err := charm.FixDeployer(&u.deployer); err != nil {
		return fmt.Errorf("cannot convert git deployment to manifest deployment: %v", err)
	}
	return nil
}
예제 #4
0
파일: deployer.go 프로젝트: imoapps/juju
// Fix replaces a git-based charm deployer with a manifest-based one, if
// necessary. It should not be called unless the existing charm deployment
// is known to be in a stable state.
func (d *deployerProxy) Fix() error {
	if err := charm.FixDeployer(&d.Deployer); err != nil {
		return errors.Annotatef(err, "cannot convert git deployment to manifest deployment")
	}
	return nil
}